void Awake() { if (factoryInstance != null) { Destroy(gameObject); return; } factoryInstance = this; DontDestroyOnLoad(gameObject); }
private void InitWaveData() { Factory.AgentFactory af = GameObject.FindWithTag(Constants.FactoryTag).GetComponent <Factory.AgentFactory>(); amount = wave.amount; interval = wave.interval; minionHealth = wave.health; minions = new GameObject[amount]; for (int i = 0; i < amount; i++) { minions[i] = af.CreateMinion(wave.type, Vector3.zero, minionHealth, wave.attackRange); minions[i].SetActive(false); minions[i].GetComponent <AgentController>().weapon.SetDamage(wave.damage); //set health HealthController ht = minions[i].transform.Find("HealthController").gameObject.GetComponent <HealthController>(); ht.Init(wave.health); } }