added Tiles, basic TileBehaviour
This commit is contained in:
parent
66756be23b
commit
433158e658
8 changed files with 100 additions and 7 deletions
|
|
@ -13,7 +13,7 @@ GameObject:
|
||||||
- component: {fileID: 4752245148499717903}
|
- component: {fileID: 4752245148499717903}
|
||||||
- component: {fileID: 4752245148499717900}
|
- component: {fileID: 4752245148499717900}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: GrassTile
|
m_Name: BaseTile
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
|
|
@ -1,14 +1,18 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Tiles;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class GrassTile : MonoBehaviour
|
public class TileBehaviour : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
private BaseTile tile;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
Debug.Log("Created");
|
Debug.Log("Created");
|
||||||
|
SetTile(new GrassTile());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
|
|
@ -20,5 +24,12 @@ public class GrassTile : MonoBehaviour
|
||||||
void OnMouseDown()
|
void OnMouseDown()
|
||||||
{
|
{
|
||||||
Debug.Log("Clicked");
|
Debug.Log("Clicked");
|
||||||
|
tile.Clicked(/* Current tool */ null);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetTile(BaseTile tileToSet)
|
||||||
|
{
|
||||||
|
tile = tileToSet;
|
||||||
|
GetComponent<SpriteRenderer>().color = tile.getColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,4 +35,6 @@ public class TileController : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
42
Assets/Scripts/Tiles/BaseTile.cs
Normal file
42
Assets/Scripts/Tiles/BaseTile.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Tiles
|
||||||
|
{
|
||||||
|
public abstract class BaseTile
|
||||||
|
{
|
||||||
|
protected Color color;
|
||||||
|
public Color getColor => color;
|
||||||
|
// Later to be replaced with
|
||||||
|
// public Sprite sprite;
|
||||||
|
|
||||||
|
protected BaseTile(Color color)
|
||||||
|
{
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DayLightStep()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clicked(UsableItem usable)
|
||||||
|
{
|
||||||
|
Debug.Log(usable.ToString() + " used on " + this.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Scripts/Tiles/FarmlandTile.cs
Normal file
12
Assets/Scripts/Tiles/FarmlandTile.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Tiles
|
||||||
|
{
|
||||||
|
public class FarmlandTile : BaseTile
|
||||||
|
{
|
||||||
|
public FarmlandTile() : base(Color.black)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Scripts/Tiles/GrassTile.cs
Normal file
12
Assets/Scripts/Tiles/GrassTile.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Tiles
|
||||||
|
{
|
||||||
|
public class GrassTile : BaseTile
|
||||||
|
{
|
||||||
|
public GrassTile() : base(Color.green)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Scripts/Tiles/WaterTile.cs
Normal file
12
Assets/Scripts/Tiles/WaterTile.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Tiles
|
||||||
|
{
|
||||||
|
public class WaterTile : BaseTile
|
||||||
|
{
|
||||||
|
public WaterTile() : base(Color.blue)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,10 +16,12 @@ public class UsableItem : Item, IUsable
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UsableItem(string displayName, string description, int id) : base(displayName, description, id) {
|
public UsableItem(string displayName, string description, int id) : base(displayName, description, id)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void select() {
|
public void select()
|
||||||
|
{
|
||||||
PlayerController.getInstance().setSelectedItem(this);
|
PlayerController.getInstance().setSelectedItem(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue