/// <summary> /// Called when an ability has just been cast by the local player's Champion. /// </summary> /// <param name="ability">The Ability that was just cast</param> /// <param name="cooldown">The cooldown of the ability</param> public void OnAbilityCasted(AbilityHandler.Abilities ability, float cooldown) { switch (ability) { case AbilityHandler.Abilities.Q: cooldownQ = cooldownQDuration = cooldown; break; case AbilityHandler.Abilities.W: cooldownW = cooldownWDuration = cooldown; break; case AbilityHandler.Abilities.E: cooldownE = cooldownEDuration = cooldown; break; case AbilityHandler.Abilities.R: cooldownR = cooldownRDuration = cooldown; break; case AbilityHandler.Abilities.F: cooldownF = cooldownFDuration = cooldown; break; case AbilityHandler.Abilities.G: cooldownG = cooldownGDuration = cooldown; break; case AbilityHandler.Abilities.B: cooldownB = cooldownBDuration = cooldown; break; } }
// Called when the upgrade button for an ability is clicked void UpgradeButtonClicked(AbilityHandler.Abilities abilityKey) { if (onUpgradeButtonClicked != null) { onUpgradeButtonClicked(abilityKey); } }
/// <summary> /// Upgrades the level of an ability when called. /// </summary> /// <param name="abilityKey">The ability key (Q,W,E,R) to be upgraded</param> public void UpgradeAbility(AbilityHandler.Abilities abilityKey) { switch (abilityKey) { case AbilityHandler.Abilities.Q: qLevel++; break; case AbilityHandler.Abilities.W: wLevel++; break; case AbilityHandler.Abilities.E: eLevel++; break; case AbilityHandler.Abilities.R: rLevel++; break; } }
/// <summary> /// Called when a champion's abilities are upgraded to update the tooltip UI. /// </summary> /// <param name="hotkey">The keycode for the ability (Q,W,E..)</param> /// <param name="ability">The Ability attempting to be cast</param> /// <param name="champion">The Champion attempting to cast the ability</param> /// <returns> /// True if the user can cast a specific ability; false if not. /// </returns> public bool CanCastAbility(AbilityHandler.Abilities hotkey, Ability ability, Champion champion) { // Conditions in which the return is instantly false if (champion.movementSpeed == 0) { return(false); } if (gameEnded) { return(false); } if (abilityHandler.GetAbilityLevel(champion, ability) == 0) { return(false); } if (champion.mana < ability.cost) { return(false); } if (ChatHandler.Instance.inputField.gameObject.activeSelf) { return(false); } // Return whether the cooldown for the ability has ended switch (hotkey) { case AbilityHandler.Abilities.Q: return(cooldownQ == 0f); case AbilityHandler.Abilities.W: return(cooldownW == 0f); case AbilityHandler.Abilities.E: return(cooldownE == 0f); case AbilityHandler.Abilities.R: return(cooldownR == 0f); case AbilityHandler.Abilities.F: return(cooldownF == 0f); case AbilityHandler.Abilities.G: return(cooldownG == 0f); case AbilityHandler.Abilities.B: return(cooldownB == 0f); } // Something went wrong, don't cast whatever it is return(false); }
// Called when an upgrade button is clicked by the player void OnUpgradeButtonClicked(AbilityHandler.Abilities abilityKey) { unclaimedUpgrades = Mathf.Max(unclaimedUpgrades - 1, 0); foreach (Ability ability in champion.abilities) { if (ability.abilityKey == abilityKey) { champion.UpgradeAbility(abilityKey); // Tell other scripts we upgraded if (onChampionUpgradeAbility != null) { onChampionUpgradeAbility(photonView.owner, champion, unclaimedUpgrades); } break; } } }