Ejemplo n.º 1
0
        /// <summary>
        /// Check if the game has ended, and if it did who won.
        /// </summary>
        public void CheckWin()
        {
            bool playerLost   = true;
            bool computerLost = true;

            foreach (Unit u in tiles.Cast <Tile>().Select((t) => { return(t.buildingOn); }))
            {
                if (u != null && u.type == UnitType.town)
                {
                    if (u.player)
                    {
                        playerLost = false;
                    }
                    else
                    {
                        computerLost = false;
                    }
                }
            }

            if (playerLost)
            {
                gameOver   = true;
                playerLost = true;
            }
            else if (computerLost)
            {
                gameOver  = true;
                playerWon = true;
            }
        }
Ejemplo n.º 2
0
    private void CreateBoard(int pXSize, int pYSize)
    {
        Board = new Tile[pXSize, pYSize];

        Vector2 offset = TilePrefab.GetComponent <SpriteRenderer>().bounds.size;
        float   startX = -((pXSize / 2) * offset.x);
        float   startY = -(pYSize / 2) * offset.y;

        for (int x = 0; x < pXSize; x++)
        {
            for (int y = 0; y < pYSize; y++)
            {
                GameObject newTileObj = Instantiate(TilePrefab, new Vector3(startX + (offset.x * x), startY + (offset.y * y)), TilePrefab.transform.rotation);
                Tile       newTile    = newTileObj.GetComponent <Tile>();

                Color tileColor = TileColors[Random.Range(0, TileColors.Count)];
                newTile.Initilize(x, y, tileColor);

                //Board.Add(newTile);
                Board[x, y] = newTile;
            }
        }

        AllTiles = Board.Cast <Tile>().ToList();
    }
        private IEnumerable <string> GetAllChoosableColors(Tile[,] tiles)
        {
            var originColor         = tiles[0, 0].Color;
            var allChooseAbleColors = tiles.Cast <Tile>()
                                      .Select(x => x.Color).Distinct()
                                      .Where(x => !x.Equals(originColor)).ToList();

            return(allChooseAbleColors);
        }
Ejemplo n.º 4
0
    public List <Tile> GetTilesWithinReach(Tile[,] tiles, Tile from, Weapon weapon = null)
    {
        if (scope == Scope.AOEEnemies || scope == Scope.AOEAllies)
        {
            return(tiles.Cast <Tile>().Where(tile => CanReach(from.point, tile.point, weapon) && tile != from).ToList());
        }
        if (scope == Scope.SingleEnemy || scope == Scope.SingleAlly)
        {
            return(tiles.Cast <Tile>().Where(tile =>
                                             CanReach(from.point, tile.point, weapon) && tile != from && tile.Occupant != null).ToList());
        }
        // if (scope == Scope.SingleAlly)
        // {
        //     return tiles.Cast<Tile>().Where(tile =>
        //         CanReach(from.point, tile.point, weapon) && tile != from).ToList();
        // }

        return(tiles.Cast <Tile>().ToList());
    }
Ejemplo n.º 5
0
 public IEnumerable <Tile> GetBoard()
 {
     return(board.Cast <Tile>().ToArray());
 }
Ejemplo n.º 6
0
 public bool AreAllTilesSameColor()
 {
     return(Tiles.Cast <Tile>()
            .All(s => string.Equals(Tiles[0, 0].Color, s.Color, StringComparison.InvariantCultureIgnoreCase)));
 }
Ejemplo n.º 7
0
 public Tile[] TilesWithMines()
 {
     return(Array.FindAll(Tiles.Cast <Tile>().ToArray(), t => t.IsMine));
 }