void initializeEventCallbacks() { SpellSelectedEvent.RegisterListener(spellSelected); SpellUnSelectedEvent.RegisterListener(spellUnSelected); CastingLocationChangedEvent.RegisterListener(castingLocationChanged); StoppedCastingEvent.RegisterListener(stoppedCasting); }
void initializeEventCallbacks() { StartedCastingEvent.RegisterListener(castingStarted); StoppedCastingEvent.RegisterListener(castingStopped); SpellSelectedEvent.RegisterListener(SpellSelected); SpellCastEvent.RegisterListener(SpellCast); SpellUnSelectedEvent.RegisterListener(SpellUnselected); CastingProjectionDestroyedEvent.RegisterListener(CastingProjectionDestroyed); CastingProjectionCreatedEvent.RegisterListener(CastingProjectionCreated); CastingLocationChangedEvent.RegisterListener(CastingLocationChanged); }
void spellSelected(SpellSelectedEvent selectedSpell) { Debug.Log("UI canvas spell selected"); if (selectedSpell.selected) { //if (selectedSpell.spell.spellType == TempSpell.SpellType.PROJECTILE) //{ this.selectedSpell = selectedSpell.spell.spell; //} } else { this.selectedSpell = null; clearTexture(UITexture); TextureHelper.ApplyTexture(UITexture, SpriteRenderer, new Vector2(0.5f, 0.5f)); } }
// Update is called once per frame void Update() { //TODO: move this to an interaction controller or something, it doesnt need to be here, but it will do for now if (Input.GetMouseButtonDown(0)) { RaycastHit2D hi = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), new Vector3(0, 0, -1f)); if (hi.collider != null) { Spell_Icon_Script spellIcon = hi.transform.GetComponent <Spell_Icon_Script>(); Debug.Log("spell clicked"); if (spellIcon != selectedSpell) { if (selectedSpell != null) { //set the previously selected spell to unselected selectedSpell.Selected = false; } SpellSelectedEvent spellSelected = new SpellSelectedEvent(); spellSelected.spell = spellIcon; spellSelected.Description = "Spell selected callback firing"; spellSelected.FireEvent(); selectedSpell = spellIcon; spellIcon.Selected = true; } } } }
void SpellSelected(SpellSelectedEvent e) { staminaCost = e.spell.spell.spellParams.staminaCost; changed = true; }