Пример #1
0
        public void StartLevel(int levelNumber)
        {
            var levelInfo = new LevelInfo();
            levelInfo.Load(levelNumber);

            // world properties
            _world.Width = levelInfo.Width;
            _world.Height = levelInfo.Height;

            // init player
            _world.Player = new PlayerUnit(_world, levelInfo.Player);
            _world.Player.Direction = UnitDirection.Up;
            _world.Player.UserData = new VisualPlayerUnit(_world.Player,
                Gfx.Instance.GetPlayerMovementAnimation());

            // init walls
            foreach (var wall in levelInfo.MetalWalls)
            {
                var wallUnit = new WallUnit(_world, wall, WallUnit.WallType.MetalWall);
                wallUnit.UserData = new VisualWallUnit(wallUnit, Gfx.Instance.GetMetalWallSprite());
                _world.Walls.Add(wallUnit);
            }
            foreach (var wall in levelInfo.TreeWalls)
            {
                var wallUnit = new WallUnit(_world, wall, WallUnit.WallType.TreeWall);
                wallUnit.UserData = new VisualWallUnit(wallUnit, Gfx.Instance.GetTreeWallSprite());
                _world.Walls.Add(wallUnit);
            }

            const int defaultEnemiesCount = 4;
            const int defaultBonusesCount = 4;
            _enemiesGenerator = new EnemiesPopulationController(defaultEnemiesCount + levelNumber,
                _world, levelInfo.EnemiesGenerationPoints);
            _bonusesGenerator = new BonusesPopulationController(defaultBonusesCount,
                _world, levelInfo.BonusGenerationPoints);

            _world.UpdateMap();
        }
Пример #2
0
 public VisualWallUnit(WallUnit wallUnit, Sprite sprite)
 {
     WallUnit = wallUnit;
     Sprite = sprite;
 }