- Home /
Rounds reset
At the end of each round in my game, I reset all the spawn point and increase the rounds count by 1 and the total rounds by 1. At round 5 I load a boss, once the boss is dead I reset the spawn point, increase the total rounds by 1 and reset the rounds count 1.
On the rounds count from 1 - 4 it works perfectly, after the boss round though, it seems to just keep increasing and I'm struggling to figure out why.
Here's the code I have in the update function:
void Update ()
{
//check all spawns are in active
for(int i = 0; i < 8; i++)
{
if(redSpawnPoints[i].GetComponent<redEnemySpawn>().isComplete == true)
{
roundComplete = true;
break;
}
else
{
roundComplete = false;
break;
}
if(greenSpawnPoints[i].GetComponent<greenEnemySpawn>().isComplete == true)
{
roundComplete = true;
break;
}
else
{
roundComplete = false;
break;
}
}
if(redBossDEAD == true)
{
roundComplete = true;
}
if(aliveCount == 0)
{
if(roundComplete == true)
{
roundComplete = false;
print ("ROUND COMPLETE!!!!!!!!!!!");
if(roundsCount < 5)
{
roundsCount +=1;
print ("rounds count = " + roundsCount);
reset ();
}
else if(roundsCount == 5)
{
//check to see if red boss level is complete
if(redBossDEAD == false)// && redBossDEAD != true)
{
//if not make the spawn active
redBossSpawn.GetComponent<redBossSpawn>().isActive = true;
for(int i = 0; i < 8; i++)
{
redSpawnPoints[i].GetComponent<redEnemySpawn>().isComplete = true;
}
}
else
{
roundsCount = 1;
print ("rounds count = " + roundsCount);
reset ();
}
}
totalRounds +=1;
print ("total rounds = " + totalRounds);
}
}
}
And here the code for the reset() function:
void reset()
{
for(int i = 0; i < redSpawnPoints.Length; i++)
{
redSpawnPoints[i].GetComponent<redEnemySpawn>().count = 0;
redSpawnPoints[i].GetComponent<redEnemySpawn>().isComplete = false;
}
if(totalRounds >5)
{
for(int j = 0; j < greenSpawnPoints.Length; j++)
{
greenSpawnPoints[j].GetComponent<greenEnemySpawn>().count = 0;
greenSpawnPoints[j].GetComponent<greenEnemySpawn>().isComplete = false;
}
}
}
Like I said, I'm struggling to figure out what is causing this, I've even tested it without the boss even being there and just reset as normal but for some reason it still keeps increasing. Any ideas?
By "seems to keep increasing", do you mean the round count goes 1,2,3,4,5,6,7...?
yes to both, it does stop though at around 500+ on the Total rounds, and carries on the game.
Your answer
![](https://koobas.hobune.stream/wayback/20220613111928im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Image processing: reseting image problems 1 Answer
Intensifying rate over time... 1 Answer
reset level on collision 3 Answers
Rounds increasing exteremely fast 1 Answer