예제 #1
0
        public Mario()
        {
            MaxHorizontalVelocity = GameValues.MarioWalkingSpeed;
            Velocity           = Vector2.Zero;
            MaxVelocity        = new Vector2(MaxHorizontalVelocity, GameValues.PhysicsMaxYVelocity);
            Acceleration       = Vector2.Zero;
            CollisionRectangle = new Rectangle((int)Position.X, (int)Position.Y, 0, 0);
            PlayableObjectStateTransitionMachine = new PlayableObjectStateTransitionMachine(this);
            Lives = GameValues.MarioStartingLives;

            numberOfFireballs = GameValues.MarioNumberOfFireBalls;
            fireballs         = new Fireball[numberOfFireballs];
            fireballs[0]      = new Fireball(Vector2.Zero, false, false);
            fireballs[1]      = new Fireball(Vector2.Zero, false, false);

            deathBuffer       = GameValues.MarioDeathBuffer;
            invisibleBuffer   = GameValues.MarioInvisibleBuffer;
            visibleBuffer     = GameValues.MarioVisibleBuffer;
            takenDamageBuffer = GameValues.MarioTakenDamageBuffer;
            starBuffer        = GameValues.MarioStarBuffer;

            InAir               = false;
            IsJumping           = false;
            StarPower           = false;
            IsSlidingOnPole     = false;
            TakenDamageState    = false;
            InCoinRoom          = false;
            IsEnteringPipe      = false;
            IsExitingPipe       = false;
            IsBig               = false;
            OnYoshi             = false;
            ReverseYoshiSprites = false;
        }
예제 #2
0
 public void HandleStaticCollision(string collisionDirection, IStaticObject staticObjectState)
 {
     if (Mario.Instance.PlayableObjectState.ToString() != "SuperMario.MarioStates.DeadMario")
     {
         PlayableObjectStateTransitionMachine.StaticStateChange(collisionDirection, staticObjectState);
     }
 }
예제 #3
0
        public void Update(GameTime gameTime)
        {
            if (this.PlayableObjectState.ToString() != "SuperMario.MarioStates.SmallMarioFlagSlideEnd" && this.PlayableObjectState.ToString() != "SuperMario.MarioStates.BigMarioFlagSlideEnd" && this.PlayableObjectState.ToString() != "SuperMario.MarioStates.FireMarioFlagSlideEnd")
            {
                MaxVelocity = new Vector2(MaxHorizontalVelocity, GameValues.PhysicsMaxYVelocity);
            }
            else
            {
                MaxVelocity = new Vector2(MaxHorizontalVelocity, 0);
            }

            if (Position.Y > GameValues.MarioDeathYPosition)
            {
                if (PlayableObjectState.ToString() != "SuperMario.MarioStates.DeadMario")
                {
                    PlayableObjectState = new DeadMario(this);
                }

                Lives--;
                if (Lives >= 1)
                {
                    GameStateMachine.Instance.GameState = new MarioRespawnState();
                }
                else
                {
                    if (deathBuffer > 0)
                    {
                        deathBuffer--;
                    }
                    else
                    {
                        deathBuffer = GameValues.MarioDeathBuffer;
                        GameStateMachine.Instance.GameState = new GameOverState();
                    }
                }
            }

            if (GameStateMachine.Instance.GameState.ToString() != "SuperMario.GameStates.MarioFreezeGameAnimationState")
            {
                Physics.Move(this);
            }

            PlayableObjectStateTransitionMachine.InvisibleBarrierCollision();
            Level.Instance.InvisibleBarrier.Update();

            for (int i = 0; i < fireballs.Length; i++)
            {
                fireballs[i].Update(gameTime);
            }

            if (StarPower)
            {
                if (starBuffer > 0)
                {
                    starBuffer--;
                }
                else
                {
                    starBuffer = GameValues.MarioStarBuffer;
                    StarPower  = !StarPower;
                }
            }

            PlayableObjectState.Update(gameTime);
        }