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(); } } }
public void CheckDeath() { if (Location.Y > Util.Instance.ThreeFifty && canFallDie) { lifes--; SoundManager.Instance.PlayPlayerDeadMusic(); isAlive = false; canFallDie = false; CurrentAnimationState = new MarioDeadState(); } }
public void CheckDead() { if (MarioPhysics.Position.Y > Constant.Constant.Instance.MarioDeadPosition) { MarioPhysics.Dead = true; MarioAnimatedState = new MarioDeadState(this); SoundFactory.Instance.CreateMarioDeadSound(); TreeNewBee.SuperMarioBros.Instance.ScManager.RemainingLife -= Constant.Constant.Instance.OneRemainingLife; TreeNewBee.SuperMarioBros.Instance.Manager.SetDelay(); if (TreeNewBee.SuperMarioBros.Instance.ScManager.RemainingLife <= Constant.Constant.Instance.NoRemainingLife) { TreeNewBee.SuperMarioBros.Instance.Manager.LostGame(); SoundFactory.Instance.CreateGameOverSound(); } } }
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; } }