diff --git a/src/Blaze-Brigade/Blaze_Brigade/Archer.cs b/src/Blaze-Brigade/Blaze_Brigade/Archer.cs index cd0ed0217332a27cd448155465cdf2ba65e357b4..2103c09f0226a1b7372df70c063e5a08250c6640 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Archer.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Archer.cs @@ -360,6 +360,15 @@ namespace Model return screenBounds; } + /** + Sets the current frame unit should be on + * @param frame the current frame number + */ + public void setCurrentFrame(int frame) + { + currentFrame = frame; + } + /** animate sprite walking the direction specified * @param direction The direction the unit is moving in diff --git a/src/Blaze-Brigade/Blaze_Brigade/Game.cs b/src/Blaze-Brigade/Blaze_Brigade/Game.cs index c57a767c1dede165c486d51a92c45c682d03e535..9849b27dd89ee4d77998481c715f8641ce32655f 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Game.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Game.cs @@ -313,6 +313,7 @@ namespace Controller if (GameState.beforeMove) // if unit has yet to move, display the overall move and attack range of unit { // Highlight movable nodes in blue + Debug.WriteLine(GameState.moveableNodes.Count()); foreach (Node move in GameState.moveableNodes) { spriteBatch.Draw(moveableNode, move.getPosition(), null, Color.White * 0.2f, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.9f); @@ -320,14 +321,16 @@ namespace Controller // Highlight attackable nodes in red LinkedList<Node> attackableNodes = GameFunction.getAttackableNodes(graph, unit); + + //Debug.WriteLine(attackableNodes.Count()); foreach (Node attack in attackableNodes) { - if (!GameState.moveableNodes.Contains(attack)) + if ((!GameState.moveableNodes.Contains(attack))&&(attack.unitOnNode!=unit)&&(!attack.isObstacle)) { spriteBatch.Draw(attackableNode, attack.getPosition(), null, Color.White * 0.2f, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.9f); } } - + } else // else if unit has already moved, only display the attack range { @@ -366,7 +369,6 @@ namespace Controller int critRate = DamageCalculations.getCritRate(unit, attackedUnit); // get enemy counter attack stats attackType = findAttackType(attackedUnit); - Debug.WriteLine(attackType); int damageDealt2 = DamageCalculations.getDamageDealt(attackedUnit, unit, attackType); int hitCount2 = DamageCalculations.getHitCount(attackedUnit, unit); int hitRate2 = DamageCalculations.getHitRate(attackedUnit, unit); @@ -475,9 +477,10 @@ namespace Controller } #endregion + + #region Game Over if (GameState.gameOver) { - Debug.WriteLine("game over"); Vector2 gameOverLocation = new Vector2(-370, -300); spriteBatch.DrawString(largestFont,"Game Over", new Vector2(350, 200), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f); //draws Game Over Text spriteBatch.Draw(gameOver, Vector2.Zero, null, Color.White, 0, gameOverLocation, 1f, SpriteEffects.None, 0f); @@ -509,6 +512,7 @@ namespace Controller } #endregion } + #endregion spriteBatch.Draw(backGround, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 1); diff --git a/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs b/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs index 5018405c8dbef89f685deb2ac023896e316d77bb..d5f0088df1fee00329266b11701b465eacac2829 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs @@ -232,8 +232,8 @@ namespace Controller { for (int y = 0; y < graph.Height; y++) { - if (isNodeAttackable(unit.getClass(), moveableNode.getPositionX(), - moveableNode.getPositionY(), graph.getNode(x, y))) + if ((isNodeAttackable(unit.getClass(), moveableNode.getPositionX(), + moveableNode.getPositionY(), graph.getNode(x, y)))&&(!attackableNodes.Contains(graph.getNode(x, y)))) //make sure attackable nodes is only added once each to list { // if node is attackable, add it to list of attackable nodes attackableNodes.AddLast(graph.getNode(x, y)); diff --git a/src/Blaze-Brigade/Blaze_Brigade/Mage.cs b/src/Blaze-Brigade/Blaze_Brigade/Mage.cs index bcfa849d18b1e9d29f499404029d3b77264bd459..9799aeb0eb9fdd2d9f1d1411207957ab4397eaac 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Mage.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Mage.cs @@ -360,6 +360,15 @@ namespace Model return screenBounds; } + /** + Sets the current frame unit should be on + * @param frame the current frame number + */ + public void setCurrentFrame(int frame) + { + currentFrame = frame; + } + /** animate sprite walking the direction specified * @param direction The direction the unit is moving in diff --git a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs index a081c3e18ff067a22d58f226b80864457a2897dd..783ebf5e86b84b47310ccf3d3563ba93d1a78731 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs @@ -200,13 +200,13 @@ namespace Controller GameState.isAnimating = false; } - private static void attackAnimation(int direction, Unit unit) + private static void attackAnimation(Direction direction, Unit unit) { GameState.isAnimating = true; float originalLocationX = unit.PixelCoordinates.X; float originalLocationY = unit.PixelCoordinates.Y; #region Attack Right - if (direction == 0) //attack right + if (direction == Direction.Right) //attack right { for (float i = originalLocationX; i <= originalLocationX + 8; i++) { @@ -224,7 +224,7 @@ namespace Controller } #endregion #region Attack Left - else if (direction == 1) //attack left + else if (direction == Direction.Left) //attack left { for (float i = originalLocationX; i >= originalLocationX - 8; i--) { @@ -242,7 +242,7 @@ namespace Controller } #endregion #region Attack Down - else if (direction == 2) //attack down + else if (direction == Direction.Down) //attack down { for (float i = originalLocationY; i <= originalLocationY + 8; i++) { @@ -260,7 +260,7 @@ namespace Controller } #endregion #region Attack Up - else if (direction == 3) //attack up + else if (direction == Direction.Up) //attack up { for (float i = originalLocationY; i >= originalLocationY - 8; i--) { @@ -390,28 +390,46 @@ namespace Controller int counterAttackDirection = 0; //Gets attack anaimation direction #region Attack animation Direction - if (unit.Position.Item1 < unit2.Position.Item1) + Direction attackDir = Direction.Up; + Direction counterAttackDir = Direction.Up; + if (unit.Position.Item1 < unit2.Position.Item1) //attack right { attackDirection = 0; counterAttackDirection = 1; + attackDir = Direction.Right; + counterAttackDir = Direction.Left; + unit.setCurrentFrame(7); + unit2.setCurrentFrame(4); } - else if (unit.Position.Item1 > unit2.Position.Item1) + else if (unit.Position.Item1 > unit2.Position.Item1) //attack left { attackDirection = 1; counterAttackDirection = 0; + attackDir = Direction.Left; + counterAttackDir = Direction.Right; + unit.setCurrentFrame(4); + unit2.setCurrentFrame(7); } - else if (unit.Position.Item2 < unit2.Position.Item2) + else if (unit.Position.Item2 < unit2.Position.Item2) //attack down { attackDirection = 2; counterAttackDirection = 3; + attackDir = Direction.Down; + counterAttackDir = Direction.Up; + unit.setCurrentFrame(1); + unit2.setCurrentFrame(10); } - else if (unit.Position.Item2 > unit2.Position.Item2) + else if (unit.Position.Item2 > unit2.Position.Item2) //attack up { attackDirection = 3; counterAttackDirection = 2; + attackDir = Direction.Up; + counterAttackDir = Direction.Down; + unit.setCurrentFrame(10); + unit2.setCurrentFrame(1); } #endregion - attackAnimation(attackDirection, unit); + attackAnimation(attackDir, unit); bool attackType = false; @@ -424,7 +442,7 @@ namespace Controller if (unit2.Alive && (GameFunction.isEnemyUnitInRange(graph, unit2, unit))) //if unit 2 is still alive, perform a counter attack { Thread.Sleep(750); - attackAnimation(counterAttackDirection, unit2); + attackAnimation(counterAttackDir, unit2); attackType = findAttackType(unit2); //gets attack type int damageTaken = DamageCalculations.finalDamage(unit2, unit, attackType); //damage dealt unit.Hp = unit.Hp - damageTaken; //update hp diff --git a/src/Blaze-Brigade/Blaze_Brigade/Unit.cs b/src/Blaze-Brigade/Blaze_Brigade/Unit.cs index 05f7f8914621062c10764128cdc8d980444a5f1e..07d81ea20a720105e7405cf4dd0bcc263a045cf6 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Unit.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Unit.cs @@ -153,6 +153,12 @@ namespace Model */ Rectangle getCurrentFrame(); + /** + Sets the current frame unit should be on + * @param frame the current frame number + */ + void setCurrentFrame(int frame); + /** returns array of equipable weapons */ diff --git a/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs b/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs index bf71a5fe40b66c8a2e7099e22fd8ad8afd93a934..4a4a2079826a3726812822703db01f7d97993c34 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs @@ -34,6 +34,7 @@ namespace Model Sets and returns a unit's Defense */ public int Def { get; set; } + /** Sets and returns a unit's Resistance */ @@ -380,6 +381,15 @@ namespace Model return screenBounds; } + /** + Sets the current frame unit should be on + * @param frame the current frame number + */ + public void setCurrentFrame(int frame) + { + currentFrame = frame; + } + /** animate sprite walking the direction specified * @param direction The direction the unit is moving in @@ -434,7 +444,7 @@ namespace Model { if ((currentFrame < 6) || (currentFrame > 8)) // if unit isnt already going right, set the sprite to default facing right { - currentFrame = 7;//increment walk cycle + currentFrame = 7; } else { @@ -444,7 +454,7 @@ namespace Model } else { - currentFrame++; + currentFrame++; //increment walk cycle } } }