Beispiel #1
0
        /// <summary>
        /// Generates an 2D array of ITile with empty tiles.
        /// </summary>
        /// <param name="levelWidth">Level width.</param>
        /// <param name="levelHeight">Level height.</param>
        public static ITile[,] Generate(Level level, int levelWidth, int levelHeight)
        {
            ITile[,] tiles = new ITile[levelWidth, levelHeight];

            for (int x = 0; x < levelWidth; x++)
            {
                for (int y = 0; y < levelHeight; y++)
                {
                    ITile tile = new RegularTile(x, y);
                    tile.Subscribe(level);
                    tile.SubscribeToFurniture(level);

                    tiles[x, y] = tile;
                }
            }

            return(tiles);
        }
Beispiel #2
0
        public void TileTypeChangeCallback()
        {
            int callsCount = 0;
            var observer   = Substitute.For <ITileObserver>();

            observer.NotifyTileTypeChanged(Arg.Do <ITile>(x => callsCount += 1));

            Assert.AreEqual(callsCount, 0);

            tile.Type = TileIndex.New;
            Assert.AreEqual(callsCount, 0);

            tile.Subscribe(observer);

            tile.Type = TileIndex.New;
            Assert.AreEqual(callsCount, 1);

            tile.Type = TileIndex.Empty;
            tile.Type = TileIndex.New;
            Assert.AreEqual(callsCount, 3);
        }