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

Changed screen size. Edited code format a little bit.

parent c8604e06
No related branches found
No related tags found
No related merge requests found
......@@ -9,13 +9,13 @@ namespace Controller
{
class GameFunction
{
public readonly int SCREEN_HEIGHT = 500;
public readonly int SCREEN_WIDTH = 500;
public readonly int SCREEN_HEIGHT = 960;
public readonly int SCREEN_WIDTH = 640;
private bool playableUnitSelected;
private Unit selectedUnit;
private Player currentPlayer;
private bool isAnimating = false; // indicates whether an animation sequence is on screen
// might not need; check if enemyUnitsInRange returns an empty list
public bool isAnEnemyUnitInRange(Unit unit)
......@@ -88,6 +88,16 @@ namespace Controller
selectedUnit = unit;
}
public bool getIsAnimating()
{
return isAnimating;
}
public void setIsAnimating(bool animating)
{
isAnimating = animating;
}
// checks if the node is attackable based on the unit's class and position
// I THINK THIS WOULD WORK MUCH SIMPLER BASED ON EQUIPPED WEAPON NOT UNIT TYPE!!
// IF logic < equippedweapon.range or IF logic < weapon with highest range.
......
......@@ -13,8 +13,6 @@ namespace Controller
{
class MouseHandler
{
private bool isAnimating = false; // indicates whether an animation sequence is on screen
MouseState lastMouseState;
MouseState currentMouseState;
int turnState = 0; //0= no button selected, 1 = attack selected, 2 = move selected
......@@ -27,14 +25,13 @@ namespace Controller
bool validX = currentMouseState.X < gameFunction.SCREEN_WIDTH && currentMouseState.X > 0;
bool validY = currentMouseState.Y < gameFunction.SCREEN_HEIGHT && currentMouseState.Y > 0;
// checks for single mouse click inside the window
if (lastMouseState.LeftButton == ButtonState.Released
&& currentMouseState.LeftButton == ButtonState.Pressed
&& validX && validY)
{
// do not react to user input if animation is on screen
if (isAnimating)
if (gameFunction.getIsAnimating())
{
return;
}
......@@ -46,8 +43,6 @@ namespace Controller
// if player clicks after unit is already selected ...
if (gameFunction.isPlayableUnitSelected())
{
// TODO: PATH FINDING
Node startNode = graph.getNode(gameFunction.getSelectedUnit().getPosition());
Node endNode = graph.getNode(position);
......@@ -55,9 +50,9 @@ namespace Controller
{
updateUnitPosition(position, gameFunction);
}
gameFunction.setPlayableUnitSelected(false);
gameFunction.setSelectedUnit(null);
setSelectedUnit(gameFunction, null, false);
}
// if player clicks when no unit is selected ...
else
{
......@@ -65,15 +60,21 @@ namespace Controller
Unit unit = getPlayableUnitOnNodeClicked(graph.getNode(position), position, gameFunction.playerCurrentlyMoving());
if (unit != null)
{
unit.setClickedOn(true);
unit.setMenuOpen(true);
gameFunction.setPlayableUnitSelected(true);
gameFunction.setSelectedUnit(unit);
setSelectedUnit(gameFunction, unit, true);
}
}
}
}
// sets selection of unit state inside GameFunction and the unit itself
private void setSelectedUnit(GameFunction gameFunction, Unit unit, bool selected)
{
unit.setMenuOpen(selected);
unit.setClickedOn(selected);
gameFunction.setPlayableUnitSelected(selected);
gameFunction.setSelectedUnit(unit);
}
// if playable unit exists where user clicked, return it; else, return null
private Unit getPlayableUnitOnNodeClicked(Node clickedNode, Vector2 positionClicked, Player currentPlayer)
{
......@@ -106,23 +107,22 @@ namespace Controller
{
if (gameFunction.getSelectedUnit().getPosition().Item1 < positionX) {
for (currentX = gameFunction.getSelectedUnit().getPosition().Item1; currentX <= positionX; currentX++)
{
Thread.Sleep(500);
gameFunction.getSelectedUnit().setPosition(currentX, currentY);
Debug.Write("X is: " + currentX);
for (currentX = gameFunction.getSelectedUnit().getPosition().Item1; currentX <= positionX; currentX++)
{
Thread.Sleep(500);
gameFunction.getSelectedUnit().setPosition(currentX, currentY);
Debug.Write("X is: " + currentX);
}
}
}else{
for (currentX = gameFunction.getSelectedUnit().getPosition().Item1; currentX >= positionX; currentX--)
else
{
Thread.Sleep(500);
gameFunction.getSelectedUnit().setPosition(currentX, currentY);
Debug.Write("X is: " + currentX);
for (currentX = gameFunction.getSelectedUnit().getPosition().Item1; currentX >= positionX; currentX--)
{
Thread.Sleep(500);
gameFunction.getSelectedUnit().setPosition(currentX, currentY);
Debug.Write("X is: " + currentX);
}
}
}
if (gameFunction.getSelectedUnit().getPosition().Item2 < positionY)
{
for (currentY = gameFunction.getSelectedUnit().getPosition().Item2; currentY <= positionY; currentY++)
......@@ -147,32 +147,22 @@ namespace Controller
}
}
public void Draw(GameTime gametime)
{
}
public void setAnimating(bool animating)
{
isAnimating = animating;
}
//which dropdownmenu is selected
void buttonAction(int i)
private void buttonAction(int i)
{
//take action corresponding to which button was clicked
// take action corresponding to which button was clicked
switch (i)
{
case 0: //if attack clicked
case 0: // if attack clicked
turnState = 1;
break;
case 1: //if moved is clicked
case 1: // if moved is clicked
turnState = 2;
break;
case 2: //if item is clicked
case 2: // if item is clicked
turnState = 3;
break;
case 3: //if wait is clicked
case 3: // if wait is clicked
break;
default:
......
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