示例#1
0
 private void EnemyCollisions(EnemyStarfighter e)
 {
     // if player intersects with enemy
     if (e.boundingBox.Intersects(playerShip.boundingBox))
     {
         e.isVisible        = false;
         playerShip.health -= 20;
         SoundManager.justBoom.Play(volume: SoundManager.effectsVolume, pitch: 0.0f, pan: 0.0f);
         Level2Explosions explosionObject = new Level2Explosions(new Vector2(e.position.X + e.enemyTexture.Width / 2, e.position.Y + e.enemyTexture.Height / 2), explosionTexture);
         explosionObject.isVisible = true;
         explosionsList.Add(explosionObject);
         destroyCount++;
     }
     //
     foreach (Bullet playerBullet in playerShip.bulletList)
     {
         if (playerBullet.boundingBox.Intersects(e.boundingBox))
         {
             destroyCount++;
             playerBullet.isVisible = false;
             e.isVisible            = false;
             HUD.playerScore       += 30;
             SoundManager.justBoom.Play(volume: SoundManager.effectsVolume, pitch: 0.0f, pan: 0.0f);
             Level2Explosions explosionObject = new Level2Explosions(new Vector2(e.position.X + e.enemyTexture.Width / 2, e.position.Y + e.enemyTexture.Height / 2), explosionTexture);
             explosionObject.isVisible = true;
             explosionsList.Add(explosionObject);
         }
     }
 }
示例#2
0
        // Collisions

        private void AsteroidCollisions(Asteroid a)
        {
            // if player intersects with asteroid
            if (a.boundingBox.Intersects(playerShip.boundingBox))
            {
                a.isVisible        = false;
                playerShip.health -= 20;
                SoundManager.justBoom.Play(volume: SoundManager.effectsVolume, pitch: 0.0f, pan: 0.0f);
                Level2Explosions explosionObject = new Level2Explosions(a.position, explosionTexture);
                explosionObject.isVisible = true;
                explosionsList.Add(explosionObject);
            }
            // Player Attack at Asteroid
            foreach (Bullet playerBullet in playerShip.bulletList)
            {
                if (playerBullet.boundingBox.Intersects(a.boundingBox))
                {
                    playerBullet.isVisible = false;
                    a.isVisible            = false;
                    HUD.playerScore       += 10;
                    SoundManager.justBoom.Play(volume: SoundManager.effectsVolume, pitch: 0.0f, pan: 0.0f);
                    Level2Explosions explosionObject = new Level2Explosions(a.position, explosionTexture);
                    explosionObject.isVisible = true;
                    explosionsList.Add(explosionObject);
                }
            }
        }
示例#3
0
        public void Update(GameTime gameTime)
        {
            player.Update(gameTime);
            SoundEffects();
            SpawnScorpions();
            SpawnWalkers();
            SpawnDroids();
            SpawnImperials();
            SpawnBoss();
            foreach (Scorpion s in scorpionList)
            {
                s.Update(gameTime);
            }

            // immperial
            foreach (Imperial imp in imperialList)
            {
                imp.Update(gameTime);
                // imperial attack
                if (imp.isAttack)
                {
                    if (impBulletCounter > 0)
                    {
                        impBulletCounter--;
                    }

                    if (impBulletCounter <= 0)
                    {
                        //
                        Bullet bullet = new Bullet(imperial_blaster);
                        bullet.isVisible = true;
                        if (imp.spriteEffect == SpriteEffects.None)
                        {
                            bullet.isLeft   = true;
                            bullet.position = new Vector2(imp.position.X, imp.position.Y + (imp.texture.Height / 2) - 10);
                        }
                        else
                        if (imp.spriteEffect == SpriteEffects.FlipHorizontally)
                        {
                            bullet.isRight  = true;
                            bullet.position = new Vector2(imp.position.X + 30, imp.position.Y + (imp.texture.Height / 2) - 10);
                        }
                        imperialBulletList.Add(bullet);
                        imp_kol++;
                        SoundManager.imp_shoot.Play(volume: SoundManager.effectsVolume, pitch: 0.0f, pan: 0.0f);
                    }

                    if (imp_kol < 10)
                    {
                        if (impBulletCounter <= 0)
                        {
                            impBulletCounter = 35;
                        }
                    }
                    else if (imp_kol == 10)
                    {
                        if (impBulletCounter <= 0)
                        {
                            impBulletCounter = 110;
                        }
                    }
                    else if (imp_kol > 10)
                    {
                        if (impBulletCounter <= 0)
                        {
                            impBulletCounter = 35;
                            imp_kol          = 0;
                        }
                    }
                }
                // COLLISION
                if (player.boundingBox.Intersects(imp.boundingBox) && player.isAttacking)
                {
                    HUD.playerScore += 25;
                    //
                    ImperialDeath id = new ImperialDeath(die1, die2, die3, new Vector2(imp.position.X, imp.position.Y + 45), imp.spriteEffect);
                    id.isVisible = true;
                    imperialDeathList.Add(id);
                    //
                    imp.isVisible = false;
                    SoundManager.imp_death.Play(volume: SoundManager.effectsVolume, pitch: 0.0f, pan: 0.0f);
                }
            }

            Collisions();

            foreach (SandExplosion sandExp in sandExplosionList)
            {
                sandExp.Update(gameTime);
            }

            foreach (Walker w in walkerList)
            {
                w.Update(gameTime);
                if (w.isAttackingAnimation)
                {
                    WalkerCreateBullets(w);
                }

                // walker dies
                if (w.boundingBox.Intersects(player.boundingBox) && player.isAttacking)  // collision
                {
                    w.isVisible = false;
                    Level2Explosions explosionObject = new Level2Explosions(new Vector2(w.position.X + (w.texture.Width / 2), w.position.Y + (w.texture.Height / 2)), explosionTexture);
                    explosionObject.isVisible = true;
                    explosionsList.Add(explosionObject);
                    HUD.playerScore += 40;
                    SoundManager.walker_boom.Play(volume: SoundManager.effectsVolume, pitch: 0.0f, pan: 0.0f);
                }
            }

            foreach (Hit h in hitExplosions)
            {
                h.Update(gameTime);
            }

            // Droids
            foreach (GonkDroid gd in droidList)
            {
                gd.Update(gameTime);
            }

            foreach (DroidDesAnimation dda in spritesGonkDroidList)
            {
                dda.Update(gameTime);
            }

            // Imperial Death Animation
            foreach (ImperialDeath id in imperialDeathList)
            {
                id.Update(gameTime);
            }

            // Boss
            foreach (Boss3Level b in bossList)
            {
                b.Update(gameTime);
            }

            // ManageWalkers();
            ManageScorpions();
            ManageExplosions();
            WalkerManageBullets();
            HitManage();
            ManageWalkers();
            ManageDroids();
            ManageDroidSprites();
            ManageImperialBullets();
            ManageImperials();
            ManageImperialDeaths();
            ManageBoss();

            foreach (Level2Explosions explosion in explosionsList)
            {
                explosion.Update(gameTime);
            }
            ManageExplosionsBoom();
            hud.Update(gameTime, player);
            //
            foreach (BigMachine bm in bigMachineList)
            {
                bm.Update(gameTime);
            }
            //
            BigMachineSpawn();
            // boss death list
            foreach (DeathBoss3 d in dieList)
            {
                d.Update(gameTime);
            }
            //
            ManageDeathBossList();


            GameOver();
        }