Example #1
0
 public void TakeDamage()
 {
     if (!(MarioPowerUpState is MarioSmallState))
     {
         MarioPowerUpState = new MarioSmallState();
         action            = false;
     }
     if (action && !(MarioAnimatedState is MarioDeadState))
     {
         if (MarioPowerUpState is MarioSmallState)
         {
             MarioAnimatedState = new MarioDeadState(this);
             TreeNewBee.SuperMarioBros.Instance.Manager.SetDelay();
             SoundFactory.Instance.CreateMarioDeadSound();
             TreeNewBee.SuperMarioBros.Instance.ScManager.RemainingLife -= Constant.Constant.Instance.OneRemainingLife;
             if (TreeNewBee.SuperMarioBros.Instance.ScManager.RemainingLife <= Constant.Constant.Instance.NoRemainingLife)
             {
                 TreeNewBee.SuperMarioBros.Instance.Manager.LostGame();
                 SoundFactory.Instance.CreateGameOverSound();
             }
         }
         else if (MarioPowerUpState is MarioBigState)
         {
             MarioPowerUpState = new MarioSmallState();
         }
     }
 }
Example #2
0
 public MarioPlayer()
 {
     PreviousAnimationState = null;
     CurrentPowerState      = new MarioSmallState(this);
     CurrentAnimationState  = new MarioRightIdleState(this);
     MarioPhysics           = new MarioPhysicalProperty(this);
     Rectangle   = new Rectangle((int)Location.X, (int)Location.Y, CurrentAnimationState.Width, CurrentAnimationState.Height);
     IsIdle      = true;
     isAlive     = true;
     isFlash     = false;
     canKick     = true;
     starTimer   = Util.Instance.Zero;
     damageTimer = Util.Instance.Zero;
     deathTimer  = Util.Instance.Zero;
     Scores      = Util.Instance.Zero;
     lifes       = Util.Instance.Int_3;
     fireballs   = new List <Fireball>();
     fireballPhysicalProperties = new List <FireballPhysicalProperty>();
     ScoreObjects    = new List <ScoreObject>();
     canTakeDamage   = true;
     resetWorld      = false;
     CanStandOnBlock = true;
     canFallDie      = true;
     Coefficient     = Util.Instance.Int_1;
 }
Example #3
0
 public SwimMario()
 {
     MarioPowerUpState  = new MarioSmallState();
     MarioAnimatedState = new MarioSwimIdleRightState(this);
     MarioPhysics       = new SwimMarioPhysics(OriginalPosition);
     time                   = Constant.Constant.Instance.InitialTime;
     action                 = true;
     Invincible             = false;
     Fetch                  = false;
     MarioPhysics.IsRunning = false;
 }
Example #4
0
 public void TakeDamage()
 {
     if (canTakeDamage && !(CurrentPowerState is MarioSmallState))
     {
         CurrentPowerState     = new MarioSmallState(this);
         CurrentAnimationState = new MarioRightIdleState(this);
         Location     += new Vector2(Util.Instance.Zero, Util.Instance.Int_15);
         isAlive       = true;
         isFlash       = true;
         canTakeDamage = false;
     }
     if (canTakeDamage && CurrentPowerState is MarioSmallState)
     {
         lifes--;
         SoundManager.Instance.PlayPlayerDeadMusic();
         isAlive       = false;
         canTakeDamage = false;
     }
 }
Example #5
0
        public void Update(GameTime gametime)
        {
            if (damageTimer == Util.Instance.DamageTimer)
            {
                canTakeDamage = true;
                isFlash       = false;
                damageTimer   = Util.Instance.Zero;
            }
            if (!canTakeDamage)
            {
                damageTimer++;
            }

            if (CurrentPowerState is MarioStarBigState || CurrentPowerState is MarioStarSmallState)
            {
                if (starTimer == Util.Instance.FiveHundreds)
                {
                    if (CurrentPowerState is MarioStarBigState)
                    {
                        CurrentPowerState = new MarioBigState(this);
                    }
                    else
                    {
                        CurrentPowerState = new MarioSmallState(this);
                    }
                    starTimer = Util.Instance.Zero;
                }
                starTimer++;
            }

            foreach (Fireball fireball in fireballs)
            {
                fireball.Update(gametime);
            }
            foreach (ScoreObject score in ScoreObjects)
            {
                score.Update(gametime);
            }

            Rectangle = new Rectangle((int)Location.X, (int)Location.Y, CurrentAnimationState.Width, CurrentAnimationState.Height);
            if (IsIdle)
            {
                PreviousAnimationState = CurrentAnimationState;
                CurrentAnimationState.Idle();
                MarioPhysics.Idle();
            }
            IsIdle = true;

            if (!isAlive)
            {
                CurrentAnimationState = new MarioDeadState();
            }

            CurrentAnimationState.Update(gametime);
            MarioPhysics.Update(gametime);
            CheckDeath();

            if (CurrentAnimationState is MarioDeadState)
            {
                deathTimer++;
            }
            if (deathTimer == Util.Instance.TwoHundreds)
            {
                deathTimer = Util.Instance.Zero;
                resetWorld = true;
            }
        }
Example #6
0
 public void Reset()
 {
     MarioAnimatedState = new MarioIdleRightState(this);
     MarioPowerUpState  = new MarioSmallState();
     MarioPhysics.Dead  = false;
 }
Example #7
0
 public Mario(Vector2 positionOnScreen) : base(positionOnScreen)
 {
     State        = new RightStandingMarioState(this);
     PowerUpState = new MarioSmallState();
     SetSprite();
 }