Пример #1
0
    public void MoveUnit(UnitScript movingUnit, Vector3Int cell_pos)
    {
        WorldTile targetTile = worldTiles[cell_pos];
        bool      reachable;

        if (movingUnit.currentWorldTile is null)
        {
            reachable = true;
        }
        else
        {
            reachable = movingUnit.movableTiles.Contains(cell_pos);
        }

        if (reachable)
        {
            if (targetTile.IsEmpty())
            {
                Debug.Log("MOVE TO TILE");
                //move the selected object to the tile
                movingUnit.MoveToTile(cell_pos);
                DeselectUnit();
            }
            else
            {
                Debug.Log("Tile is full");
            }
        }
        else
        {
            Debug.Log("Tile not reachable");
        }
    }