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

Fixed bug in movement

parent cfee1a10
No related branches found
No related tags found
No related merge requests found
...@@ -11,11 +11,14 @@ namespace Controller ...@@ -11,11 +11,14 @@ namespace Controller
// This class holds useable functions in the scope of the entire gameplay // This class holds useable functions in the scope of the entire gameplay
static class GameFunction static class GameFunction
{ {
// might not need; check if enemyUnitsInRange returns an empty list // returns whether an enemy unit is in range of the unit
public static bool isAnEnemyUnitInRange(Unit unit) public static bool isAnEnemyUnitInRange(Graph graph, Unit unit)
{ {
// TODO if (enemyUnitsInRange(graph, unit).Count == 0)
return false; {
return false;
}
return true;
} }
// returns whether or not the enemy unit is within attack range of unit // returns whether or not the enemy unit is within attack range of unit
...@@ -34,7 +37,11 @@ namespace Controller ...@@ -34,7 +37,11 @@ namespace Controller
Button[] buttons = unit.getButtons(); Button[] buttons = unit.getButtons();
for (int i = 0; i < buttons.Count(); i++) for (int i = 0; i < buttons.Count(); i++)
{ {
buttons[i].setActive(true); if (buttons[i].getButtonType() != ButtonType.Attack
|| buttons[i].getButtonType() != ButtonType.AttackConfirm)
{
buttons[i].setActive(true);
}
} }
} }
...@@ -47,12 +54,23 @@ namespace Controller ...@@ -47,12 +54,23 @@ namespace Controller
GameState.beforeMove = true; GameState.beforeMove = true;
} }
// returns all enemy units in range of the specified unit // returns all enemy units in strict attack range of the specified unit
public static LinkedList<Unit> enemyUnitsInRange(Unit unit) public static LinkedList<Unit> enemyUnitsInRange(Graph graph, Unit unit)
{ {
// TODO //TODO: int range = unit.getEquippedWeapon().getRange(); // use this to determine all hitable squares
//int range = unit.getEquippedWeapon().getRange(); // use this to determine all hitable squares
return null; LinkedList<Unit> enemyUnitsInRange = new LinkedList<Unit>();
LinkedList<Unit> allEnemyUnits = GameState.enemyPlayer.getUnits();
foreach (Unit enemyUnit in allEnemyUnits)
{
if (isEnemyUnitInRange(graph, unit, enemyUnit))
{
enemyUnitsInRange.AddLast(enemyUnit);
}
}
return enemyUnitsInRange;
} }
// checks if specified unit can perform actions // checks if specified unit can perform actions
......
...@@ -83,6 +83,7 @@ namespace Controller ...@@ -83,6 +83,7 @@ namespace Controller
GameState.selectedUnit.getButtonOfType(ButtonType.Move).setActive(false); // move button no longer active GameState.selectedUnit.getButtonOfType(ButtonType.Move).setActive(false); // move button no longer active
updateUnitPosition(graph, mouseClickCoordinates, path); updateUnitPosition(graph, mouseClickCoordinates, path);
GameState.beforeMove = false; GameState.beforeMove = false;
turnState = TurnState.Wait;
} }
else else
{ {
......
...@@ -26,7 +26,6 @@ namespace Model ...@@ -26,7 +26,6 @@ namespace Model
void setEquippedWeapon(Weapon w); // sets the unit's currently equipped weapon void setEquippedWeapon(Weapon w); // sets the unit's currently equipped weapon
//void setEquipableWeapons(Weapon add); // need to update the weapon array, put new weapon into it //void setEquipableWeapons(Weapon add); // need to update the weapon array, put new weapon into it
bool isButtonActive(ButtonType buttonType); // indicates whether a button has already been previously selected or not bool isButtonActive(ButtonType buttonType); // indicates whether a button has already been previously selected or not
void setButtonActive(ButtonType buttonType, bool active);
void setButtonCoordinates(Vector2 pixelCoordinates); // sets the coordinates of menu buttons void setButtonCoordinates(Vector2 pixelCoordinates); // sets the coordinates of menu buttons
void animate(int direction); // animate sprite walking the direction specified void animate(int direction); // animate sprite walking the direction specified
void setInitialStats(); // sets initial unit stats upon creation void setInitialStats(); // sets initial unit stats upon creation
......
...@@ -146,31 +146,6 @@ namespace Model ...@@ -146,31 +146,6 @@ namespace Model
} }
} }
public void setButtonActive(ButtonType buttonType, bool active)
{
switch (buttonType)
{
case ButtonType.Attack:
buttons[0].setActive(active);
return;
case ButtonType.Move:
buttons[1].setActive(active);
return;
case ButtonType.Items:
buttons[2].setActive(active);
return;
case ButtonType.Wait:
buttons[3].setActive(active);
return;
case ButtonType.AttackConfirm:
buttons[4].setActive(active);
return;
default:
return;
}
}
public Texture2D getCharInfo() public Texture2D getCharInfo()
{ {
return charInfo; return charInfo;
......
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