Skip to content
Snippets Groups Projects
Commit 47da281d authored by Susan Yuen's avatar Susan Yuen
Browse files

Adding unit death

parent 1a60dae4
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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
......
......@@ -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
}
......
......@@ -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
......@@ -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);
}
}
}
......@@ -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
......
......@@ -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)
*/
......
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