コード例 #1
0
        public sealed override void Smooth()
        {
            Func <Tile, bool> condition = (currentTile) => currentTile.Type == Tile.TileType.WATER;
            Tile replacement            = new Tile()
            {
                Type = Tile.TileType.WATER, Icon = Tile.TileType.DEFAULT
            };

            CornerSmoother.Smooth(tile, condition, false, replacement);

            condition = (currentTile) => currentTile.Icon == Tile.TileType.FOREST;

            Tile[] replacements =
            {
                new Tile()
                {
                    Type = Tile.TileType.GRASS, Icon = Tile.TileType.PINE
                },
                new Tile()
                {
                    Type = Tile.TileType.GRASS, Icon = Tile.TileType.TREE
                },
                new Tile()
                {
                    Type = Tile.TileType.GRASS, Icon = Tile.TileType.DEFAULT
                }
            };

            CornerSmoother.Smooth(tile, condition, true, replacements);
        }
コード例 #2
0
        public sealed override void Smooth()
        {
            Func <Tile, bool> condition = (currentTile) => currentTile.Type == Tile.TileType.WATER;
            Tile replacement            = new Tile()
            {
                Type = Tile.TileType.WATER, Icon = Tile.TileType.DEFAULT
            };

            CornerSmoother.Smooth(tile, condition, false, replacement);

            if (tile.Orientation == Map.Orientation.Top)
            {
                land[LAND_WIDTH - 1, LAND_HEIGHT - 2].Icon = Tile.TileType.DEFAULT;
                land[LAND_WIDTH - 1, LAND_HEIGHT - 3].Icon = Tile.TileType.DEFAULT;
                land[LAND_WIDTH - 2, LAND_HEIGHT - 3].Icon = Tile.TileType.DEFAULT;

                land[0, LAND_HEIGHT - 2].Icon = Tile.TileType.DEFAULT;
                land[0, LAND_HEIGHT - 3].Icon = Tile.TileType.DEFAULT;
                land[1, LAND_HEIGHT - 3].Icon = Tile.TileType.DEFAULT;
            }
            else if (tile.Orientation == Map.Orientation.Bottom)
            {
                land[LAND_WIDTH - 1, 1].Icon = Tile.TileType.DEFAULT;
                land[LAND_WIDTH - 1, 2].Icon = Tile.TileType.DEFAULT;
                land[LAND_WIDTH - 2, 2].Icon = Tile.TileType.DEFAULT;

                land[0, 1].Icon = Tile.TileType.DEFAULT;
                land[0, 2].Icon = Tile.TileType.DEFAULT;
                land[1, 2].Icon = Tile.TileType.DEFAULT;
            }
            else if (tile.Orientation == Map.Orientation.Left)
            {
                land[1, LAND_HEIGHT - 1].Icon = Tile.TileType.DEFAULT;
                land[2, LAND_HEIGHT - 1].Icon = Tile.TileType.DEFAULT;
                land[2, LAND_HEIGHT - 2].Icon = Tile.TileType.DEFAULT;

                land[1, 0].Icon = Tile.TileType.DEFAULT;
                land[2, 0].Icon = Tile.TileType.DEFAULT;
                land[2, 1].Icon = Tile.TileType.DEFAULT;
            }
            else if (tile.Orientation == Map.Orientation.Right)
            {
                land[LAND_WIDTH - 2, LAND_HEIGHT - 1].Icon = Tile.TileType.DEFAULT;
                land[LAND_WIDTH - 3, LAND_HEIGHT - 1].Icon = Tile.TileType.DEFAULT;
                land[LAND_WIDTH - 3, LAND_HEIGHT - 2].Icon = Tile.TileType.DEFAULT;

                land[LAND_WIDTH - 2, 0].Icon = Tile.TileType.DEFAULT;
                land[LAND_WIDTH - 3, 0].Icon = Tile.TileType.DEFAULT;
                land[LAND_WIDTH - 3, 1].Icon = Tile.TileType.DEFAULT;
            }
        }
コード例 #3
0
        public sealed override void Smooth()
        {
            Func <Tile, bool> condition = (currentTile) =>
                                          currentTile.Type == Tile.TileType.PLAIN && (
                currentTile.Icon == Tile.TileType.FOREST ||
                currentTile.Icon == Tile.TileType.MOUNTAIN ||
                currentTile.Icon == Tile.TileType.DEFAULT);

            Tile replacement = new Tile()
            {
                Type = Tile.TileType.GRASS, Icon = Tile.TileType.DEFAULT
            };

            CornerSmoother.Smooth(tile, condition, false, replacement);
        }
コード例 #4
0
        /// <summary>
        /// Creates an new game instance.
        /// </summary>
        /// <param name="gameConfiguration"></param>
        public Game(Config gameConfiguration)
        {
            PathFinder.Initialize(this);
            CornerSmoother.Initialize(this, gameConfiguration.Seed);

            _configuration = gameConfiguration;
            _gameWorld     = new Map(gameConfiguration);
            _gameWorld.GenerateLands(gameConfiguration.Seed);
            _entities           = new List <Entity>();
            _view               = new View(_gameWorld);
            _selection          = new List <Entity>();
            _firstPersonSpawned = false;
            _entityFactory      = new EntityFactory();
            _entityFactory.AddObserver(this);
        }