/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (GameLogic game = new GameLogic()) { game.Run(); } }
public void ProcessInput(GameLogic gamelogic, GameState gameState, KeyboardState oKS, KeyboardState nKS, MouseState oMS, MouseState nMS, Hero hero, Map dMap) { if (gameState == GameState.Running) { if (nKS.IsKeyDown(Keys.Escape) && !oKS.IsKeyDown(Keys.Escape)) { gamelogic.OpenMainMenu("blank"); } //adjust log if (nKS.IsKeyDown(Keys.OemMinus) && oKS.IsKeyUp(Keys.OemMinus)) LogScrollUp(); else if (nKS.IsKeyDown(Keys.OemPlus) && oKS.IsKeyUp(Keys.OemPlus)) LogScrollDown(); //select actions if (nKS.IsKeyDown(Keys.D1) && oKS.IsKeyUp(Keys.D1)) selAct = 0; else if (nKS.IsKeyDown(Keys.D2) && oKS.IsKeyUp(Keys.D2)) selAct = 1; else if (nKS.IsKeyDown(Keys.D3) && oKS.IsKeyUp(Keys.D3)) selAct = 2; else if (nKS.IsKeyDown(Keys.D4) && oKS.IsKeyUp(Keys.D4)) selAct = 3; else if (nKS.IsKeyDown(Keys.D5) && oKS.IsKeyUp(Keys.D5)) selAct = 4; else if (nKS.IsKeyDown(Keys.D6) && oKS.IsKeyUp(Keys.D6)) selAct = 5; else if (nKS.IsKeyDown(Keys.D7) && oKS.IsKeyUp(Keys.D7)) selAct = 6; else if (nKS.IsKeyDown(Keys.D8) && oKS.IsKeyUp(Keys.D8)) selAct = 7; else if (nKS.IsKeyDown(Keys.D9) && oKS.IsKeyUp(Keys.D9)) selAct = 8; else if (nKS.IsKeyDown(Keys.D0) && oKS.IsKeyUp(Keys.D0)) selAct = 9; //Mouse Input Point mPoint = new Point(nMS.X, nMS.Y); Point mapMLoc = dMap.XYtoMap(nMS.X, nMS.Y); if (gD.Viewport.Bounds.Contains(mPoint)) { if (oMS.LeftButton != ButtonState.Pressed && nMS.LeftButton == ButtonState.Pressed) { if (CatchClick(mPoint, nMS)) { } else { //clicks on map //Console.WriteLine(string.Format("Click at {0}, {1}",tarpoint.X, tarpoint.Y)); if (dMap.IsInMap(mapMLoc) && dMap.vision[mapMLoc.X, mapMLoc.Y] > 0 && dMap.blocks[mapMLoc.X, mapMLoc.Y] && !(hero.mapX == mapMLoc.X && hero.mapY == mapMLoc.Y)) { hero.mQueue = dMap.PathTo(new Point(hero.mapX, hero.mapY), mapMLoc); } } } if (oMS.RightButton != ButtonState.Pressed && nMS.RightButton == ButtonState.Pressed) { if (CatchClick(mPoint, nMS)) { } else { //clicks on map //Console.WriteLine(string.Format("Click at {0}, {1}",tarpoint.X, tarpoint.Y)); if (dMap.IsInMap(mapMLoc) && dMap.blocks[mapMLoc.X, mapMLoc.Y] && !(hero.mapX == mapMLoc.X && hero.mapY == mapMLoc.Y)) { dMap.monsters.Add(new Monster(string.Format("M{0}", dMap.monsters.Count), 0, mapMLoc.X, mapMLoc.Y)); dMap.monsters[dMap.monsters.Count - 1].Move(mapMLoc.X, mapMLoc.Y, dMap); } else { foreach (Monster fiend in dMap.monsters) { if (fiend.mapX == mapMLoc.X && fiend.mapY == mapMLoc.Y) { dMap.alts[fiend.mapX, fiend.mapY] = 17 + rando.Next(3); fiend.Kill(dMap); } } } } } } } else if (gameState == GameState.MainMenu) { mainMenu.ClearHighlight(); mainMenu.MenuHover(nMS.X, nMS.Y); if (nMS.LeftButton == ButtonState.Pressed && oMS.LeftButton == ButtonState.Released) { mainMenu.MenuClick(nMS.X, nMS.Y); } } else if (gameState == GameState.Graveyard) { if (nKS.IsKeyDown(Keys.Escape) && !oKS.IsKeyDown(Keys.Escape)) { gamelogic.OpenMainMenu("blank"); } } }
public void ProcessInput(GameLogic gamelogic, GameState gameState, KeyboardState oKS, KeyboardState nKS, MouseState oMS, MouseState nMS, Hero hero, Map dMap) { if (gameState == GameState.Running) { if (nKS.IsKeyDown(Keys.Escape) && !oKS.IsKeyDown(Keys.Escape)) { gamelogic.OpenMainMenu("blank"); } //adjust log if (nKS.IsKeyDown(Keys.OemMinus) && oKS.IsKeyUp(Keys.OemMinus)) { LogScrollUp(); } else if (nKS.IsKeyDown(Keys.OemPlus) && oKS.IsKeyUp(Keys.OemPlus)) { LogScrollDown(); } //select actions if (nKS.IsKeyDown(Keys.D1) && oKS.IsKeyUp(Keys.D1)) { selAct = 0; } else if (nKS.IsKeyDown(Keys.D2) && oKS.IsKeyUp(Keys.D2)) { selAct = 1; } else if (nKS.IsKeyDown(Keys.D3) && oKS.IsKeyUp(Keys.D3)) { selAct = 2; } else if (nKS.IsKeyDown(Keys.D4) && oKS.IsKeyUp(Keys.D4)) { selAct = 3; } else if (nKS.IsKeyDown(Keys.D5) && oKS.IsKeyUp(Keys.D5)) { selAct = 4; } else if (nKS.IsKeyDown(Keys.D6) && oKS.IsKeyUp(Keys.D6)) { selAct = 5; } else if (nKS.IsKeyDown(Keys.D7) && oKS.IsKeyUp(Keys.D7)) { selAct = 6; } else if (nKS.IsKeyDown(Keys.D8) && oKS.IsKeyUp(Keys.D8)) { selAct = 7; } else if (nKS.IsKeyDown(Keys.D9) && oKS.IsKeyUp(Keys.D9)) { selAct = 8; } else if (nKS.IsKeyDown(Keys.D0) && oKS.IsKeyUp(Keys.D0)) { selAct = 9; } //Mouse Input Point mPoint = new Point(nMS.X, nMS.Y); Point mapMLoc = dMap.XYtoMap(nMS.X, nMS.Y); if (gD.Viewport.Bounds.Contains(mPoint)) { if (oMS.LeftButton != ButtonState.Pressed && nMS.LeftButton == ButtonState.Pressed) { if (CatchClick(mPoint, nMS)) { } else { //clicks on map //Console.WriteLine(string.Format("Click at {0}, {1}",tarpoint.X, tarpoint.Y)); if (dMap.IsInMap(mapMLoc) && dMap.vision[mapMLoc.X, mapMLoc.Y] > 0 && dMap.blocks[mapMLoc.X, mapMLoc.Y] && !(hero.mapX == mapMLoc.X && hero.mapY == mapMLoc.Y)) { hero.mQueue = dMap.PathTo(new Point(hero.mapX, hero.mapY), mapMLoc); } } } if (oMS.RightButton != ButtonState.Pressed && nMS.RightButton == ButtonState.Pressed) { if (CatchClick(mPoint, nMS)) { } else { //clicks on map //Console.WriteLine(string.Format("Click at {0}, {1}",tarpoint.X, tarpoint.Y)); if (dMap.IsInMap(mapMLoc) && dMap.blocks[mapMLoc.X, mapMLoc.Y] && !(hero.mapX == mapMLoc.X && hero.mapY == mapMLoc.Y)) { dMap.monsters.Add(new Monster(string.Format("M{0}", dMap.monsters.Count), 0, mapMLoc.X, mapMLoc.Y)); dMap.monsters[dMap.monsters.Count - 1].Move(mapMLoc.X, mapMLoc.Y, dMap); } else { foreach (Monster fiend in dMap.monsters) { if (fiend.mapX == mapMLoc.X && fiend.mapY == mapMLoc.Y) { dMap.alts[fiend.mapX, fiend.mapY] = 17 + rando.Next(3); fiend.Kill(dMap); } } } } } } } else if (gameState == GameState.MainMenu) { mainMenu.ClearHighlight(); mainMenu.MenuHover(nMS.X, nMS.Y); if (nMS.LeftButton == ButtonState.Pressed && oMS.LeftButton == ButtonState.Released) { mainMenu.MenuClick(nMS.X, nMS.Y); } } else if (gameState == GameState.Graveyard) { if (nKS.IsKeyDown(Keys.Escape) && !oKS.IsKeyDown(Keys.Escape)) { gamelogic.OpenMainMenu("blank"); } } }