public void Init() { this.name = spell.name; //this.icon = spell.icon; this.manaCost = spell.manaCost; this.magnitude = spell.magnitude; this.duration = spell.duration; this.fireType = spell.fireType; AudioSource[] audioSources = GameObject.Find("Spells").GetComponents <AudioSource>(); this.castSound = audioSources[0]; this.castSound.clip = spell.castSound; this.castSound.clip = spell.castSound; this.targetingType = spell.targetingType; switch (fireType) { case FireType.Instant: this.cooldown = ((InstantSpell)spell).cooldown; break; case FireType.Charge: this.cooldown = ((ChargeSpell)spell).cooldown; this.chargeTime = ((ChargeSpell)spell).chargeTime; this.chargeSound = audioSources[1]; this.chargeSound.clip = ((ChargeSpell)spell).chargeSound; break; case FireType.Stream: this.frequency = ((StreamSpell)spell).frequency; break; default: try { throw new System.Exception("Unidentified FireType or Null"); } catch (System.Exception exception) { ErrorEvent.Trace(exception); } break; } spell.Init(); initialized = true; }
// Update is called once per frame void Update() { SpellShift(); CheckSpellChange(); CheckInitialization(); switch (fireType) { case FireType.Instant: FireWithCooldown(); break; case FireType.Charge: FireWithCharge(); break; case FireType.Stream: FireWithStream(); break; default: try { throw new System.Exception("Unidentified FireType or Null"); } catch (System.Exception exception) { ErrorEvent.Trace(exception); } break; } lastSpell = spell; }