Beispiel #1
0
 public void MakeMove(Vector2Int pos, Player player)
 {
     Map.PlayerUse(Map.cellMap[pos], player, _tilemap);
     for (int addX = -1; addX <= 1; ++addX)
     {
         for (int addY = -1; addY <= 1; ++addY)
         {
             Vector2Int neighbourPos = new Vector2Int(pos.x + addX, pos.y + addY);
             if (!Map.cellMap.ContainsKey(neighbourPos))
             {
                 continue;
             }
             FieldCell neighbour = Map.cellMap[neighbourPos];
             neighbour.isAvaiable = Map.IsAvaiable(neighbourPos, _tilemap);
         }
     }
     currentPlayerIndex++;
     currentPlayerIndex %= players.Length;
 }
Beispiel #2
0
    private void Awake()
    {
        _mainCamera = Camera.main;
        _tilemap    = GetComponent <Tilemap>();
        Map         = new MapClass(mapSize);
        foreach (var pos in _tilemap.cellBounds.allPositionsWithin)
        {
            Vector3Int localPlace = new Vector3Int(pos.x, pos.y, pos.z);
            if (_tilemap.HasTile(localPlace))
            {
                _tilemap.SetTileFlags(localPlace, TileFlags.None);
                Map.cellMap[(Vector2Int)localPlace] = new FieldCell(_tilemap.GetTile(localPlace), (Vector2Int)localPlace);
            }
        }

        foreach (var player in players)
        {
            foreach (var cellPosition in player.cellPositions)
            {
                Map.PlayerUse(Map.cellMap[cellPosition], player, _tilemap);
            }
        }
    }