add grid manager
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user