public void SetInitData(EnemyWaveData.EnemyWave wave, Transform topRight, Transform bottomLeft, SwarmEnemyGroup swarmEnemyGroup) { _waveData = wave; _maxScale = wave.WormholeSize; _currentScale = 0.0f; _spawnedEnemy = false; _objectPoolManager = ServiceLocator.Get <ObjectPoolManager>(); _topright = topRight; _bottomLeft = bottomLeft; _swarmEnemyGroup = swarmEnemyGroup; }
private void SpawnWave(EnemyWaveData.EnemyWave wave) { // (Optional) split the number of enemies into multiple wormholes for each wave. // 1. Get a new wormhole gameobject from the object pool. // 2. Reset the new wormhole and pass in the curret wave data. // 3. Pick a random spot between TopRight and BottomLeft Transforms and position the wormhole at that spot. // 4. Activate the new wormhole float x; float y; x = UnityEngine.Random.Range(BottomLeft.position.x + 3.0f, TopRight.position.x - 3.0f); y = UnityEngine.Random.Range(TopRight.position.y - 3.0f, BottomLeft.position.y + 3.0f); GameObject _wormhole = _objectPoolManager.GetObjectFromPool("Wormhole"); _wormhole.gameObject.GetComponent <Wormhole>().SetInitData(wave, TopRight, BottomLeft, _swarmEnemyGroup); _wormhole.transform.position = new Vector3(x, y, _wormhole.transform.position.z); //_wormhole = Instantiate(_wormhole, new Vector3(x, y, 0.0f), Quaternion.identity); _wormhole.SetActive(true); }