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 eb4ef8122cde2b2dc951926e6f7198ced073dd71..22ddb4255070f648ee37156ec6291e36c39c3839 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj.Debug.cachefile +++ b/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj.Debug.cachefile @@ -31,3 +31,4 @@ Content\mage_attack.xnb Content\warrior_attack.xnb Content\attack_confirm.xnb Content\confirm_attack.xnb +Content\PixelFontLargest.xnb diff --git a/src/Blaze-Brigade/Blaze_Brigade/DamageCalculations.cs b/src/Blaze-Brigade/Blaze_Brigade/DamageCalculations.cs index 17c676f396d89d79cd2fd534cb0eac172e2d6d2d..a15551ec359c87f535c5ac53ea09bed9a1143596 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/DamageCalculations.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/DamageCalculations.cs @@ -6,11 +6,11 @@ using System.Text; namespace Model { //This class deals with all damage calculations dealt by a unit attacking another unit - class DamageCalculations + static class DamageCalculations { //passes in the 2 units, and a boolean on whether attack is physical (false), or magical (true), and returns damage dealt by taking into account an attacker's str/int, and defender def/res - public int getDamageDealt(Unit attacker, Unit defender, bool physOrMagic){ + public static int getDamageDealt(Unit attacker, Unit defender, bool physOrMagic){ if(physOrMagic== false) { return attacker.Str - defender.Def; //return physical damage dealt @@ -23,19 +23,19 @@ namespace Model } //passes in the 2 units, and returns the hit rate as a percentage out of 100 by taking into account both unit's skill - public int getHitRate(Unit attacker, Unit defender) + public static int getHitRate(Unit attacker, Unit defender) { return (int) Math.Round( ( ( (attacker.Skill / 10.0) - (defender.Skill / 10.0) + 1.0) * 0.8)*100.0); } //passes in the 2 units, and returns the crit rate as a percentage out of 100 by taking into account both unit's skill - public int getCritRate(Unit attacker, Unit defender) + public static int getCritRate(Unit attacker, Unit defender) { - return (int)Math.Round( ( ( (attacker.Skill / 3.0) - (defender.Skill / 3.0) + 1.0) * 0.8) * 100.0); + return (int)Math.Round( ( ( (attacker.Skill / 3.0) - (defender.Skill / 3.0) + 1.0) * 0.1) * 100.0); } //passes in then 2 units, and determines how many attacks the attacker makes by factoring in both unit's relative speed - public int getHitCount(Unit attacker, Unit defender) + public static int getHitCount(Unit attacker, Unit defender) { if (attacker.Speed > (defender.Speed + 4)) { @@ -48,7 +48,7 @@ namespace Model } //factors in damage dealt, hit rate, crit rate, and number of attacks (as in how above functions were calculated) to calculate actual damage dealt - public int finalDamage(Unit attacker, Unit defender, bool physOrMagic) + public static int finalDamage(Unit attacker, Unit defender, bool physOrMagic) { int rawDamage = getDamageDealt(attacker, defender, physOrMagic); int hitRate = getHitRate(attacker, defender); diff --git a/src/Blaze-Brigade/Blaze_Brigade/Game.cs b/src/Blaze-Brigade/Blaze_Brigade/Game.cs index 01dd8e01c923b63cbb6d59998c29c44c6f53475c..d822b8c0adaf5d4a9c788beb4584c758567055bb 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Game.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Game.cs @@ -47,6 +47,7 @@ namespace Controller Texture2D backGround, moveableNode, attackableNode; private SpriteFont font; // custom font private SpriteFont largeFont; // custom font 2 + private SpriteFont largestFont; // custom font 3 #endregion @@ -89,6 +90,7 @@ namespace Controller font = Content.Load<SpriteFont>("PixelFont"); //loads font PixelFont largeFont = Content.Load<SpriteFont>("PixelFontLarge"); //loads font PixelFont + largestFont = Content.Load<SpriteFont>("PixelFontLargest"); //loads font PixelFont graphics.PreferredBackBufferWidth = GameState.SCREEN_WIDTH; // width of screen graphics.PreferredBackBufferHeight = GameState.SCREEN_HEIGHT; //height of screen @@ -303,24 +305,62 @@ namespace Controller } } } - + #region Attack menu Button confirmButton = unit.getButtonOfType(ButtonType.AttackConfirm); Vector2 attackInfoLocation2 = new Vector2(519, 0); + if (GameState.attackConfirmOpen) { + // get attack stats + int damageDealt = DamageCalculations.getDamageDealt(unit, attackedUnit, false); + int hitCount = DamageCalculations.getHitCount(unit, attackedUnit); + int hitRate = DamageCalculations.getHitRate(unit, attackedUnit); + int critRate = DamageCalculations.getCritRate(unit, attackedUnit); + // get enemy counter attack stats + int damageDealt2 = DamageCalculations.getDamageDealt(attackedUnit, unit, false); + int hitCount2 = DamageCalculations.getHitCount(attackedUnit, unit); + int hitRate2 = DamageCalculations.getHitRate(attackedUnit, unit); + int critRate2 = DamageCalculations.getCritRate(attackedUnit, unit); + if (GameState.currentPlayer == player1) { - spriteBatch.Draw(unit.getCharAttackInfo(), Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charAttackInfoBackground texture for current character + + spriteBatch.Draw(unit.getCharAttackInfo(), Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charAttackInfoBackground texture for current character + spriteBatch.DrawString(largeFont, damageDealt.ToString(), new Vector2(180, 458), Color.DarkBlue, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws damage dealt + spriteBatch.DrawString(font, " x " +hitCount.ToString(), new Vector2(195, 459), Color.DarkBlue, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws hit count + spriteBatch.DrawString(largeFont, hitRate.ToString()+" %", new Vector2(170, 488), Color.DarkBlue, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws hit rate + spriteBatch.DrawString(largeFont, critRate.ToString()+" %", new Vector2(170, 518), Color.DarkBlue, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws crit rate + spriteBatch.DrawString(largestFont, unit.Hp.ToString(), new Vector2(342, 475), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws unit health + spriteBatch.Draw(attackedUnit.getCharAttackInfo(), attackInfoLocation2, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charAttackInfoBackground for unit being attacked + spriteBatch.DrawString(largeFont, damageDealt2.ToString(), new Vector2(700, 458), Color.DarkRed, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws counterattack damage + spriteBatch.DrawString(font, " x " + hitCount2.ToString(), new Vector2(715, 459), Color.DarkRed, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws counterattack hit count + spriteBatch.DrawString(largeFont, hitRate2.ToString() + " %", new Vector2(690, 488), Color.DarkRed, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws counterattack hit rate + spriteBatch.DrawString(largeFont, critRate2.ToString() + " %", new Vector2(690, 518), Color.DarkRed, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws counterattack crit rate + spriteBatch.DrawString(largestFont, attackedUnit.Hp.ToString(), new Vector2(862, 475), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws enemy unit health + } else { - spriteBatch.Draw(unit.getCharAttackInfo(), attackInfoLocation2, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charAttackInfoBackground texture for current character - spriteBatch.Draw(attackedUnit.getCharAttackInfo(), Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charAttackInfoBackground for unit being attacked + spriteBatch.Draw(attackedUnit.getCharAttackInfo(), Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charAttackInfoBackground texture for current character + spriteBatch.DrawString(largeFont, damageDealt.ToString(), new Vector2(180, 458), Color.DarkBlue, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws counterattack damage + spriteBatch.DrawString(font, " x " +hitCount.ToString(), new Vector2(195, 459), Color.DarkBlue, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws counterattack hit count + spriteBatch.DrawString(largeFont, hitRate.ToString()+" %", new Vector2(170, 488), Color.DarkBlue, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws counterattack hit rate + spriteBatch.DrawString(largeFont, critRate.ToString()+" %", new Vector2(170, 518), Color.DarkBlue, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws counterattack crit rate + spriteBatch.DrawString(largestFont, attackedUnit.Hp.ToString(), new Vector2(342, 475), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws enemy unit health + + spriteBatch.Draw(unit.getCharAttackInfo(), attackInfoLocation2, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charAttackInfoBackground for current character + spriteBatch.DrawString(largeFont, damageDealt.ToString(), new Vector2(700, 458), Color.DarkRed, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws damage + spriteBatch.DrawString(font, " x " + hitCount.ToString(), new Vector2(715, 459), Color.DarkRed, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws hit count + spriteBatch.DrawString(largeFont, hitRate.ToString() + " %", new Vector2(690, 488), Color.DarkRed, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws hit rate + spriteBatch.DrawString(largeFont, critRate.ToString() + " %", new Vector2(690, 518), Color.DarkRed, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws crit rate + spriteBatch.DrawString(largestFont, unit.Hp.ToString(), new Vector2(862, 475), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws unit health + } spriteBatch.Draw(confirmButton.getImage(), confirmButton.getPixelCoordinates(), null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.8f); } #endregion + #endregion } #region Character Info Screen player1 @@ -335,17 +375,16 @@ namespace Controller for (int k = 0; k < 4; k++) //for stats - level, str, int, skill, { - spriteBatch.DrawString(font, unit.getStats(k).ToString(), statLocation, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws each stat + spriteBatch.DrawString(font, unit.getStats(k).ToString(), statLocation, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); statLocation = statLocation + increment; //increment downwards } for (int t = 4; t < 7; t++) //for stats - speed, defense, resistance { - spriteBatch.DrawString(font, unit.getStats(t).ToString(), statLocation2, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws each stat + spriteBatch.DrawString(font, unit.getStats(t).ToString(), statLocation2, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); statLocation2 = statLocation2 + increment; //increment downwards } - spriteBatch.DrawString(largeFont, unit.Hp.ToString(), new Vector2(278, 532), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws each stat - + spriteBatch.DrawString(largeFont, unit.Hp.ToString(), new Vector2(278, 532), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws unit hp spriteBatch.Draw(unit.getCharInfo(), infoLocation, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charInfoBackground texture } //else, info screen for player 2 @@ -360,17 +399,17 @@ namespace Controller for (int k = 0; k < 4; k++) //for stats - level, str, int, skill, { - spriteBatch.DrawString(font, unit.getStats(k).ToString(), statLocation, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws each stat + spriteBatch.DrawString(font, unit.getStats(k).ToString(), statLocation, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); statLocation = statLocation + increment; //increment downwards } for (int t = 4; t < 7; t++) //for stats - speed, defense, resistance { - spriteBatch.DrawString(font, unit.getStats(t).ToString(), statLocation2, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws each stat + spriteBatch.DrawString(font, unit.getStats(t).ToString(), statLocation2, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); statLocation2 = statLocation2 + increment; //increment downwards } - spriteBatch.DrawString(largeFont, unit.Hp.ToString(), new Vector2(893, 532), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws each stat - spriteBatch.Draw(unit.getCharInfo(), infoLocation, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charInfoBackground texture + spriteBatch.DrawString(largeFont, unit.Hp.ToString(), new Vector2(893, 532), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.6f); //draws unit HP + spriteBatch.Draw(unit.getCharInfo(), infoLocation, null, Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.7f); //draw charInfoBackground texture } } #endregion diff --git a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs index 913ed9976ffcd33c8d936e52efcd8d693935ceed..e408c8c49e840c2c9400792583184bab0f799abc 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs @@ -167,9 +167,8 @@ namespace Controller GameState.isAnimating = false; } - private static void attackAnimation(int direction) + private static void attackAnimation(int direction, Unit unit) { - Unit unit = GameState.selectedUnit; GameState.isAnimating = true; float originalLocationX = unit.PixelCoordinates.X; float originalLocationY = unit.PixelCoordinates.Y; @@ -343,23 +342,35 @@ namespace Controller unit.getButtonOfType(ButtonType.Move).setActive(false); // move button is no longer active unit.getButtonOfType(ButtonType.Attack).setActive(false); // attack button is no longer active int attackDirection = 0; + int counterAttackDirection = 0; if (unit.Position.Item1 < unit2.Position.Item1) { attackDirection = 0; + counterAttackDirection = 1; } else if (unit.Position.Item1 > unit2.Position.Item1) { attackDirection = 1; + counterAttackDirection = 0; } else if (unit.Position.Item2 < unit2.Position.Item2) { attackDirection = 2; + counterAttackDirection = 3; } else if (unit.Position.Item2 > unit2.Position.Item2) { attackDirection = 3; + counterAttackDirection = 2; } - attackAnimation(attackDirection); + + attackAnimation(attackDirection, unit); + int damageDealt = DamageCalculations.finalDamage(unit, unit2, false); + Thread.Sleep(750); + attackAnimation(counterAttackDirection, unit2); + int damageTaken = DamageCalculations.finalDamage(unit2, unit, false); + unit2.Hp = unit2.Hp - damageDealt; + unit.Hp = unit.Hp - damageTaken; GameState.attackConfirmOpen = false; setSelectedUnit(null, false); turnState = TurnState.Wait; diff --git a/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs b/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs index 31026be3ba76be859e8cd8fa1539cedab9ec720a..c29e2a84c06c212c5bba17b9d4a73f13fd543422 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs @@ -59,7 +59,7 @@ namespace Model Alive = true; Level = 1; Hp = 10; - Str = 9; + Str = 7; Int = 1; Skill = 6; Speed = 8; diff --git a/src/Blaze-Brigade/Blaze_BrigadeContent/Blaze_BrigadeContent.contentproj b/src/Blaze-Brigade/Blaze_BrigadeContent/Blaze_BrigadeContent.contentproj index 3cda57cb96072da1f5f7743a18b35c200d3b70a6..8a09698cf68cbf3f218bab3f5c02b720fc8495ac 100644 --- a/src/Blaze-Brigade/Blaze_BrigadeContent/Blaze_BrigadeContent.contentproj +++ b/src/Blaze-Brigade/Blaze_BrigadeContent/Blaze_BrigadeContent.contentproj @@ -261,6 +261,13 @@ <Processor>TextureProcessor</Processor> </Compile> </ItemGroup> + <ItemGroup> + <Compile Include="PixelFontLargest.spritefont"> + <Name>PixelFontLargest</Name> + <Importer>FontDescriptionImporter</Importer> + <Processor>FontDescriptionProcessor</Processor> + </Compile> + </ItemGroup> <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. diff --git a/src/Blaze-Brigade/Blaze_BrigadeContent/PixelFontLargest.spritefont b/src/Blaze-Brigade/Blaze_BrigadeContent/PixelFontLargest.spritefont new file mode 100644 index 0000000000000000000000000000000000000000..c5d620e0a8bb0fa7cee448b15ac273913e94b772 --- /dev/null +++ b/src/Blaze-Brigade/Blaze_BrigadeContent/PixelFontLargest.spritefont @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +This file contains an xml description of a font, and will be read by the XNA +Framework Content Pipeline. Follow the comments to customize the appearance +of the font in your game, and to change the characters which are available to draw +with. +--> +<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics"> + <Asset Type="Graphics:FontDescription"> + + <!-- + Modify this string to change the font that will be imported. + --> + <FontName>PixelMplus10</FontName> + + <!-- + Size is a float value, measured in points. Modify this value to change + the size of the font. + --> + <Size>50</Size> + + <!-- + Spacing is a float value, measured in pixels. Modify this value to change + the amount of spacing in between characters. + --> + <Spacing>0</Spacing> + + <!-- + UseKerning controls the layout of the font. If this value is true, kerning information + will be used when placing characters. + --> + <UseKerning>true</UseKerning> + + <!-- + Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic", + and "Bold, Italic", and are case sensitive. + --> + <Style>Regular</Style> + + <!-- + If you uncomment this line, the default character will be substituted if you draw + or measure text that contains characters which were not included in the font. + --> + <!-- <DefaultCharacter>*</DefaultCharacter> --> + + <!-- + CharacterRegions control what letters are available in the font. Every + character from Start to End will be built and made available for drawing. The + default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin + character set. The characters are ordered according to the Unicode standard. + See the documentation for more information. + --> + <CharacterRegions> + <CharacterRegion> + <Start> </Start> + <End>~</End> + </CharacterRegion> + </CharacterRegions> + </Asset> +</XnaContent>