Esempio n. 1
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;
                    }
                }
            }
        }
Esempio n. 2
0
 private void SetMariosEnemyHitThisIterationToFalse()
 {
     ScoringSystem.PlayerScore(GameUtilities.Player1).SetMarioEnemyHitThisIterationToFalse();
     if (marios[GameUtilities.Player2] != null)
     {
         ScoringSystem.PlayerScore(GameUtilities.Player2).SetMarioEnemyHitThisIterationToFalse();
     }
 }
Esempio n. 3
0
 public Mario(Vector2 location, int player)
 {
     this.State         = new IdleRightSmallMarioState(this);
     this.Location      = location;
     this.player        = player;
     this.Velocity      = new Vector2(GameUtilities.StationaryVelocity, GameUtilities.StationaryVelocity);
     this.Acceleration  = new Vector2(GameUtilities.StationaryAcceleration, GameUtilities.Gravity);
     this.IsProtected   = false;
     this.MarioTopSpeed = GameUtilities.MarioRegularSpeed;
     ScoringSystem.PlayerScore(player).RegisterMario(this);
 }
Esempio n. 4
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            IMario mario  = (IMario)gameObject1;
            IEnemy goomba = (IEnemy)gameObject2;

            if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead || !goomba.Alive)
            {
                return;
            }
            ScoringSystem.PlayerScore(mario.Player).AddPointsForStompingEnemy(gameObject2);
            goomba.Terminate("LEFT");
            SoundManager.Instance.PlayStompSound();
        }
Esempio n. 5
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            IMario mario = (IMario)gameObject1;

            if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead)
            {
                return;
            }
            IEnemy koopa = (IEnemy)gameObject2;

            if (koopa.State.GetType() == typeof(KoopaSideDeathState))
            {
                return;
            }
            ScoringSystem.PlayerScore(mario.Player).AddPointsForStompingEnemy(gameObject2);
            koopa.Terminate("DOWN");
        }
Esempio n. 6
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            IMario mario  = (IMario)gameObject1;
            IEnemy goomba = (IEnemy)gameObject2;

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

            mario.Location = new Vector2(mario.Location.X, goomba.Location.Y - mario.Destination.Height + GameUtilities.SinglePixel);
            if (goomba.Alive)
            {
                mario.Velocity = new Vector2(mario.Velocity.X, GameUtilities.MarioBounceVelocity);
                ScoringSystem.PlayerScore(mario.Player).AddPointsForStompingEnemy(gameObject2);
                goomba.Terminate("TOP");
                SoundManager.Instance.PlayStompSound();
            }
        }
Esempio n. 7
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            IMario mario = (IMario)gameObject1;

            if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead)
            {
                return;
            }
            IEnemy koopa = (IEnemy)gameObject2;

            if (koopa.State.GetType() == typeof(KoopaSideDeathState))
            {
                return;
            }
            mario.Location = new Vector2(mario.Destination.X, koopa.Location.Y - mario.Destination.Height - GameUtilities.SinglePixel * 5);
            mario.Velocity = new Vector2(mario.Velocity.X, GameUtilities.MarioBounceVelocity);
            if (koopa.State.GetType() == typeof(KoopaDeadState))
            {
                SoundManager.Instance.PlayKickSound();
                if (koopa.Velocity.X == GameUtilities.StationaryVelocity)
                {
                    ScoringSystem.PlayerScore(mario.Player).AddPointsForInitiatingShell(gameObject2);
                    koopa.Velocity = new Vector2(GameUtilities.KoopaShellVelocity, koopa.Velocity.Y);
                }
                else
                {
                    koopa.Velocity = new Vector2(GameUtilities.StationaryVelocity, koopa.Velocity.Y);
                }
            }
            else
            {
                ScoringSystem.PlayerScore(mario.Player).AddPointsForStompingEnemy(gameObject2);
                koopa.Terminate("UP");
                koopa.Velocity = new Vector2(GameUtilities.StationaryVelocity, koopa.Velocity.Y);
                SoundManager.Instance.PlayStompSound();
            }
        }
Esempio n. 8
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            IMario mario = (IMario)gameObject1;

            if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead ||
                mario.IsProtected)
            {
                return;
            }
            Koopa2 koopa = (Koopa2)gameObject2;

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

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

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

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

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

            if (mario.State.IsStar == true)
            {
                ScoringSystem.PlayerScore(mario.Player).AddPointsForSpecialKoopaHit(gameObject2);
                koopa.Terminate("DOWN");
            }
            else
            {
                if (koopa.State.GetType() == typeof(KoopaDeadState) &&
                    koopa.Velocity.X == GameUtilities.StationaryVelocity)
                {
                    ScoringSystem.PlayerScore(mario.Player).AddPointsForInitiatingShell(gameObject2);
                    koopa.Velocity = new Vector2(GameUtilities.KoopaShellVelocity, koopa.Velocity.Y);

                    SoundManager.Instance.PlayKickSound();
                    return;
                }
                else if (koopa.State.GetType() == typeof(KoopaDeadState) && koopa.Velocity.X > 0)
                {
                    return;
                }
                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;
                    SoundManager.Instance.PlayPipeSound();
                    GameUtilities.GameObjectManager.MarioTransition(mario.State.MarioShape, MarioState.MarioShapeEnums.Small, mario);
                    break;
                }
                mario.Location = new Vector2(mario.Location.X, mario.Location.Y);
            }
        }