void CycleSpellForward() { if (!isCasting && !isSwitching) { isSwitching = true; currentSpell.UnEquip(this); int currentIndex = acquiredSpells.IndexOf(currentSpell); if (currentIndex == acquiredSpells.Count - 1) { spellIndex = 0; currentSpell = acquiredSpells[0]; } else { spellIndex++; currentSpell = acquiredSpells[spellIndex]; } currentSpell.Equip(this); } }
// init private void Awake() { playerInput = GetComponent <PlayerInput>(); fpsController = GetComponent <FirstPersonDrifter>(); foreach (Transform child in spellContainer) { ISpell spell = child.GetComponent <ISpell>(); // Ignore transforms that don't have spells on them, but we will warn if (spell != null) { acquiredSpells.Add(child.GetComponent <ISpell>()); child.gameObject.SetActive(false); } else { Debug.LogWarning(child.name + " has no spell attached!"); } } currentSpell = acquiredSpells[0]; currentSpell.Equip(this); }