Пример #1
0
        public void NetworkSpawn(EnemyPopulationObserver populationObserver, float seedX)
        {
            int index = GetRandomIndex();

            float x   = GetRandomPosX(seedX);
            float y   = _spawnArea.CalculateY(x, _offsetY[index]);
            var   pos = new Vector3(x, y, 0.0f);

            var enemyObj = PhotonNetwork.Instantiate("Prefabs/Enemy/" + _spawnEnemyNames[index], pos, Quaternion.identity, 0);
            var enemy    = enemyObj.GetComponent <Enemy>();

            enemy.AttachPopulationObserver(populationObserver);
        }
Пример #2
0
        public void NetworkSpawn(EnemyPopulationObserver populationObserver, float seedX)
        {
            int index = GetRandomIndex();

            if (!_spawnArea.IsInRange(seedX))
            {
                Debug.LogError("seedX is out of range");
                seedX = _spawnArea.GetRandomX();
            }

            float x   = GetRandomPosX(seedX);
            float y   = _spawnArea.CalculateY(x, _offsetY[index]);
            var   pos = new Vector3(x, y, 0.0f);

            var enemyObj = PhotonNetwork.Instantiate("Prefabs/Enemy/" + _spawnEnemyNames[index], pos, Quaternion.identity, 0);
            var enemy    = enemyObj.GetComponent <Enemy>();

            enemy.AttachPopulationObserver(populationObserver);
            enemy.AttachSpawner(this);
        }
Пример #3
0
 public void AttachPopulationObserver(EnemyPopulationObserver populationObserver)
 {
     PopulationObserver = populationObserver;
 }