Skip to content

Commit

Permalink
changed wave system
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Perdue committed Mar 10, 2022
1 parent 6bf8fb2 commit 81287cc
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
7 changes: 3 additions & 4 deletions Scenes/AlexandraSquare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ public void waveReset()
player.health = 100;
else
player.health += 30;
spawnEnemy(waveCounter*4, new int[] { -10, 69 }, new int[] { -8, 6 }, player.Layer,0);
spawnEnemy(waveCounter, new int[] { -10, 69 }, new int[] { -8, 6 }, player.Layer, 1);
spawnEnemy(waveCounter, new int[] { -10, 69 }, new int[] { -8, 6 }, player.Layer, 2);
//make it so it spawns different enemy types at higher waves - need different enemy types
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);
}

public override void Update(GameTime delta)
Expand Down
45 changes: 24 additions & 21 deletions Scenes/BaseScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,35 @@ public override void Update(GameTime delta)

public void spawnEnemy(int amount, int[] rangeX, int[] rangeY, int layer,int enemyType)
{
string[] directions = new string[] { "up", "down", "left", "right" };
List<Point> spawnableTiles = new List<Point>();
for (int x = rangeX[0]; x < rangeX[1]; x++)
if (amount != 0)
{
for (int y = rangeY[0]; y < rangeY[1]; y++)
string[] directions = new string[] { "up", "down", "left", "right" };
List<Point> spawnableTiles = new List<Point>();
for (int x = rangeX[0]; x < rangeX[1]; x++)
{
if (!Map.Layers.Where(a => a.ID == layer).FirstOrDefault().CollisionHull.ContainsKey(new Point(x, y)))
for (int y = rangeY[0]; y < rangeY[1]; y++)
{
spawnableTiles.Add(new Point(x, y));
if (!Map.Layers.Where(a => a.ID == layer).FirstOrDefault().CollisionHull.ContainsKey(new Point(x, y)))
{
spawnableTiles.Add(new Point(x, y));
}
}
}
}
Random random = new Random();
for (int x = 0; x < amount; x++)
{
var index = random.Next(spawnableTiles.Count);
var enemyPos = spawnableTiles[index];
spawnableTiles.RemoveAt(index);
var newEnemy = new Enemy(directions[random.Next(directions.Count())], random.Next(30), TileToGridLocation(enemyPos));
if (enemyType == 1)
newEnemy = new EnemyTank(directions[random.Next(directions.Count())], random.Next(10), TileToGridLocation(enemyPos));
if(enemyType == 2)
newEnemy = new EnemySprint(directions[random.Next(directions.Count())], random.Next(30), TileToGridLocation(enemyPos));
TileEngine.Instance.GetScene().AddObject(newEnemy);
newEnemy.SetLayer("Objects");
newEnemy.CreateAndSetWeapon(new Fists());
Random random = new Random();
for (int x = 0; x < amount; x++)
{
var index = random.Next(spawnableTiles.Count);
var enemyPos = spawnableTiles[index];
spawnableTiles.RemoveAt(index);
var newEnemy = new Enemy(directions[random.Next(directions.Count())], random.Next(30), TileToGridLocation(enemyPos));
if (enemyType == 1)
newEnemy = new EnemyTank(directions[random.Next(directions.Count())], random.Next(10), TileToGridLocation(enemyPos));
if (enemyType == 2)
newEnemy = new EnemySprint(directions[random.Next(directions.Count())], random.Next(30), TileToGridLocation(enemyPos));
TileEngine.Instance.GetScene().AddObject(newEnemy);
newEnemy.SetLayer("Objects");
newEnemy.CreateAndSetWeapon(new Fists());
}
}
}

Expand Down
Binary file modified campus-crawl.teproj
Binary file not shown.

0 comments on commit 81287cc

Please sign in to comment.