diff --git a/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj b/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj index e1a4dc244c1dab0b88e6a6719d12b5db95371655..09218cbc282901e230f7e4be919b9f79c996390a 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj +++ b/src/Blaze-Brigade/Blaze_Brigade/Blaze_Brigade.csproj @@ -31,7 +31,8 @@ <UseVSHostingProcess>false</UseVSHostingProcess> <PlatformTarget>x86</PlatformTarget> <XnaCompressContent>false</XnaCompressContent> - <DocumentationFile>C:\Users\chaos\Documents\Blaze-Brigade\Doc\MIS\Blaze_Brigade.XML</DocumentationFile> + <DocumentationFile> + </DocumentationFile> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <DebugType>pdbonly</DebugType> 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 a9d64d0da54fb8788e67a5afa044380c85684697..22ddb4255070f648ee37156ec6291e36c39c3839 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 6c132c5d9a0bb2c24db5c9f39a9fb1000b59f35c..eddcee4086bb256e0407b1b6f191d9a53d95334a 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Game.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Game.cs @@ -221,6 +221,16 @@ namespace Controller case GameMenuState.Playing: // if true.. load new image... backGround = Content.Load<Texture2D>("Game_Map"); // load background + + Debug.WriteLine(player1.getNumOfUnits()); + + if (GameFunction.isGameOver(player1, player2)) + { + // TODO: game over screen + Debug.WriteLine("Game is over."); + break; + } + if (GameFunction.isTurnOver()) { Player tempPlayer = GameState.currentPlayer; @@ -228,6 +238,18 @@ namespace Controller GameState.enemyPlayer = (tempPlayer); GameFunction.startTurn(GameState.currentPlayer); } + + // removes deceased units in Player 1 + foreach(Unit unit in player1.getUnits()) + { + GameFunction.removeDeceasedUnit(graph, player1, unit); + } + + // removes deceased units in Player 2 + foreach (Unit unit in player2.getUnits()) + { + GameFunction.removeDeceasedUnit(graph, player2, unit); + } break; } #endregion @@ -251,8 +273,11 @@ namespace Controller for (int i = 0; i < player1.getNumOfUnits(); i++) { Unit unit = player1.getUnits().ElementAt(i); //gets unit at i - spriteBatch.Draw(unit.getSpriteImage(), unit.PixelCoordinates, - unit.getCurrentFrame(), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.8f); + if (unit.Alive) + { + spriteBatch.Draw(unit.getSpriteImage(), unit.PixelCoordinates, + unit.getCurrentFrame(), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.8f); + } } #endregion @@ -261,8 +286,11 @@ namespace Controller for (int i = 0; i < player2.getNumOfUnits(); i++) { Unit unit = player2.getUnits().ElementAt(i); - spriteBatch.Draw(unit.getSpriteImage(), unit.PixelCoordinates, - unit.getCurrentFrame(), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.8f); + if (unit.Alive) + { + spriteBatch.Draw(unit.getSpriteImage(), unit.PixelCoordinates, + unit.getCurrentFrame(), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.8f); + } } #endregion @@ -435,7 +463,7 @@ namespace Controller break; } - spriteBatch.End(); // end spriteBatch + spriteBatch.End(); // end spriteBatch base.Draw(gameTime); // repeatedly calls draw } diff --git a/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs b/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs index b824c039edf1bbebb076e5de6263ce2a331f7ad0..5018405c8dbef89f685deb2ac023896e316d77bb 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs @@ -130,9 +130,20 @@ namespace Controller /** Returns whether or not the game is over, based off win conditions. */ - public static bool isGameOver() + public static bool isGameOver(Player player1, Player player2) { - // TODO + // if player1 does not have anymore units, game is over + if (player1.getNumOfUnits() <= 0) + { + return true; + } + + // if player2 does not have anymore units, game is over + if (player2.getNumOfUnits() <= 0) + { + return true; + } + return false; } @@ -257,7 +268,7 @@ namespace Controller } /** - Returns a list of nodes representing the path from start node to end node; if not path is valid, return null. + Returns a list of nodes representing the path from start node to end node; if no path is valid, return null. \param graph Graph representing the current game map. \param unit Unit to move. \param start Start Node of the path. @@ -350,6 +361,18 @@ namespace Controller return adjacentNodes; } - } -} + /** + Updates units based on their status (alive/dead). If dead, will remove the unit from the game. (Unit will be no longer active). + \param unit Unit to update status of. + */ + public static void removeDeceasedUnit(Graph graph, Player player, Unit unit) + { + if (!unit.Alive) + { + graph.getNode(unit.Position).unitOnNode = null; + player.removeUnit(unit); + } + } + } +} \ No newline at end of file diff --git a/src/Blaze-Brigade/Blaze_Brigade/Player.cs b/src/Blaze-Brigade/Blaze_Brigade/Player.cs index 3af48d118f5a63de38cbb7dfe1e10b4f6cdc30bf..089104e752cf7c0dce6fd15730b1aa23734be9ab 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Player.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Player.cs @@ -62,6 +62,15 @@ namespace Model { ownedUnits.AddLast(unit); } + + /** + Removes the specified unit from the player's units. + \param unit Unit to be removed. + */ + public void removeUnit(Unit unit) + { + ownedUnits.Remove(unit); + } } } diff --git a/src/Blaze-Brigade/Blaze_Brigade/Unit.cs b/src/Blaze-Brigade/Blaze_Brigade/Unit.cs index 15a81e7796af4595b060bb70d1c8f0b150f2d63a..05f7f8914621062c10764128cdc8d980444a5f1e 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Unit.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Unit.cs @@ -32,7 +32,7 @@ namespace Model /** Sets and returns a unit's HP */ - int Hp { get; set; } + int Hp { get; set; } /** Sets and returns a unit's Strength diff --git a/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs b/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs index 54934177b6c02ad8416663c578574c3c76742a15..bf71a5fe40b66c8a2e7099e22fd8ad8afd93a934 100644 --- a/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs +++ b/src/Blaze-Brigade/Blaze_Brigade/Warrior.cs @@ -20,13 +20,12 @@ namespace Model Sets and returns whether or not unit is alive */ public bool Alive { get; set; } - /** - Sets and returns a unit's HP - */ - public int Hp { get; set; } + private int str; // unit strength private int intelligence; // unit intelliegence private int skill; // unit skill + private int hp; // unit hp + /** Sets and returns a unit's Speed */ @@ -154,6 +153,27 @@ namespace Model } } + /* + Sets the hp of the unit. + \n Gets the unit's hp. + */ + public int Hp + { + get + { + return hp; + } + set + { + if (value <= 0) + { + this.Alive = false; + } + + hp = value; + } + } + /** Returns the unit's movability range on grid (number of spaces the unit can move in one turn) */