void Awake() { if (this.slot == null) { this.slot = this.GetComponent <UISpellSlot>(); } }
public void OnUnassignSpellSlot(UISpellSlot slot) { if (this.enabled && this.m_TargetGraphic != null) { this.m_TargetGraphic.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, this.m_UnassignedSize.x); this.m_TargetGraphic.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, this.m_UnassignedSize.y); } }
public void OnSpellClick(UISpellSlot slot) { // Make sure we have the cast bar component and the slot is assigned if (this.m_CastBar == null || !slot.IsAssigned()) return; // Check if we are already casting if (this.m_CastBar.IsCasting) return; // Get the spell info from the slot UISpellInfo spellInfo = slot.GetSpellInfo(); // Make sure we have spell info if (spellInfo == null) return; // Check if we are on cooldown if (spellInfo.Cooldown > 0f && slot.cooldownComponent != null && slot.cooldownComponent.IsOnCooldown) return; // Check if the spell is not insta cast if (!spellInfo.Flags.Has(UISpellInfo_Flags.InstantCast)) { // Start casting this.m_CastBar.StartCasting(spellInfo, spellInfo.CastTime, Time.time + spellInfo.CastTime); } // Handle cooldown just for the demonstration if (slot.cooldownComponent != null && spellInfo.Cooldown > 0f) { // Start the cooldown on all the slots with the specified spell id foreach (UISpellSlot s in UISpellSlot.GetSlots()) { if (s.IsAssigned() && s.GetSpellInfo() != null && s.cooldownComponent != null) { // If the slot IDs match if (s.GetSpellInfo().ID == spellInfo.ID) { // Start the cooldown s.cooldownComponent.StartCooldown(spellInfo.ID, spellInfo.Cooldown); } } } } }
void Awake() { if (this.slot == null) this.slot = this.GetComponent<UISpellSlot>(); }
/// <summary> /// Raises the assign spell event. /// </summary> /// <param name="spellSlot">The spell slot.</param> public void OnAssignSpell(UISpellSlot spellSlot) { // Return if the slot is not valid if (spellSlot == null || spellSlot.GetSpellInfo() == null) return; // Get the spell info UISpellInfo spellInfo = spellSlot.GetSpellInfo(); // Check if this spell still has cooldown if (spellCooldowns.ContainsKey(spellInfo.ID)) { float cooldownTill = spellCooldowns[spellInfo.ID].endTime; // Check if the cooldown isnt expired if (cooldownTill > Time.time) { // Resume the cooldown this.ResumeCooldown(spellInfo.ID); } else { // Cooldown already expired, remove the record spellCooldowns.Remove(spellInfo.ID); } } }
/// <summary> /// Raises the unassign event. /// </summary> public void OnUnassignSpell(UISpellSlot spellSlot) { this.InterruptCooldown(); }