42 lines
711 B
C#
42 lines
711 B
C#
using UnityEngine;
|
|
|
|
public class GridObject
|
|
{
|
|
private GridXZ<GridObject> _grid;
|
|
private int _x;
|
|
private int _z;
|
|
private Transform _transform;
|
|
|
|
|
|
public GridObject(GridXZ<GridObject> grid, int x, int z)
|
|
{
|
|
_grid = grid;
|
|
_x = x;
|
|
_z = z;
|
|
}
|
|
|
|
public void SetTransform(Transform transform)
|
|
{
|
|
_transform = transform;
|
|
_grid.TriggerGridObjectChanged(_x, _z);
|
|
}
|
|
|
|
public void ClearTransform()
|
|
{
|
|
_transform = null;
|
|
_grid.TriggerGridObjectChanged(_x, _z);
|
|
}
|
|
|
|
public bool CanPlace()
|
|
{
|
|
return _transform == null;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return _x + "," + _z;
|
|
}
|
|
}
|
|
|
|
|