Exemple #1
0
 public Tile GetExit()
 {
     return(Parse(() =>
     {
         var line = ReadLine(3);
         var arr = line.Split(' ');
         Throw.If <Exception>(() => arr.Length != 2);
         var positionX = int.Parse(arr[0]);
         var positionY = int.Parse(arr[1]);
         return _tileFactory.Create(positionX, positionY, TileType.Exit);
     }));
 }
 private void Fill(ITileFactory tileFactory)
 {
     for (int x = 0; x < SizeX; x++)
     {
         for (int y = 0; y < SizeY; y++)
         {
             _gameTiles.Add(tileFactory.Create(new Coordinate(x, y), OwnerType));
         }
     }
 }
Exemple #3
0
 public void InitializeBoard()
 {
     Enumerable
     .Range(0, GameSettings.TilesCount)
     .ToList()
     .Shuffle()
     .Select(i => i < GameSettings.MinesCount)
     .Select((hasMine, i) => (hasMine, i))
     .Select(tuple =>
             (column: tuple.i % GameSettings.Columns, row: tuple.i / GameSettings.Columns, tuple.hasMine))
     .Select(x => _tileFactory.Create(x.column, x.row, x.hasMine))
     .ForEach(AddTile);
 }
        public ITile[,] Generate(ITileFactory _tileGenerator, BoxCollider _planeCollider, int _width = 100, int _height = 100)
        {
            width  = _width;
            height = _height;

            tiles = new ITile[width, height];
            _planeCollider.transform.position += new Vector3(width / 2, height / 2, 0);
            _planeCollider.size = new Vector3(width, height, _planeCollider.size.z);

            for (int y = 0; y < _height; y++)
            {
                for (int x = 0; x < _width; x++)
                {
                    tiles[x, y] = _tileGenerator.Create(x, y);
                }
            }

            FillRandomTiles(10);

            return(tiles);
        }