Exemple #1
0
        public void EnemyInteraction(GameTime gameTime)
        {
            PlayerShip.Update(gameTime);
            for (int i = 0; i < PlayerShotList.Count; i++)
            {
                PlayerShotList[i].Update(gameTime);
                if (PlayerShotList[i].Position.Y < -100.0f)
                {
                    PlayerShotList.RemoveAt(i);
                }
            }



            for (int i = 0; i < EnemyList.Count; i++)
            {
                EnemyList[i].Update(gameTime);
                if (EnemyList[i].Firing)
                {
                    //Fireball fireball = new Fireball(enemyFireballTexture,
                    //new Vector2(EnemyList[i].Position.X + 10.0f,
                    //EnemyList[i].Position.Y + 30.0f), -300.0f);
                    //enemyFireballList.Add(fireball);
                    EnemyList[i].Firing = false;
                }
                bool ShipCollide = PlayerShip.Collision(EnemyList[i].Position, 20.0f);
                if (ShipCollide == true) //lose HP
                {
                    Health -= 20.0f;
                    Points += 75;
                    EnemyList.RemoveAt(i);
                    PlaySound(ExplodeNoise);
                    if (Health < 0.0f)
                    {
                        gamestate = GameState.EndScreen;
                    }
                }

                if (PlayerShotList.Count > 0)
                {
                    int FBallCollide = EnemyList[i].CollisionBall(PlayerShotList);
                    if (FBallCollide != -1)
                    {
                        if ((int)ShipType.Bandit == EnemyList[i].ShipType)
                        {
                            Points += 200;
                        }
                        if ((int)ShipType.Bandit_Elite == EnemyList[i].ShipType)
                        {
                            Points += 300;
                        }

                        EnemyList.RemoveAt(i);
                        PlayerShotList.RemoveAt(FBallCollide);

                        PlaySound(ExplodeNoise);
                    }
                }
            }
        }