public IEnumerator SwitchWeakness(float p_TimeToWait) { for (;;) { Weakness = (Weakness == eCurrentWeakness.TYPEA) ? eCurrentWeakness.TYPEB : eCurrentWeakness.TYPEA; //if (gameObject.GetComponent<Renderer>() != null) gameObject.GetComponent<Renderer>().material = SetMaterial(); SwapActiveColor(); yield return(new WaitForSeconds(p_TimeToWait)); } }
//Old weakness switch function. Relies on randomness IEnumerator SwitchWeaknessOLD(int p_Randomness = 10) { for (;;) { int randomValue = Random.Range(1, 100); if (randomValue % p_Randomness == 0) { Weakness = (Weakness == eCurrentWeakness.TYPEA) ? eCurrentWeakness.TYPEB : eCurrentWeakness.TYPEA; if (gameObject.GetComponent <Renderer>() != null) { gameObject.GetComponent <Renderer>().material = (Weakness == eCurrentWeakness.TYPEA) ? TypeAMaterial : TypeBMaterial; } } yield return(new WaitForSeconds(0.5f)); } }