public void Update() { if (Game1.State.Type == GameStates.GameOver) { MarioInfo.MarioLife[0] = 3; MarioInfo.UpdateHighestScore(); CoinSystem.Instance.ResetCoin(); ScoringSystem.ResetScore(); MarioInfo.ClearTimer(); } }
public void Update() { Keys[] pressedKeys = Keyboard.GetState().GetPressedKeys(); if (Game1.State.Type == GameStates.Playing) { if ((pressedKeys.Contains(Keys.Q) && preKeys != null && !preKeys.Contains(Keys.Q))) { commandDict[Keys.Q].Execute(); } if ((pressedKeys.Contains(Keys.M) && !preKeys.Contains(Keys.M))) { SoundManager.Instance.muteAndUnmute(Muted); Muted = !Muted; } else if ((pressedKeys.Contains(Keys.Y) && preKeys != null)) { commandDict[Keys.Y].Execute(); } else if ((pressedKeys.Contains(Keys.U) && preKeys != null)) { commandDict[Keys.U].Execute(); } else if ((pressedKeys.Contains(Keys.I) && preKeys != null)) { commandDict[Keys.I].Execute(); } else if ((pressedKeys.Contains(Keys.O) && preKeys != null)) { commandDict[Keys.O].Execute(); } else if ((pressedKeys.Contains(Keys.F) && preKeys != null)) { commandDict[Keys.F].Execute(); } if (Left(pressedKeys)) { commandDict[Keys.Left].Execute(); } else if (Right(pressedKeys)) { commandDict[Keys.Right].Execute(); } else if (Jump(pressedKeys)) { commandDict[Keys.Up].Execute(); } else if (Down(pressedKeys)) { commandDict[Keys.Down].Execute(); } else if (LeftJump(pressedKeys)) { if (mario.IsInAir || mario.IsInWater) { if (mario.IsInWater) { if (mario.Swimable) { switch (mario.State.MarioShape) { case Shape.Small: mario.State = new SwimmingLeftSmallMarioState(mario); break; case Shape.Big: mario.State = new SwimmingLeftBigMarioState(mario); break; case Shape.Fire: mario.State = new SwimmingLeftFireMarioState(mario); break; } mario.State.MarioPosture = Posture.Swimming; mario.State.MarioDirection = Direction.Left; mario.Velocity = new Vector2(mario.Velocity.X, GameData.marioInWaterJump); mario.Acceleration = new Vector2(0, GameData.Gravity + GameData.Float); mario.Swimable = false; } } commandDict[Keys.Left].Execute(); } else { commandDict[Keys.Up].Execute(); } } else if (LeftDown(pressedKeys)) { commandDict[Keys.Down].Execute(); } else if (RightJump(pressedKeys)) { if (mario.IsInAir || mario.IsInWater) { if (mario.IsInWater) { if (mario.Swimable) { switch (mario.State.MarioShape) { case Shape.Small: mario.State = new SwimmingRightSmallMarioState(mario); break; case Shape.Big: mario.State = new SwimmingRightBigMarioState(mario); break; case Shape.Fire: mario.State = new SwimmingRightFireMarioState(mario); break; } mario.State.MarioPosture = Posture.Swimming; mario.State.MarioDirection = Direction.Right; mario.Velocity = new Vector2(mario.Velocity.X, GameData.marioInWaterJump); mario.Acceleration = new Vector2(0, GameData.Gravity + GameData.Float); mario.Swimable = false; } } commandDict[Keys.Right].Execute(); } else { commandDict[Keys.Up].Execute(); } } else if (RightDown(pressedKeys)) { commandDict[Keys.Down].Execute(); } else if (LeftRightJump(pressedKeys)) { commandDict[Keys.Up].Execute(); } if (preKeys != null) { foreach (Keys key in preKeys) { if (preKeys.Contains(key) && Keyboard.GetState().IsKeyUp(key)) { if (releasedCommandDict.ContainsKey(key)) { releasedCommandDict[key].Execute(); } } } } if (pressedKeys.Contains(Keys.P)) { Game1.State.Pause(); SoundManager.Instance.muteAndUnmute(Muted); Muted = !Muted; } preKeys = pressedKeys; } else if (Game1.State.Type == GameStates.Title) { if ((pressedKeys.Contains(Keys.Enter) && preKeys != null && !preKeys.Contains(Keys.Enter))) { mygame.Reset(); if (titlePanel.option == 0) { Game1.State = new PlayingState(mygame); SoundManager.Instance.PlayOverWorldSong(); } else if (titlePanel.option == 1) { mygame.LoadNextLevel("./LevelLoader/Level2.xml"); Game1.State = new Transition(mygame); } // MarioInfo.StartTimer(); MarioInfo.StartTimer(); } else if ((pressedKeys.Contains(Keys.Q) && preKeys != null && !preKeys.Contains(Keys.Q))) { commandDict[Keys.Q].Execute(); } else if ((pressedKeys.Contains(Keys.Up) && !preKeys.Contains(Keys.Up))) { titlePanel.Up(); } else if ((pressedKeys.Contains(Keys.Down) && !preKeys.Contains(Keys.Down))) { titlePanel.Down(); } } else if (Game1.State.Type == GameStates.LifeDisplay) { if ((pressedKeys.Contains(Keys.Y) && preKeys != null && !preKeys.Contains(Keys.Y))) { if (mario.IsLevel2) { mygame.LoadNextLevel("./LevelLoader/Level2.xml"); } else { mygame.LevelReset(mygame.File); } Game1.State.Proceed(); //SoundManager.Instance.PlayOverWorldSong(); } else if ((pressedKeys.Contains(Keys.N) && preKeys != null && !preKeys.Contains(Keys.N))) { commandDict[Keys.Q].Execute(); } } else if (Game1.State.Type == GameStates.Pause) { if (pressedKeys.Contains(Keys.P)) { Game1.State.Proceed(); SoundManager.Instance.muteAndUnmute(Muted); Muted = !Muted; } } else if (Game1.State.Type == GameStates.GameOver) { if ((pressedKeys.Contains(Keys.Y) && preKeys != null && !preKeys.Contains(Keys.Y))) { Game1.State.Proceed(); MarioInfo.ClearTimer(); } else if ((pressedKeys.Contains(Keys.N) && preKeys != null && !preKeys.Contains(Keys.N))) { commandDict[Keys.Q].Execute(); } } else if (Game1.State.Type == GameStates.Victory) { if ((pressedKeys.Contains(Keys.Y) && preKeys != null && !preKeys.Contains(Keys.Y))) { MarioInfo.ClearTimer(); MarioInfo.MarioLife[0] = 3; mygame.Reset(); //SoundManager.Instance.PlayOverWorldSong(); Game1.State.Proceed(); } else if ((pressedKeys.Contains(Keys.N) && preKeys != null && !preKeys.Contains(Keys.N))) { commandDict[Keys.Q].Execute(); } } else if (Game1.State.Type == GameStates.Transition) { mygame.LoadNextLevel("./LevelLoader/Level2.xml"); Game1.State.Proceed(); } preKeys = pressedKeys; }
public void Update() { Keys[] pressedKeys = Keyboard.GetState().GetPressedKeys(); if ((Game1.State.Type == GameStates.Playing)) { if ((pressedKeys.Contains(Keys.Q) && preKeys != null && !preKeys.Contains(Keys.Q))) { commandDict[Keys.Q].Execute(); } if ((pressedKeys.Contains(Keys.M) && !preKeys.Contains(Keys.M))) { SoundManager.Instance.muteAndUnmute(Muted); Muted = !Muted; } else if ((pressedKeys.Contains(Keys.Y) && preKeys != null)) { commandDict[Keys.Y].Execute(); } else if ((pressedKeys.Contains(Keys.U) && preKeys != null)) { commandDict[Keys.U].Execute(); } else if ((pressedKeys.Contains(Keys.I) && preKeys != null)) { commandDict[Keys.I].Execute(); } else if ((pressedKeys.Contains(Keys.O) && preKeys != null)) { commandDict[Keys.O].Execute(); } if (Left(pressedKeys)) { commandDict[Keys.Left].Execute(); } else if (Right(pressedKeys)) { commandDict[Keys.Right].Execute(); } else if (Jump(pressedKeys)) { commandDict[Keys.Up].Execute(); } else if (Down(pressedKeys)) { commandDict[Keys.Down].Execute(); } else if (LeftJump(pressedKeys)) { if (mario.IsInAir) { commandDict[Keys.Left].Execute(); } else { commandDict[Keys.Up].Execute(); } } else if (LeftDown(pressedKeys)) { commandDict[Keys.Down].Execute(); } else if (RightJump(pressedKeys)) { if (mario.IsInAir) { commandDict[Keys.Right].Execute(); } else { commandDict[Keys.Up].Execute(); } } else if (RightDown(pressedKeys)) { commandDict[Keys.Down].Execute(); } else if (LeftRightJump(pressedKeys)) { commandDict[Keys.Up].Execute(); } if (preKeys != null) { foreach (Keys key in preKeys) { if (preKeys.Contains(key) && Keyboard.GetState().IsKeyUp(key)) { if (releasedCommandDict.ContainsKey(key)) { releasedCommandDict[key].Execute(); } } } } if ((pressedKeys.Contains(Keys.P) && preKeys != null && preKeys.Contains(Keys.P))) { Game1.State.Pause(); SoundManager.Instance.muteAndUnmute(Muted); Muted = !Muted; } preKeys = pressedKeys; } else if (Game1.State.Type == GameStates.Title) { if ((pressedKeys.Contains(Keys.Enter) && preKeys != null && !preKeys.Contains(Keys.Enter))) { mygame.Reset(); Game1.State = new PlayingState(mygame); SoundManager.Instance.PlayOverWorldSong(); MarioInfo.StartTimer(); } else if ((pressedKeys.Contains(Keys.Q) && preKeys != null && !preKeys.Contains(Keys.Q))) { commandDict[Keys.Q].Execute(); } } else if (Game1.State.Type == GameStates.LifeDisplay) { if ((pressedKeys.Contains(Keys.Y) && preKeys != null && !preKeys.Contains(Keys.Y))) { mygame.LevelReset(); Game1.State.Proceed(); SoundManager.Instance.PlayOverWorldSong(); } else if ((pressedKeys.Contains(Keys.N) && preKeys != null && !preKeys.Contains(Keys.N))) { commandDict[Keys.Q].Execute(); } } else if (Game1.State.Type == GameStates.Pause) { if ((pressedKeys.Contains(Keys.P) && preKeys != null)) { Game1.State.Proceed(); SoundManager.Instance.muteAndUnmute(Muted); Muted = !Muted; } } else if (Game1.State.Type == GameStates.GameOver) { if ((pressedKeys.Contains(Keys.Y) && preKeys != null && !preKeys.Contains(Keys.Y))) { Game1.State.Proceed(); MarioInfo.ClearTimer(); } else if ((pressedKeys.Contains(Keys.N) && preKeys != null && !preKeys.Contains(Keys.N))) { commandDict[Keys.Q].Execute(); } } else if (Game1.State.Type == GameStates.Victory) { if ((pressedKeys.Contains(Keys.Y) && preKeys != null && !preKeys.Contains(Keys.Y))) { mygame.Reset(); MarioInfo.ClearTimer(); MarioInfo.MarioLife[0] = 3; Game1.State.Proceed(); } else if ((pressedKeys.Contains(Keys.N) && preKeys != null && !preKeys.Contains(Keys.N))) { commandDict[Keys.Q].Execute(); } } }