// Set one effect on public void RandomEffect() { int rngEffectId = Random.Range(0, Effects.Count); StartDistortion(); while (true) { rngEffectId = Random.Range(0, Effects.Count); if (Effects.IndexOf(CurrentEffect) == rngEffectId) { var nextID = Effects.IndexOf(CurrentEffect) + 1; rngEffectId = nextID == Effects.Count ? 0 : nextID; } if (Random.value < Effects[rngEffectId].chance) { break; } } Debug.Log(Effects[rngEffectId].chance); CurrentEffect = Effects[rngEffectId]; CurrentEffect.StartEffect(); StartCoroutine(EffectWai(randomInterval / 2)); }
public void NextPickUpEffect() { int pickUpCount = Random.Range(0, PickUpEffects.Count - 1); CurrentPickupEffect = PickUpEffects[pickUpCount]; CurrentPickupEffect.StartEffect(); StartCoroutine(PickUpEffectWai(5)); }
public void NextEffect() { if (CurrentEffect != null) { CurrentEffect.EndEffect(); var nextID = Effects.IndexOf(CurrentEffect) + 1; Debug.Log(nextID); EffectId = nextID == Effects.Count ? 0 : nextID; } CurrentEffect = Effects[EffectId]; CurrentEffect.StartEffect(); }