Ejemplo n.º 1
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            Koopa2 koopa = (Koopa2)gameObject1;

            if (koopa.State.GetType() == typeof(KoopaSideDeathState))
            {
                return;
            }
            Goomba2 goomba = (Goomba2)gameObject2;

            if (!goomba.Alive)
            {
                return;
            }

            if (koopa.State.GetType() == typeof(KoopaDeadState) &&
                koopa.Velocity.X != GameUtilities.StationaryVelocity)
            {
                ScoringSystem.Player1Score.AddPointsForEnemyHitByShell(gameObject1);
                goomba.Terminate("LEFT");
                return;
            }

            koopa.Location = new Vector2(koopa.Location.X - GameUtilities.SinglePixel, koopa.Location.Y);
            koopa.ChangeDirection();
            goomba.ChangeDirection();
        }
Ejemplo n.º 2
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            IMario  mario  = (IMario)gameObject1;
            Goomba2 goomba = (Goomba2)gameObject2;

            if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead ||
                mario.IsProtected || !goomba.Alive)
            {
                return;
            }

            int marioPreY = (int)(mario.Destination.Y - (mario.Velocity.Y - GameUtilities.SinglePixel));

            if (marioPreY + mario.Destination.Height < gameObject2.Destination.Y)
            {
                ICollisionCommand TopCommand = new MarioGoombaCollisionTop();

                TopCommand.Execute(gameObject1, gameObject2);
                return;
            }

            else if (marioPreY > gameObject2.Destination.Y + gameObject2.Destination.Height)
            {
                ICollisionCommand BottomCommand = new MarioGoombaCollisionBottom();
                BottomCommand.Execute(gameObject1, gameObject2);
                return;
            }

            if (goomba.Alive)
            {
                if (mario.State.IsStar == true)
                {
                    ScoringSystem.PlayerScore(mario.Player).AddPointsForSpecialGoombaHit(gameObject2);
                    goomba.Terminate("RIGHT");
                }
                else
                {
                    goomba.ChangeDirection();
                    switch (mario.State.MarioShape)
                    {
                    case MarioState.MarioShapeEnums.Small:
                        mario.State.Terminated();
                        break;

                    case MarioState.MarioShapeEnums.Big:
                        mario.IsProtected = true;
                        GameUtilities.GameObjectManager.MarioTransition(mario.State.MarioShape, MarioState.MarioShapeEnums.Small, mario);
                        SoundManager.Instance.PlayPipeSound();
                        break;

                    case MarioState.MarioShapeEnums.Fire:
                        mario.IsProtected = true;
                        GameUtilities.GameObjectManager.MarioTransition(mario.State.MarioShape, MarioState.MarioShapeEnums.Small, mario);
                        SoundManager.Instance.PlayPipeSound();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            FireBallProjectile fireBall = (FireBallProjectile)gameObject1;
            Goomba2            enemy    = (Goomba2)gameObject2;

            if (!enemy.Alive)
            {
                return;
            }
            if (enemy.State.GetType() != typeof(GoombaDeadState))
            {
                fireBall.Terminate();
                ScoringSystem.AddPointsForFireballGoombaHit(gameObject2, fireBall.InitiatingPlayer);
                enemy.Terminate("LEFT");
                SoundManager.Instance.PlayKickSound();
            }
        }