/// <summary> /// Gets called when a new Spell is generated /// </summary> /// <param name="sl">the generated spell</param> /// public void OnSpellGenerated(SpellLogic sl) { currentSpell = sl; if (sl.Spelltype == SpellType.Charged) { // Set IsCharging() charge = true; if (SpellChargingStarting != null) { SpellChargingStarting(this, new EventArgs()); } StartCoroutine("Charge"); } else if (sl.Spelltype == SpellType.Continuous) { // Set Animation based on the Spellform like Spray. If the number of animations grows, we can add a Dictionary that contains Delegates, so it also has constant time. continuous = true; sl.gameObject.SetActive(true); if (SpellContinuousStarting != null) { SpellContinuousStarting(this, new EventArgs()); } StartCoroutine("Continuous"); } }
private void RaiseNewSpellGenerated(SpellLogic sl) { if(SpellGenerated != null) { SpellGenerated(sl); } }
// Unoptimized. void Update() { if (Input.anyKey) { if (Input.GetKeyDown(KeyCode.Q)) { stack.Push(new Element(ElementType.Q, ElementType.A, 1, default(Color))); } if (Input.GetKeyDown(KeyCode.W)) { stack.Push(new Element(ElementType.W, ElementType.S, 2, default(Color))); } if (Input.GetKeyDown(KeyCode.E)) { stack.Push(new Element(ElementType.E, ElementType.D, 3, default(Color))); } if (Input.GetKeyDown(KeyCode.R)) { stack.Push(new Element(ElementType.R, ElementType.F, 4, default(Color))); } if (Input.GetKeyDown(KeyCode.A)) { stack.Push(new Element(ElementType.A, ElementType.Q, 5, default(Color))); } if (Input.GetKeyDown(KeyCode.S)) { stack.Push(new Element(ElementType.S, ElementType.W, 6, default(Color))); } if (Input.GetKeyDown(KeyCode.D)) { stack.Push(new Element(ElementType.D, ElementType.E, 7, default(Color))); } if (Input.GetKeyDown(KeyCode.F)) { stack.Push(new Element(ElementType.F, ElementType.R, 8, default(Color))); } if (Input.GetKeyDown(KeyCode.LeftShift)) { stack.PopAll(); } } if (stack.AnyElementOnStack && currentSpell == null) { if (Input.GetMouseButtonDown(1)) { currentSpell = SpellGenerator.Instance.GenerateSpell(stack.GetStack(), false, StaffPosition); handler.OnSpellGenerated(currentSpell); stack.PopAll(); } else if (Input.GetMouseButtonDown(2)) { currentSpell = SpellGenerator.Instance.GenerateSpell(stack.GetStack(), true, StaffPosition); handler.OnSpellGenerated(currentSpell); stack.PopAll(); } } if(Input.GetMouseButtonUp(1) || Input.GetMouseButtonUp(2)) { handler.OnButtonUp(); currentSpell = null; } }