/// <summary> /// Awake is called when the script instance is being loaded. /// </summary> void Awake() { DontDestroyOnLoad(this); if (Instance == null) { Instance = this; } else { Destroy(gameObject); } currentState = GameState.OVERWORLD; stage = new RPGun_FightStage(); stage.enemiesToSpawn = new List <GameObject>(); stage.enemiesToSpawn.Add(fightEnemyPrefab); }
void Awake() { enemies = new Dictionary <Guid, RPGun_Enemy>(); manager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <RPGun_GameManager>(); stage = manager.GetStage(); var enemySpawnPointObjects = GameObject.FindGameObjectsWithTag("EnemySpawnPoint"); enemySpawnPoints = new List <Transform>(); foreach (GameObject esp in enemySpawnPointObjects) { enemySpawnPoints.Add(esp.transform); } foreach (GameObject enemy in stage.enemiesToSpawn) { GameObject newObject = GameObject.Instantiate(enemy, enemySpawnPoints[0].position, enemySpawnPoints[0].rotation); RPGun_Enemy newEnemy = newObject.GetComponent <RPGun_Enemy>(); newEnemy.SetId(AddEnemy(newEnemy)); newEnemy.SetFightManager(this); } }