diff --git a/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj.Debug.cachefile b/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj.Debug.cachefile index b6a3ac3d0a0ae6055ecde3d32e2ec8bae2a607c6..fff2ff503b294a00061e5a148e90de751abeca6d 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj.Debug.cachefile +++ b/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj.Debug.cachefile @@ -6,10 +6,10 @@ Content\attack.xnb Content\items.xnb Content\move.xnb Content\wait.xnb -Content\warrior_stats.xnb -Content\warrior.xnb Content\PixelFont.xnb +Content\warrior_stats.xnb Content\PixelFontLarge.xnb +Content\warrior.xnb Content\instructions1.xnb Content\instructions2.xnb Content\instructions3.xnb diff --git a/src/Blaze-Brigade/Blaze_Brigade/Game.cs b/src/Blaze-Brigade/Blaze_Brigade/Game.cs index 56c1adce7df971d3972644945384c1a5c58dfd0e..3b0677d5150c454a6c53bc23efac7a4c1a553566 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Game.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Game.cs @@ -304,6 +304,11 @@ namespace Controller } } } + MenuButton confirmButton = unit.getAttackConfirmButton(); + if (GameState.attackConfirmOpen) + { + spriteBatch.Draw(confirmButton.getImage(), confirmButton.getPixelCoordinates(), null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } #endregion } @@ -361,14 +366,14 @@ namespace Controller MenuButton moveButton = new MenuButton(MenuButtonType.Move, unitPosition, Content.Load<Texture2D>("move")); MenuButton itemButton = new MenuButton(MenuButtonType.Items, unitPosition, Content.Load<Texture2D>("items")); ; MenuButton waitButton = new MenuButton(MenuButtonType.Wait, unitPosition, Content.Load<Texture2D>("wait")); ; - MenuButton attackConfirmButton = new MenuButton(MenuButtonType.Attack, unitPosition, Content.Load<Texture2D>("attack")); + MenuButton attackConfirmButton = new MenuButton(MenuButtonType.AttackConfirm, unitPosition, Content.Load<Texture2D>("attack")); if (player == 1) { if (unitType == UnitType.Warrior) { Unit unit = new Warrior(Content.Load<Texture2D>("warrior"), attackButton, moveButton, - itemButton, waitButton, Content.Load<Texture2D>("warrior_stats"), unitPosition, 1); + itemButton, waitButton, attackConfirmButton, Content.Load<Texture2D>("warrior_stats"), unitPosition, 1); graph.getNode(unitPosition).unitOnNode = (unit); return unit; } @@ -378,7 +383,7 @@ namespace Controller if (unitType == UnitType.Warrior) { Unit unit = new Warrior(Content.Load<Texture2D>("2warrior"), attackButton, moveButton, - itemButton, waitButton, Content.Load<Texture2D>("2warrior_stats"), unitPosition, 2); + itemButton, waitButton, attackConfirmButton, Content.Load<Texture2D>("2warrior_stats"), unitPosition, 2); graph.getNode(unitPosition).unitOnNode = (unit); return unit; } diff --git a/src/Blaze-Brigade/Blaze_Brigade/GameState.cs b/src/Blaze-Brigade/Blaze_Brigade/GameState.cs index 4347d49ce922d6d20360f847677b670bf89e8811..a8bcb753924e614f5b49074d198a37c0821db031 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/GameState.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/GameState.cs @@ -17,6 +17,7 @@ namespace Model public static Player currentPlayer { get; set; } // indicates player 1 public static Player enemyPlayer { get; set; } // indicates enemy player (player 2) public static bool dropDownMenuOpen { get; set; } // indicates whether drop down menu should be open + public static bool attackConfirmOpen { get; set; } //indicates whether player has selected a unit to attack public static bool beforeMove { get; set; } // true before unit moves, false after it moves. Used to determine what tiles are highlighted public static bool isAnimating { get; set; } // indicates whether an animation sequence is on screen public static LinkedList<Node> moveableNodes { get; set; } // holds moveable nodes that can be retreived without calling path finding diff --git a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs index 92549984c902362dde8ed09f8ec42c87063979e4..f1d677c2eb984e0ee0217004b8925ed45361f025 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs @@ -58,12 +58,11 @@ namespace Controller if (getMenuButtonClicked(mouseClickCoordinates) != null) { MenuButton menuButton = getMenuButtonClicked(mouseClickCoordinates); + Debug.WriteLine(getMenuButtonClicked(mouseClickCoordinates).getButtonType()); buttonAction(menuButton); return; } - - // if user clicks on a valid end node, move to it if (turnState == TurnState.Move) { @@ -89,12 +88,10 @@ namespace Controller if (unit != null) { setAttackedUnit(unit, true); - attackAnimation(graph, 0); - - //GameState.dropDownMenuOpen = (true); + GameState.attackConfirmOpen = true; //opens attack confirm button - - } + + } } } @@ -165,7 +162,7 @@ namespace Controller GameState.beforeMove = (false); } - private static void attackAnimation(Graph graph, int direction) + private static void attackAnimation(int direction) { Unit unit = GameState.selectedUnit; GameState.isAnimating = true; @@ -181,12 +178,13 @@ namespace Controller Thread.Sleep(10); } - for (float i = unit.PixelCoordinates.X; i >= originalLocationX; i--) + 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); } + Debug.WriteLine(unit.PixelCoordinates.X); } #endregion #region Attack Left @@ -194,30 +192,30 @@ namespace Controller { for (float i = originalLocationX; i >= originalLocationX - 8; i--) { - unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X + 1, unit.PixelCoordinates.Y); + 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++) + for (float i = unit.PixelCoordinates.X; i < originalLocationX; i++) { - unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X - 1, unit.PixelCoordinates.Y); + 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 + #region Attack Down + else if (direction == 2) //attack down { - for (float i = originalLocationY; i >= originalLocationY - 8; i--) + 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++) + for (float i = unit.PixelCoordinates.Y; i > originalLocationY; i++) { unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X , unit.PixelCoordinates.Y - 1); Game.Instance.Tick(); @@ -225,19 +223,19 @@ namespace Controller } } #endregion - #region Attack Down - else if (direction == 3) //attack down + #region Attack Up + else if (direction == 3) //attack up { for (float i = originalLocationY; i >= originalLocationY - 8; i--) { - unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X, unit.PixelCoordinates.Y + 1); + 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++) + for (float i = unit.PixelCoordinates.Y; i < originalLocationY; i++) { - unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X, unit.PixelCoordinates.Y - 1); + unit.PixelCoordinates = new Vector2(unit.PixelCoordinates.X, unit.PixelCoordinates.Y + 1); Game.Instance.Tick(); Thread.Sleep(10); } @@ -311,6 +309,15 @@ namespace Controller } } } + int ButtonX = (int)unit.getAttackConfirmButton().getPixelCoordinates().X; + int ButtonY = (int)unit.getAttackConfirmButton().getPixelCoordinates().Y; + if (ButtonX <= clickX && clickX < ButtonX + 128 && ButtonY <= clickY && clickY < ButtonY + 32) + { + if (GameState.attackConfirmOpen) + { + return unit.getAttackConfirmButton(); + } + } return null; } @@ -318,32 +325,54 @@ namespace Controller private static void buttonAction(MenuButton button) { // take action corresponding to which button was clicked + Unit unit = GameState.selectedUnit; + Unit unit2 = GameState.unitToAttack; switch (button.getButtonType()) { - case MenuButtonType.Attack: // if attackMenu clicked - turnState = TurnState.AttackMenu; - GameState.dropDownMenuOpen = (false); // close the dropdownmenu when selecting who to attack - button.setActive(false); + case MenuButtonType.Attack: // if attack clicked + turnState = TurnState.Attack; + 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; + turnState = TurnState.AttackMenu; button.setActive(false); - Unit unit = GameState.selectedUnit; - MenuButton moveButtons = unit.getMenuButtonAt(1); + unit.getMenuButtonAt(1).setActive(false); + int attackDirection=0; + if (unit.Position.Item1 < unit2.Position.Item1) + { + attackDirection = 0; + } + else if (unit.Position.Item1 > unit2.Position.Item1) + { + attackDirection = 1; + } + else if (unit.Position.Item2 < unit2.Position.Item2) + { + attackDirection = 2; + } + else if (unit.Position.Item2 > unit2.Position.Item2) + { + attackDirection = 3; + } + Debug.WriteLine(attackDirection); + attackAnimation(attackDirection); + GameState.attackConfirmOpen = false; + GameState.dropDownMenuOpen = true; break; case MenuButtonType.Move: // if moved is clicked turnState = TurnState.Move; - GameState.dropDownMenuOpen = (false); // close the dropdownmenu when selecting where to move + GameState.dropDownMenuOpen = false; // close the dropdownmenu when selecting where to move button.setActive(false); break; case MenuButtonType.Items: // if item is clicked turnState = TurnState.Items; - GameState.dropDownMenuOpen = (false); + GameState.dropDownMenuOpen = false; break; case MenuButtonType.Wait: // if wait is clicked turnState = TurnState.Wait; - GameState.dropDownMenuOpen = (false); + GameState.dropDownMenuOpen = false; GameState.playableUnitSelected = false; button.setActive(false); break; diff --git a/src/Blaze-Brigade/Blaze_Brigade/Unit.cs b/src/Blaze-Brigade/Blaze_Brigade/Unit.cs index 27262a4442abaa335aaf8faa02f3de073191e20e..6181352d7b7452ee36a27a32b6c7d0d73a00f91f 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Unit.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Unit.cs @@ -40,6 +40,7 @@ namespace Model Tuple<int, int> Position { get; set;} // gets and sets unit's position by tile Vector2 PixelCoordinates { get; set; } MenuButton getMenuButtonAt(int i); + MenuButton getAttackConfirmButton(); MenuButton[] getMenuButtons(); // returns the dropdown menu buttons of the unit Rectangle getCurrentFrame(); // returns the current sprite frame in animation sequence diff --git a/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs b/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs index b315e69e11b6e326b90e87c2dd6fefd87eaede0e..9b0960e0fc17a0aa53e79ff36bd165dd498c72f6 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs @@ -34,13 +34,14 @@ namespace Model private int player; // which player this unit belongs to public Warrior(Texture2D spriteImage, MenuButton attackButton, MenuButton moveButton, - MenuButton itemButton, MenuButton waitButton, Texture2D charInfo, Vector2 coordinates, int player) + MenuButton itemButton, MenuButton waitButton, MenuButton confirmButton, Texture2D charInfo, Vector2 coordinates, int player) { this.spriteImage = spriteImage; menuButtons[0] = attackButton; menuButtons[1] = moveButton; menuButtons[2] = itemButton; menuButtons[3] = waitButton; + attackConfirm = confirmButton; this.charInfo = charInfo; this.player = player; pixelCoordinates = coordinates; @@ -192,6 +193,11 @@ namespace Model { return menuButtons[i]; } + + public MenuButton getAttackConfirmButton() + { + return attackConfirm; + } // updates menu button positions public void setMenuButtonCoordinates(Vector2 pixelCoordinates)