private void BuildLevel()
        {
            if (activeLevel.GetType() == typeof(Level1))
            {
                m_Level     = new Surface(LEVEL_WIDTH, LEVEL_HEIGHT);
                activeLevel = new Level1(m_Level, tileSize);
            }
            else if (activeLevel.GetType() == typeof(Level2))
            {
                m_Level     = new Surface(LEVEL_WIDTH, LEVEL_HEIGHT);
                activeLevel = new Level2(m_Level, tileSize);
            }
            else if (activeLevel.GetType() == typeof(Level3))
            {
                m_Level     = new Surface(LEVEL_WIDTH, LEVEL_HEIGHT);
                activeLevel = new Level3(m_Level, tileSize);
                background  = new Surface(@"Assets\Sprites\background_lvl1.jpg");
            }
            specialObjects = activeLevel.SpecialObjects;
            terrain        = activeLevel.GetTerrain();

            if (hero != null && hero.Dead != true)
            {
                Hero tempHero = hero;
                moveableObjects = new List <MoveableObject>();
                hero            = new Hero(m_Level, activeLevel.HeroPosition, "keyboard", this)
                {
                    HP = tempHero.HP, Weapons = tempHero.Weapons, On_the_ground = true
                };
                hero.RefreshWeapons();
                hero.CurrentWeapon = hero.Weapons.Last();
            }
            else
            {
                moveableObjects = new List <MoveableObject>();
                hero            = new Hero(m_Level, activeLevel.HeroPosition, "keyboard", this)
                {
                    On_the_ground = true
                };
            }
            moveableObjects.Add(hero);
            camera        = new Camera(SCREEN_WIDTH, SCREEN_HEIGHT, LEVEL_WIDTH, LEVEL_HEIGHT, hero);
            currentWeapon = hero.CurrentWeapon;
            foreach (var enemyPosition in activeLevel.EnemyPositions)
            {
                enemies.Add(new Enemy(m_Level, enemyPosition, this, true)); // moving
            }
            foreach (var idleEnemyPosition in activeLevel.IdleEnemyPositions)
            {
                enemies.Add(new Enemy(m_Level, idleEnemyPosition, this, false));  // not moving
            }
            if (activeLevel.BossPosition != null && activeLevel.BossPosition != new Point(0, 0))
            {
                bossEnemy = new BossEnemy(m_Level, activeLevel.BossPosition, this, false);
                enemies.Add(bossEnemy);
                bossEnemy.BossSound.Play();
            }
            moveableObjects.AddRange(enemies);
            done = true;
        }
예제 #2
0
 public Bullet(Surface video, BossEnemy bossEnemy, Manager manager, int angle, int direction, Point position) : base(video, manager) // voor BossEnemy
 {
     this.video     = video;
     this.manager   = manager;
     this.position  = position;
     this.bossEnemy = bossEnemy;
     Angle          = angle;
     bulletType     = new Surface(@"Assets\Sprites\guns\fireball.png");
     Width          = bulletType.Width;
     Height         = bulletType.Height;
     colRectangle   = new Rectangle(position.X, position.Y, Width, Height);
     velocity       = 8;
 }