- Home /
while loop does not pick up again on continue
Hey everyone,
I've created a script that allows a player to continue after watching an ad. My Spawn Coroutines are based on a "while loop" everything on continue works great EXCEPT the spawn routines do not pick back up, they remain stuck where ever it was when the player died. I'll post 1 of the spawn routine while loops, the command that calls the spawn routines in the first place and the continue button script itself. I don't see why this wouldn't properly continue, so I'm hoping a fresh set of eyes will help.
here is the spawn routine itself
public IEnumerator MerchantSpawnRoutine() {
while (GameManager.gameManager.gameOver == false)
{
if (UIManager.uIManager.pauseMenuVisible == true)
{
yield return null;
}
else
{
yield return new WaitForSeconds(Random.Range(1, 3));
if (UIManager.uIManager.score >= 0)
{
Instantiate(_hardMerchantTop, new Vector3(Random.Range(-1.5f, 1.2f), 5.6f, 0), Quaternion.identity);
}
}
}
}
here is the Game Manager
public bool gameOver = false;
private void Start() {
Instantiate(player);
AudioSource.PlayClipAtPoint(_ninjaStartSFX, transform.position);
gameOver = false;
SpawnManager.spawnManager.StartSpawnRoutines();
}
and here is the continue script (I won't post all of it just the part for the ad being watched
public void ShowAd() {
ShowAdCallbacks options = new ShowAdCallbacks();
options.finishCallback = HandleShowResult;
ShowAdPlacementContent ad = Monetization.GetPlacementContent(placementID) as ShowAdPlacementContent;
ad.Show(options);
}
void HandleShowResult (ShowResult result)
{
if (result == ShowResult.Finished)
{
UIManager.uIManager.Continue();
Player.ninja.lives = 3;
UIManager.uIManager.UpdateLives(Player.ninja.lives);
}
THANKS!