Ejemplo n.º 1
0
        public override void Collided(ICollidable i_Collidable)
        {
            Enemy  enemy  = i_Collidable as Enemy;
            Bullet bullet = i_Collidable as Bullet;

            if (enemy != null)
            {
                if (!this.ShootingSpriteType.Name.Equals("Enemy"))
                {
                    if (!enemy.isDying)
                    {
                        Player        player        = SpaceInvadersServices.GetPlayerComponent(this.Game, this.GunSerialNumber);
                        EnemiesMatrix enemiesMatrix = SpaceInvadersServices.GetEnemeiesMatrixComponent(this.GameScreen);
                        enemiesMatrix.SpeedUp(0.92);
                        enemy.LastAnimation();
                        if (player != null)
                        {
                            player.AddScore(enemy.Points);
                        }

                        enemy.Dispose();
                    }

                    this.GameScreen.Remove(this);
                    this.Dispose();
                }
            }
            else if (bullet != null)
            {
                if (!bullet.ShootingSpriteType.Name.Equals(this.ShootingSpriteType.Name))
                {
                    if (this.ShootingSpriteType.Name.Equals("SpaceShip"))
                    {
                        this.GameScreen.Remove(this);
                        this.Dispose();
                    }
                    else if (this.ShootingSpriteType.Name.Equals("Enemy"))
                    {
                        int randomNumber = new Random().Next(1, 10);
                        if (randomNumber == 1)
                        {
                            this.GameScreen.Remove(this);
                            this.Dispose();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public override void Initialize()
 {
     initilizeOnFirstRun();
     SpritesFactory.CreateSprite(this, SpritesFactory.eSpriteType.MotherShip);
     SpritesFactory.CreateSprite(this, SpritesFactory.eSpriteType.SpaceBackground);
     EnemiesMatrix enemiesMatrix = new EnemiesMatrix(this);
     BarrierGroup barrierGroup = new BarrierGroup(this);
     m_MultiPlayerConfiguration = SpaceInvadersServices.GetMultiPlayerConfiguration(this.Game);
     m_MultiPlayerConfiguration.CreatePlayers(this);
     m_WonLevelSound = SoundFactory.CreateSound(this, SoundFactory.eSoundType.LevelWin);
     m_GameOverSound = SoundFactory.CreateSound(this, SoundFactory.eSoundType.GameOver);
     this.Add(enemiesMatrix);
     this.Add(barrierGroup);
     base.Initialize();
     SpaceInvadersServices.ChangeBarriersGroupVerticalPosition(this, barrierGroup);
 }