// Update is called once per frame void Update() { timer += Time.deltaTime; timer2 -= Time.deltaTime; switch ((int)timer) { case 15: maxCountCreature = 3; timeToSpawn = 7f; break; case 30: maxCountCreature = 5; timeToSpawn = 6.5f; break; case 80: maxCountCreature = 8; timeToSpawn = 6f; break; case 150: maxCountCreature = 12; timeToSpawn = 5f; break; case 220: maxCountCreature = 16; timeToSpawn = 4f; break; case 300: maxCountCreature = 17; timeToSpawn = 3f; break; case 380: maxCountCreature = 18; timeToSpawn = 2f; break; case 470: maxCountCreature = 19; timeToSpawn = 1.1f; break; case 570: maxCountCreature = 21; timeToSpawn = 0.9f; break; case 680: maxCountCreature = 22; timeToSpawn = 0.7f; break; case 840: maxCountCreature = 23; timeToSpawn = 0.4f; break; } if (countCreature < maxCountCreature && !portal.isStarted && !portal.ended && hit && timer2 < 0) { if ((int)timer > 45 && Random.Range(0, 3) == 2) { spawner.DoSpawn(); } if ((int)timer > 80 && Random.Range(1, 4) == 3) { spawner.DoSpawn(); spawner.DoSpawn(); } spawner.DoSpawn(); timer2 = timeToSpawn; } if (countCreature > 0 && portal.ended) { portal.NPCallive = countCreature; } }