Beispiel #1
0
        private void handleBulletCollision(Bullet i_Bullet)
        {
            PlayerSpaceInvaders player = SpaceInvadersServices.GetPlayerComponent(this.Game, SerialNumber);

            if (player != null)
            {
                player.LoseLife();
                int remainingPlayerLifes = player.Lifes;
                this.Position = new Vector2(0, this.Position.Y);
                if (remainingPlayerLifes == 0)
                {
                    this.isDying = true;
                    LastAnimation();
                }
                else
                {
                    this.Position = new Vector2(0, this.Position.Y);
                    this.Animations["BlinkAnimator"].Reset();
                    this.Animations["BlinkAnimator"].Resume();
                }

                this.GameScreen.Remove(i_Bullet);
                i_Bullet.Dispose();
            }
        }
Beispiel #2
0
        public override void Collided(ICollidable i_Collidable)
        {
            Bullet         bullet           = i_Collidable as Bullet;
            Enemy          enemy            = i_Collidable as Enemy;
            Sprite         collidableSprite = i_Collidable as Sprite;
            List <Vector2> collidedPoints;
            bool           autoPixelClear = true;

            if (bullet != null)
            {
                CollisionServices.eCollisionDirection collisionDirection = m_CollisionServices.GetCollisionDirection(this, collidableSprite);
                int halfBulletHeight = (int)(bullet.Height * 0.55);
                if (m_CollisionServices.IsPixelsIntersect(this, collidableSprite, out collidedPoints, !autoPixelClear))
                {
                    m_HitSound.Play();
                    Sprite barrier = this as Sprite;
                    m_CollisionServices.ClearPixelsInVerticalDirection(ref barrier, collidedPoints, collisionDirection, halfBulletHeight);
                    this.GameScreen.Remove(bullet);
                    bullet.Dispose();
                }
            }

            if (enemy != null)
            {
                m_CollisionServices.IsPixelsIntersect(this, collidableSprite, out collidedPoints, autoPixelClear);
            }
        }
Beispiel #3
0
        public override void Collided(ICollidable i_Collidable)
        {
            Bullet bullet = i_Collidable as Bullet;

            if (bullet != null && !this.isDying)
            {
                this.Velocity = new Vector2(0);
                isDying       = true;
                m_SoundWhenKilled.Play();
                LastAnimation();
                PlayerSpaceInvaders player = SpaceInvadersServices.GetPlayerComponent(this.Game, bullet.GunSerialNumber);
                if (player != null)
                {
                    player.AddScore(Points);
                }

                this.GameScreen.Remove(bullet);
                bullet.Dispose();
            }
        }
Beispiel #4
0
        private void handleBulletCollision(Bullet i_Bullet)
        {
            PlayerSpaceInvaders player = SpaceInvadersServices.GetPlayerComponent(this.Game, SerialNumber);
            if (player != null)
            {
                player.LoseLife();
                int remainingPlayerLifes = player.Lifes;
                this.Position = new Vector2(0, this.Position.Y);
                if (remainingPlayerLifes == 0)
                {
                    this.isDying = true;
                    LastAnimation();
                }
                else
                {
                    this.Position = new Vector2(0, this.Position.Y);
                    this.Animations["BlinkAnimator"].Reset();
                    this.Animations["BlinkAnimator"].Resume();
                }

                this.GameScreen.Remove(i_Bullet);
                i_Bullet.Dispose();
            }
        }