public void SpawnWave() { GameConditionsManager.countOfKilledZombiesInCurrentWave = 0; GameConditionsManager.currentWave++; EventController.InvokeEvent(Consts.Events.events.updateWaveUI); if (!isGameStarted) { EventController.InvokeEvent(Consts.Events.events.startGame); isGameStarted = true; } difficulty = DifficultyController.CalculateDifficulty(GameConditionsManager.currentWave); //spawnCount = GameConditionsManager.currentWave * difficulty * 2; //Debug.Log("Calculate!"); spawnCount = GameConditionsManager.currentWave * 4; if (DifficultyController.isMaxim) { Debug.Log("MaximLvl"); spawnCount *= Consts.Values.Balance.RisingCoef; } else if (DifficultyController.isMinim) { Debug.Log("MinLvl"); spawnCount /= Consts.Values.Balance.loweringCoef; } Debug.Log("spawnCount = " + spawnCount); int tmpCount = (int)(spawnCount / 4); if (tmpCount < 1) { tmpCount = 1; } zombiesAliveCount = tmpCount * 4; for (int i = 0; i < tmpCount; i++) { Vector3 spawnPos = new Vector3(-tmpCount + i * 2, 1f, Player.transform.position.z + Consts.Values.Zombie.zombieSpawnDistance); if (i % 2 == 0) { spawnPos.z *= 2f; } int tmp = Random.Range(1, Consts.Values.Zombie.slowZombieSpawnRate + 1); if (tmp == Consts.Values.Zombie.slowZombieSpawnRate && DifficultyController.isMaxim) { // Instantiate(slowZombie, spawnPos, Quaternion.identity); GameObject tmpGO = UnityPoolManager.Instance.Pop <UnityPoolObject>(4, true).gameObject; tmpGO.transform.SetPositionAndRotation(spawnPos, Quaternion.identity); // tmpGO.SetActive(true); GameConditionsManager.zombies.Add(tmpGO.GetComponent <UnityPoolObject>()); } else { // Instantiate(fastZombie, spawnPos, Quaternion.identity); GameObject tmpGO = UnityPoolManager.Instance.Pop <UnityPoolObject>(3, true).gameObject; tmpGO.transform.SetPositionAndRotation(spawnPos, Quaternion.identity); // tmpGO.SetActive(true); GameConditionsManager.zombies.Add(tmpGO.GetComponent <UnityPoolObject>()); } } for (int i = 0; i < tmpCount; i++) { Vector3 spawnPos = new Vector3(-tmpCount + i * 2, 1f, Player.transform.position.z - Consts.Values.Zombie.zombieSpawnDistance); if (i % 2 == 0) { spawnPos.z *= 2f; } int tmp = Random.Range(1, Consts.Values.Zombie.slowZombieSpawnRate + 1); if (tmp == Consts.Values.Zombie.slowZombieSpawnRate) { GameObject tmpGO = UnityPoolManager.Instance.Pop <UnityPoolObject>(4, true).gameObject; tmpGO.transform.SetPositionAndRotation(spawnPos, Quaternion.identity); // tmpGO.SetActive(true); GameConditionsManager.zombies.Add(tmpGO.GetComponent <UnityPoolObject>()); } else { GameObject tmpGO = UnityPoolManager.Instance.Pop <UnityPoolObject>(3, true).gameObject; tmpGO.transform.SetPositionAndRotation(spawnPos, Quaternion.identity); GameConditionsManager.zombies.Add(tmpGO.GetComponent <UnityPoolObject>()); } } for (int i = 0; i < tmpCount; i++) { Vector3 spawnPos = new Vector3(Player.transform.position.x - Consts.Values.Zombie.zombieSpawnDistance, 1f, Player.transform.position.z - tmpCount + i * 2); if (i % 2 == 0) { spawnPos.x *= 2f; } int tmp = Random.Range(1, Consts.Values.Zombie.slowZombieSpawnRate + 1); if (tmp == Consts.Values.Zombie.slowZombieSpawnRate) { GameObject tmpGO = UnityPoolManager.Instance.Pop <UnityPoolObject>(4, true).gameObject; tmpGO.transform.SetPositionAndRotation(spawnPos, Quaternion.identity); // tmpGO.SetActive(true); GameConditionsManager.zombies.Add(tmpGO.GetComponent <UnityPoolObject>()); } else { GameObject tmpGO = UnityPoolManager.Instance.Pop <UnityPoolObject>(3, true).gameObject; tmpGO.transform.SetPositionAndRotation(spawnPos, Quaternion.identity); // tmpGO.SetActive(true); GameConditionsManager.zombies.Add(tmpGO.GetComponent <UnityPoolObject>()); } } for (int i = 0; i < tmpCount; i++) { Vector3 spawnPos = new Vector3(Player.transform.position.x + Consts.Values.Zombie.zombieSpawnDistance, 1f, Player.transform.position.z - tmpCount + i * 2); if (i % 2 == 0) { spawnPos.x *= 2f; } int tmp = Random.Range(1, Consts.Values.Zombie.slowZombieSpawnRate + 1); if (tmp == Consts.Values.Zombie.slowZombieSpawnRate) { GameObject tmpGO = UnityPoolManager.Instance.Pop <UnityPoolObject>(4, true).gameObject; tmpGO.transform.SetPositionAndRotation(spawnPos, Quaternion.identity); GameConditionsManager.zombies.Add(tmpGO.GetComponent <UnityPoolObject>()); // tmpGO.SetActive(true); } else { GameObject tmpGO = UnityPoolManager.Instance.Pop <UnityPoolObject>(3, true).gameObject; tmpGO.transform.SetPositionAndRotation(spawnPos, Quaternion.identity); // tmpGO.SetActive(true); GameConditionsManager.zombies.Add(tmpGO.GetComponent <UnityPoolObject>()); } } }