public void AddPower(string powerName) { if (myPowers.Count > 0) { myPowers[myPowers.Count - 1].isReady = false; } Debug.Log(powerName); SuperPowerBase spb = gameObject.AddComponent(Type.GetType(powerName)) as SuperPowerBase; spb.isReady = true; myPowers.Add(spb); }
internal void Update() { //Try to cleanup oldest power if (myPowers.Count > 0) { SuperPowerBase p = myPowers[0]; if (!p.isActive && !p.isReady) { myPowers.RemoveAt(0); Destroy(p); //Debug.Log("Cleaning"); } } }
public void AddPower(string powerName) { if (myPowers.Count > 0) { myPowers[myPowers.Count - 1].isReady = false; } //Debug.Log(powerName); SuperPowerBase spb = gameObject.AddComponent(Type.GetType(powerName)) as SuperPowerBase; spb.isReady = true; myPowers.Add(spb); if (!powerText) { GameObject powerUI = GameObject.FindGameObjectWithTag("PowerUp"); powerText = powerUI.transform.GetChild(playerIndex).GetComponent<Text>(); } powerText.text = powerName; }