Exemplo n.º 1
0
    /// <summary>
    /// Get the points and spawn enemies in it
    /// Then add the enemy to the spawned enemies list
    /// </summary>
    void Spawn()
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }

        List <TDS_SpawningInformation> _spawnInformations = pointsManager.GetSpawningInformations(waveNumber);

        if (_spawnInformations.Count == 0)
        {
            waveNumber++;
            OnNextWave?.Invoke();
        }
        for (int i = 0; i < _spawnInformations.Count; i++)
        {
            TDS_Enemy _enemy = PhotonNetwork.Instantiate(((EnemyName)_spawnInformations[i].PrefabId).ToString(), _spawnInformations[i].SpawnPosition + Vector3.up, Quaternion.identity, 0).GetComponent <TDS_Enemy>();
            if (enemyCanvas && (lifeBarName != string.Empty))
            {
                Vector3       _pos      = new Vector3(_enemy.transform.position.x, .1f, _enemy.transform.position.z);
                Quaternion    _rotation = Quaternion.Euler(90, 0, 0);
                TDS_FilledBar _bar      = PhotonNetwork.Instantiate(lifeBarName, _pos, _rotation, 0).GetComponent <TDS_FilledBar>();
                _bar.SetCanvas(enemyCanvas);
                _enemy.SetLifeBar(_bar);
            }
            _enemy.SetOwner(this);
            spawnedEnemies.Add(_enemy);
        }
    }
Exemplo n.º 2
0
 /// <summary>
 /// SpawnEnemies using Enemies Info
 /// Spawn at a position, with a state, etc...
 /// </summary>
 /// <param name="_enemiesInfo"></param>
 public void SpawnEnemiesUsingInfos(List <TDS_EnemyInfo> _enemiesInfo)
 {
     foreach (TDS_EnemyInfo _info in _enemiesInfo)
     {
         TDS_Enemy _enemy = PhotonNetwork.Instantiate(((EnemyName)_info.EnemyType).ToString(), _info.EnemyPosition, Quaternion.identity, 0).GetComponent <TDS_Enemy>();
         _enemy.SetOwner(this);
         spawnedEnemies.Add(_enemy);
     }
 }