92 lines
2.1 KiB
C#
92 lines
2.1 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class TileComponent : MonoBehaviour
|
|
{
|
|
public int x;
|
|
public int y;
|
|
|
|
public bool isOccupied;
|
|
public bool isOccupiedByCrop;
|
|
public bool isOccupiedByInteractableItem;
|
|
|
|
public Tile tile;
|
|
|
|
public TMP_Text coordinatesText;
|
|
|
|
|
|
// Start is called before the first frame update
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
public void SetTile(int x, int y)
|
|
{
|
|
this.x = x;
|
|
this.y = y;
|
|
}
|
|
|
|
public void SetOccupied(bool isOccupied)
|
|
{
|
|
this.isOccupied = isOccupied;
|
|
}
|
|
|
|
public void SetCoordinatesText()
|
|
{
|
|
coordinatesText = gameObject.transform.Find("Coord").GetComponent<TMP_Text>();
|
|
coordinatesText.text = x + "x" + y;
|
|
}
|
|
|
|
public void SetOccupiedByCrop(bool isOccupiedByCrop)
|
|
{
|
|
this.isOccupiedByCrop = isOccupiedByCrop;
|
|
}
|
|
|
|
public void SetOccupiedByInteractableItem(bool isOccupiedByInteractableItem)
|
|
{
|
|
this.isOccupiedByInteractableItem = isOccupiedByInteractableItem;
|
|
}
|
|
|
|
public void Initialize(int posX, int posY, Tile gSpace)
|
|
{
|
|
tile = gSpace;
|
|
x = posX;
|
|
y = posY;
|
|
// check if tile is occupied by crop or interactable item
|
|
isOccupied = tile != null;
|
|
isOccupiedByCrop = tile != null && tile.Crop != null;
|
|
isOccupiedByInteractableItem = tile != null && tile.InteractableItem != null;
|
|
SetTile(x, y);
|
|
SetCoordinatesText();
|
|
DrawTileBorder();
|
|
}
|
|
|
|
|
|
private void Debug()
|
|
{
|
|
// add black border around tile and white border around tile
|
|
// if tile is occupied by crop or interactable item
|
|
if (isOccupied)
|
|
{
|
|
// add black border around tile
|
|
|
|
|
|
// if tile is occupied by crop
|
|
if (isOccupiedByCrop)
|
|
{
|
|
// add white border around tile
|
|
}
|
|
|
|
// if tile is occupied by interactable item
|
|
if (isOccupiedByInteractableItem)
|
|
{
|
|
// add white border around tile
|
|
}
|
|
}
|
|
}
|
|
|
|
private void DrawTileBorder()
|
|
{
|
|
// add black border around tile
|
|
}
|
|
} |