private void Update() { hackingBar.fillAmount = (float)gateProgress / (float)gateMaxValue; if (!MatchInfo.eventIsOn) { if (timeBtwTheyCome <= 0 && gateProgress < gateMaxValue) { if (checkpointPassed) { EnemyTag[] areEnemiesAround = GameObject.FindObjectsOfType <EnemyTag>(); if (areEnemiesAround.Length == 0) { Debug.Log("The number of enemies is " + areEnemiesAround); if (gateWaveCounter >= 4) { gateWaveCounter = 0; } else { gateWaveCounter += 1; Debug.Log("Gate counter should have changed. It is = " + gateWaveCounter); } checkpointPassed = false; aRoutineHasStarted = false; } } else if (!checkpointPassed && !aRoutineHasStarted) { if (gateWaveCounter == 0) { SummonCheckpoint01(); Debug.Log("Will Summon Checkpoint01"); } else if (gateWaveCounter == 1) { SummonCheckpoint02(); Debug.Log("Will Summon Checkpoint02"); } else if (gateWaveCounter == 2) { SummonCheckpoint03(); Debug.Log("Will Summon Checkpoint03"); } else if (gateWaveCounter == 3) { SummonCheckpoint04(); Debug.Log("Will Summon Checkpoint04"); } else if (gateWaveCounter == 4) { FinalSummon(); Debug.Log("Will Summon Checkpoint05"); } Debug.Log("checkpoint is false"); } //Do magic timeBtwTheyCome = startTimeBtwTheyCome; Debug.Log("TimeBtwTheyCome has restarted"); } else if (gateProgress >= gateMaxValue && !openGateCalled) { EnemyTag[] areEnemiesAround = GameObject.FindObjectsOfType <EnemyTag>(); if (areEnemiesAround.Length == 0) { gateProgress = gateMaxValue; matchInfo.OpeningaGate(); timeBtwTheyCome = 7; openGateCalled = true; } else { Debug.Log("Attempting to Open this gate but enemies around : " + areEnemiesAround[0].name); } timeBtwTheyCome = startTimeBtwTheyCome; } else if (gateProgress >= gateMaxValue) { Debug.Log("openGateCalled : " + openGateCalled); } else { timeBtwTheyCome -= Time.deltaTime; } } else if (MatchInfo.eventIsOn) { StopAllCoroutines(); } }