public void Spawn() { if (GameManager.Instance.getStatus() != GameManager.STATE.ONGOING) { return; } /* * if (GameController.Instance.IsGameOver) * { * * return; * }*/ if (_limitToMax && _spawns >= _maxSpawns) { CancelInvoke("Spawn"); _enabled = false; return; } if (_currentInScene >= _maxInScene) { //Debug.Log ("stop spawning!"); return; } // Determine spawn position Vector3 spawnPosition = new Vector3(); if (_spawnAtLocation) { //spawnPosition = new Vector3(transform.position.x,transform.position.y - 6,transform.position.z); spawnPosition = _startLocation.position; } else { //spawnPosition.x = Random.Range(-_spawnBounds.x, _spawnBounds.x); //spawnPosition.z = Random.Range(-_spawnBounds.y, _spawnBounds.y); //spawnPosition.y = 1.1f; } GameObject spawnedObject = null; if (_spawnType == SpawnType.Enemy) { float random = Random.value; float cumulativeProb = 0; foreach (EnemySpawnSettings setting in _spawnSettings) { cumulativeProb += setting.Probability; if (random <= cumulativeProb) { // Spawn! int spawnAmount = setting.IsBurstSpawn ? setting.BurstAmount : 1; Sequence spawnSequence = DOTween.Sequence(); spawnSequence.AppendCallback(() => { BaseEnemy _baseEnemy = EnemyPool.Instance.SpawnEnemy(new Vector3(), setting.GetRandomSpawnEnemyType()); //BaseEnemy(_baseEnemy); spawnedObject = _baseEnemy.gameObject; _baseEnemy.setHealth(healthMultiplier); if (setting.AlterEnemySpeed) { //_baseEnemy.spee = setting.EnemySpeed; } //virezEnemy.AddOnKillCallback(DecreaseOnSceneCount); _baseEnemy.AddOnKillCallback(DecreaseOnSceneCount); spawnedObject.transform.position = spawnPosition; _spawns++; _currentInScene++; enemy.Add(_baseEnemy); Notifier.GetComponentInChildren <NotificationManager> ().NotifyText(spawnedObject.name + " spawned"); }).AppendInterval(setting.BurstInterval).SetLoops(spawnAmount); break; } } } else { Instantiate(_spawnObject, new Vector3(), Quaternion.identity); } }