diff --git a/src/Blaze-Brigade/Blaze_Brigade/Game.cs b/src/Blaze-Brigade/Blaze_Brigade/Game.cs index 1c81fe9847330eab4d8228904539e1182575657e..c022ec8a21cf9cb394be45668e7652a2a9614989 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Game.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Game.cs @@ -26,6 +26,13 @@ namespace Controller #region Variables + static Game instance; + + public static Game Instance + { + get { return instance; } + } + GameMenuState currentGameState = GameMenuState.MainMenu; // game starts in main menu screen MainMenu mMenu; // main menu variable HowToPlay tut; // instruction screen variable @@ -44,6 +51,8 @@ namespace Controller // constructor for game public Game() { + instance = this; + graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferWidth = GameState.SCREEN_HEIGHT; graphics.PreferredBackBufferHeight = GameState.SCREEN_WIDTH; diff --git a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs index 2ed06be0e0e40b26fd6195158a8138ec9a8fc263..46b56e06748b09c8ffe3c799f8f655ef740dafcc 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs @@ -64,7 +64,11 @@ namespace Controller // if user clicks on a valid end node, move to it if (turnState == TurnState.Move) { - GameState.getSelectedUnit().setMenuOpen(false); // remove drop down menu from screen + // remove drop down menu from screen + GameState.getSelectedUnit().setMenuOpen(false); + Game.Instance.Tick(); + + // set variables for path finding Node startNode = graph.getNode(GameState.getSelectedUnit().getPosition()); Node endNode = graph.getNode(mouseClickCoordinates); LinkedList<Node> path = GameFunction.pathFinder(graph, GameState.getSelectedUnit(), startNode, endNode); @@ -74,6 +78,7 @@ namespace Controller { updateUnitPosition(mouseClickCoordinates, path); } + GameState.getSelectedUnit().setMenuOpen(true); // opens drop down menu on screen again setSelectedUnit(null, false); // unselect the unit turnState = TurnState.Wait; @@ -128,15 +133,13 @@ namespace Controller { Unit unit = GameState.getSelectedUnit(); - // TODO: CALL ANIMATION FUNCTION HERE TO ANIMATE UNIT - // Use path to determine which nodes to move to - //foreach (Node node in path) - //{ - // unit.setPosition(node.getPositionX(), node.getPositionY()); - //} - - // moves the unit to end node - unit.setPosition(path.Last().getPositionX(), path.Last().getPositionY()); + // updates the unit's position to each node in the path (node by node) + foreach (Node node in path) + { + unit.setPosition(node.getPositionX(), node.getPositionY()); + Game.Instance.Tick(); + Thread.Sleep(100); + } } // returns a menu button that was clicked; if no menu button was clicked, returns null