Skip to content

Commit

Permalink
added bonus score for completing the waves quickly
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Perdue committed Mar 13, 2022
1 parent ae7f359 commit d57e330
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Scenes/AlexandraSquare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class AlexandraSquare : BaseScene
Player player;
Boolean timed = false;
Label waveInfo;
int timeStart = -1;
public override void Initialize()
{
base.Initialize();
Expand All @@ -34,21 +35,27 @@ public override void Initialize()
waveInfo.FontSize = 32;
waveInfo.Colour = Color.Black;
waveInfo.Anchor = UIAnchor.Right | UIAnchor.Top;
timeStart = (int)(DateTime.UtcNow - new DateTime(1000, 1, 1)).TotalSeconds;
UI.AddElement(waveInfo);
//...
}

public void spawnReset()
{
timeStart = (int)(DateTime.UtcNow - new DateTime(1000, 1, 1)).TotalSeconds;
if (player != null && timed)
{
player.respawn();
spawnEnemy(1, new int[] { -10, 69 }, new int[] { -8, 6 }, player.Layer, 0);
}
}

public void waveReset()
{
int timeElapsed = timeStart - (int)(DateTime.UtcNow - new DateTime(1000, 1, 1)).TotalSeconds;
if(((waveCounter * 30) - timeElapsed) * 5 > 0 && waveCounter != 1)
{
player.score += ((waveCounter * 60) - timeElapsed) *5;
}
if (player.health < 100)
if (player.health > 70)
player.health = 100;
Expand All @@ -57,6 +64,7 @@ public void waveReset()
spawnEnemy(waveCounter *2, new int[] { -10, 69 }, new int[] { -8, 6 }, player.Layer,0);
spawnEnemy((int)waveCounter /2, new int[] { -10, 69 }, new int[] { -8, 6 }, player.Layer, 1);
spawnEnemy((int)waveCounter/3, new int[] { -10, 69 }, new int[] { -8, 6 }, player.Layer, 2);
timeStart = (int)(DateTime.UtcNow - new DateTime(1000, 1, 1)).TotalSeconds;
}

public override void Update(GameTime delta)
Expand Down

0 comments on commit d57e330

Please sign in to comment.