Skip to content
Snippets Groups Projects
Commit 547f253d authored by Trandinh Thien's avatar Trandinh Thien
Browse files

Added another mainMenu state - attackConfirm. Added dif directions for...

Added another mainMenu state - attackConfirm. Added dif directions for attacking. NOw detects what unit is being attacked. WORK IN PROGRESS
parent 3be5e0c8
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ namespace Model
enum TurnState //what the current turn state is (per unit)
{
Wait,
AttackMenu,
Attack,
Move,
Items
......
......@@ -60,6 +60,7 @@ namespace View
enum MenuButtonType
{
Attack,
AttackConfirm,
Move,
Items,
Wait
......
......@@ -92,6 +92,8 @@ namespace Controller
attackAnimation(graph, 0);
//GameState.dropDownMenuOpen = (true);
}
}
}
......@@ -169,10 +171,10 @@ namespace Controller
GameState.isAnimating = true;
float originalLocationX = unit.PixelCoordinates.X;
float originalLocationY = unit.PixelCoordinates.Y;
if (direction == 0)
#region Attack Right
if (direction == 0) //attack right
{
for(float i = originalLocationX; i <= originalLocationX+8; i++)
for (float i = originalLocationX; i <= originalLocationX + 8; i++)
{
unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X + 1, unit.PixelCoordinates.Y);
Game.Instance.Tick();
......@@ -186,6 +188,61 @@ namespace Controller
Thread.Sleep(10);
}
}
#endregion
#region Attack Left
else if (direction == 1) //attack left
{
for (float i = originalLocationX; i >= originalLocationX - 8; i--)
{
unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X + 1, unit.PixelCoordinates.Y);
Game.Instance.Tick();
Thread.Sleep(10);
}
for (float i = unit.PixelCoordinates.X; i <= originalLocationX; i++)
{
unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X - 1, unit.PixelCoordinates.Y);
Game.Instance.Tick();
Thread.Sleep(10);
}
}
#endregion
#region Attack Up
else if (direction == 2) //attack up
{
for (float i = originalLocationY; i >= originalLocationY - 8; i--)
{
unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X , unit.PixelCoordinates.Y +1);
Game.Instance.Tick();
Thread.Sleep(10);
}
for (float i = unit.PixelCoordinates.X; i <= originalLocationX; i++)
{
unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X , unit.PixelCoordinates.Y - 1);
Game.Instance.Tick();
Thread.Sleep(10);
}
}
#endregion
#region Attack Down
else if (direction == 3) //attack down
{
for (float i = originalLocationY; i >= originalLocationY - 8; i--)
{
unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X, unit.PixelCoordinates.Y + 1);
Game.Instance.Tick();
Thread.Sleep(10);
}
for (float i = unit.PixelCoordinates.X; i <= originalLocationX; i++)
{
unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X, unit.PixelCoordinates.Y - 1);
Game.Instance.Tick();
Thread.Sleep(10);
}
}
#endregion
GameState.isAnimating = false;
}
......@@ -263,11 +320,18 @@ namespace Controller
// take action corresponding to which button was clicked
switch (button.getButtonType())
{
case MenuButtonType.Attack: // if attack clicked
turnState = TurnState.Attack;
case MenuButtonType.Attack: // if attackMenu clicked
turnState = TurnState.AttackMenu;
GameState.dropDownMenuOpen = (false); // close the dropdownmenu when selecting who to attack
button.setActive(false);
break;
case MenuButtonType.AttackConfirm: // if confirm attack clicked
turnState = TurnState.Attack;
button.setActive(false);
Unit unit = GameState.selectedUnit;
MenuButton moveButtons = unit.getMenuButtonAt(1);
break;
case MenuButtonType.Move: // if moved is clicked
turnState = TurnState.Move;
GameState.dropDownMenuOpen = (false); // close the dropdownmenu when selecting where to move
......
......@@ -39,6 +39,7 @@ namespace Model
Texture2D getCharInfo(); // returns the char info screen texture
Tuple<int, int> Position { get; set;} // gets and sets unit's position by tile
Vector2 PixelCoordinates { get; set; }
MenuButton getMenuButtonAt(int i);
MenuButton[] getMenuButtons(); // returns the dropdown menu buttons of the unit
Rectangle getCurrentFrame(); // returns the current sprite frame in animation sequence
......
......@@ -183,6 +183,11 @@ namespace Model
{
return menuButtons;
}
public MenuButton getMenuButtonAt(int i)
{
return menuButtons[i];
}
// updates menu button positions
public void setMenuButtonCoordinates(Vector2 pixelCoordinates)
......
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