public override void Update() { //Update everything here. if (GAME_ENGINE.GetMouseButtonDown(1)) { Console.WriteLine(GAME_ENGINE.GetMousePosition().X); Console.WriteLine(GAME_ENGINE.GetMousePosition().Y); Console.WriteLine(level); } if (start == true) { levels[level].OnEnter(); start = false; } if (GAME_ENGINE.GetKeyDown(Key.Escape)) { levels[level].OnExit(); level = (int)Levels.Main; levels[level].OnEnter(); } if (GAME_ENGINE.GetKeyDown(Key.D1)) { levels[level].OnExit(); level = (int)Levels.Curling; levels[level].OnEnter(); } if (GAME_ENGINE.GetKeyDown(Key.D2)) { levels[level].OnExit(); level = (int)Levels.Pool; levels[level].OnEnter(); } if (GAME_ENGINE.GetKeyDown(Key.D3)) { levels[level].OnExit(); level = (int)Levels.Golf; levels[level].OnEnter(); } levels[level].Update(); }
public override void Update() { missileLauncher.ForwardCollision(); if (GAME_ENGINE.GetKey(Key.Escape)) { if (Registers.gameState == GameState.Error) { GAME_ENGINE.Quit(); } if (Registers.gameState == GameState.Running) { Registers.gameState = GameState.Paused; } if (Registers.gameState == GameState.Stopped) { GAME_ENGINE.Quit(); } } if (GAME_ENGINE.GetKey(Key.ShiftKey)) { Registers.sprint = true; } else { Registers.sprint = false; } if (GAME_ENGINE.GetMouseButtonDown(0) && Registers.gameState == GameState.Paused) { } if (Registers.gameState == GameState.Running) { if (GAME_ENGINE.GetKeyDown(Key.Space)) { Registers.fireNow = true; } //make the crosshair move faster when shift is held if (Registers.sprint == false) { float speedMultiplier = 1.1f; if (GAME_ENGINE.GetKey(Key.W)) { Registers.CrosshairY -= aimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier; } if (GAME_ENGINE.GetKey(Key.S) && Registers.CrosshairY < Alignment.Y.Down - 70) { Registers.CrosshairY += aimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier; } if (GAME_ENGINE.GetKey(Key.D)) { Registers.CrosshairX += aimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier; } if (GAME_ENGINE.GetKey(Key.A)) { Registers.CrosshairX -= aimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier; } } else { float speedMultiplier = 1.3f; if (GAME_ENGINE.GetKey(Key.W)) { Registers.CrosshairY -= shiftAimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier; } if (GAME_ENGINE.GetKey(Key.S) && Registers.CrosshairY < Alignment.Y.Down - 70) { Registers.CrosshairY += shiftAimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier; } if (GAME_ENGINE.GetKey(Key.D)) { Registers.CrosshairX += shiftAimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier; } if (GAME_ENGINE.GetKey(Key.A)) { Registers.CrosshairX -= shiftAimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier; } } } //Trigger the error screen by force if (GAME_ENGINE.GetKeyDown(Key.F12)) { Registers.gameState = GameState.Error; } if (GAME_ENGINE.GetKeyUp(Key.F12)) { Registers.gameState = GameState.Running; } //RESETING THE GAME CAN CAUSE PROBLEMS if (GAME_ENGINE.GetKeyDown(Key.R) && Registers.gameState == GameState.Stopped) { Registers.gameState = GameState.Reseting; Registers.CrosshairX = Alignment.X.Center; Registers.CrosshairY = Alignment.Y.Center; cities.Clear(); for (int i = 0; i < 6; i++) { cities.Add(new Building(this, i)); } GC.Collect(); destroyedCities = 0; Registers.gameState = GameState.Running; } //Force lose the game if (GAME_ENGINE.GetKeyDown(Key.F2)) { destroyedCities = 6; } //Enable all cities if (GAME_ENGINE.GetKeyDown(Key.F3)) { destroyedCities = 0; Registers.gameState = GameState.Running; } }