Changeset 4713
- Timestamp:
- 2013-07-26 11:45:18 (9 years ago)
- Location:
- 2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/CastleMaster.csproj
r4703 r4713 100 100 <Compile Include="Guis\GuiManager.cs" /> 101 101 <Compile Include="Guis\GuiStoreMenu.cs" /> 102 <Compile Include="Guis\GuiWinLooseMessage.cs" /> 102 103 <Compile Include="Input\InputHandler.cs" /> 103 104 <Compile Include="MathHelpers\FastFunctions.cs" /> -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Game.cs
r4703 r4713 36 36 private GuiMainScreen mainScreen; 37 37 private bool isGameRunning = false; 38 private static Game instance; 38 39 39 40 #region Counter … … 56 57 players = new Player[2]; 57 58 guiManager = new GuiManager(); 59 IsGamePaused = true; 60 instance = this; 58 61 } 59 62 … … 65 68 66 69 public bool IsGameRunning { get { return isGameRunning; } } 70 71 public bool IsGamePaused { get; set; } 72 73 public static Game Instance { get { return instance; } } 67 74 68 75 protected override void Initialize() … … 89 96 input.RegisterKeyboardKey(Keys.F4); 90 97 input.RegisterKeyboardKey(Keys.F1); 98 input.RegisterKeyboardKey(Keys.F2); 91 99 input.RegisterKeyboardKey(Keys.ShiftKey); 92 100 input.RegisterKeyboardKey(Keys.ControlKey); … … 102 110 } 103 111 112 public void OpenMainMenu() 113 { 114 ResetGame(); 115 guiManager.AddGui(mainScreen, true, true); 116 } 117 104 118 public void ResetGame() 105 119 { 120 IsGamePaused = true; 106 121 isGameRunning = false; 107 122 level = null; 108 123 camera = null; 109 124 players = new Player[2]; 110 ingame.Remove(); 125 if (ingame != null) 126 ingame.Remove(); 111 127 GC.Collect(); 112 128 } … … 117 133 ResetGame(); 118 134 135 IsGamePaused = false; 119 136 isGameRunning = true; 120 137 … … 128 145 foreach (Player p in players) 129 146 if (p != null) p.OnLevelLoaded(); 130 camera.CenterOn( level.Width / 2 * Viewport.TILESIZE, level.Height / 2* Viewport.TILESIZE);147 camera.CenterOn(100 * Viewport.TILESIZE, 15 * Viewport.TILESIZE); 131 148 132 149 ingame = new GuiPlayer(guiManager, players[0]); … … 166 183 167 184 mainScreen = new GuiMainScreen(guiManager, this); 168 guiManager.AddGui(mainScreen, true, true);185 OpenMainMenu(); 169 186 } 170 187 … … 179 196 if (InputHandler.HasKeyBeenPressed(Keys.F4)) 180 197 IsFixedTimeStep = !IsFixedTimeStep; 181 if (InputHandler.HasKeyBeenPressed(Keys.Escape) )198 if (InputHandler.HasKeyBeenPressed(Keys.Escape) && (guiManager.ImportantGui == null || !(guiManager.ImportantGui is GuiWinLooseMessage))) 182 199 { 183 200 if (isGameRunning) … … 187 204 else 188 205 mainScreen.Remove(); 206 207 IsGamePaused = mainScreen.IsActive; 189 208 } 190 209 else Exit(); 191 210 } 192 211 193 if (isGameRunning && ! mainScreen.IsActive)212 if (isGameRunning && !IsGamePaused) 194 213 { 195 214 if (InputHandler.MouseScrollDelta > 1) … … 201 220 if (p != null) 202 221 p.Update(); 203 //players[0].Update();204 222 205 223 camera.Update(); -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Guis/GuiManager.cs
r4703 r4713 30 30 registeredGuis = registeredGuis.OrderBy(g => g.Importance).ToList(); 31 31 } 32 33 public Gui ImportantGui { get { return importantGui; } } 32 34 33 35 public void RemoveGui(Gui gui) -
2013/30/DenisZ/CastleMaster/CastleMaster/CastleMaster/Units/UnitKing.cs
r4703 r4713 6 6 using CastleMaster.Players; 7 7 using CastleMaster.Graphics; 8 using CastleMaster.Guis; 8 9 9 10 namespace CastleMaster.Units … … 45 46 base.Remove(); 46 47 level.RemoveUnit(this); 48 49 GuiWinLooseMessage winLooseMsg = new GuiWinLooseMessage(Game.GuiManager, Game.Instance, Game.GetEnemyTeam(Owner.Team)); 50 Game.GuiManager.AddGui(winLooseMsg, true, true); 51 Game.Instance.IsGamePaused = true; 47 52 } 48 53
Note: See TracChangeset
for help on using the changeset viewer.