Skip to content
Snippets Groups Projects
Commit a88b9723 authored by Susan Yuen's avatar Susan Yuen
Browse files

ANIMATING WORKS!! Game class is now a singleton

parent db30e3c3
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment