//Coroutine used for ability cooldown IEnumerator CooldownHandler(AbilityTest ability) { ARKLogger.LogMessage(eLogCategory.Combat, eLogLevel.System, ability.animationTag + " on " + ability.cooldown.ToString()+" second cooldown"); ability.offCooldown = false; yield return new WaitForSeconds(ability.cooldown); ability.offCooldown = true; ARKLogger.LogMessage(eLogCategory.Combat, eLogLevel.System, ability.animationTag + " is off cooldown"); }
public void PlayerCastedAbility(AbilityTest castedAbility) { if (castedAbility.offCooldown) { HandleCooldown(castedAbility); HandleEnergy(castedAbility.energy); corruptManager.ModifyMeter(castedAbility); HandleCorruption(castedAbility.cast); } }
public void ModifyMeter(AbilityTest castedAbil) { if (castedAbil.cast == eAbilityCast.Light) { corruptionMeter += castedAbil.corruption; stageCorLevel += castedAbil.corruption; } else { corruptionMeter -= castedAbil.corruption; stageCorLevel += castedAbil.corruption; } if (corruptionMeter > 100) corruptionMeter = 100; if (corruptionMeter < 0) corruptionMeter = 0; if (corruptionMeter + corruptionLevel >= corruptionThresh) corrupted = true; }
//Casts players ability private void CastAbility(AbilityTest ability) { //Check to see ability is off cooldown if (ability.offCooldown && (player.playerHUD.energySlider.value - ability.energy) > 0) { //play the correct animation anim.Play(ability.animationTag, 0); //set the correct trigger meleeAttackTrigger.enabled = true; //update the triggers damage with abilities damage meleeAttackTrigger.SendMessage(CombatActions.UpdateDamage, ability.damage); player.playerHUD.PlayerCastedAbility(ability); StartCoroutine(CooldownHandler(ability)); } else { string message = ability.animationTag + " not off ability cooldown yet!"; ARKLogger.LogMessage(eLogCategory.Combat, eLogLevel.Warning, message); } }
//on player load setup abilities void Start() { energyRegen = 5.0f; corruptionDegen = 1.0f; #region Ability setup //Abilities(damage, cooldown, InputTag, sprite image) attack1 = new AbilityTest(eEquippedSlot.Attack1, eAbilityCast.Light, 5, 0.25f, 0, 5, Resources.Load<Sprite>("Sprites/Demon/Abilities/BasicAttacks/BasicAttack1")); attack2 = new AbilityTest(eEquippedSlot.Attack2, eAbilityCast.Dark, 10, 3f, 5, 20, Resources.Load<Sprite>("Sprites/Demon/Abilities/BasicAttacks/BasicAttack1")); spell1 = new AbilityTest(eEquippedSlot.Spell1, eAbilityCast.Light, 20, 5f, 10, 20, Resources.Load<Sprite>("Sprites/Demon/Abilities/BasicAttacks/BasicAttack1")); spell2 = new AbilityTest(eEquippedSlot.Spell2, eAbilityCast.Dark, 25, 5f, 20, 25, Resources.Load<Sprite>("Sprites/Demon/Abilities/BasicAttacks/BasicAttack1")); spell3 = new AbilityTest(eEquippedSlot.Spell3, eAbilityCast.Dark, 40, 10f, 30, 50, Resources.Load<Sprite>("Sprites/Demon/Abilities/BasicAttacks/BasicAttack1")); ultimate = new AbilityTest(eEquippedSlot.Ultimate, eAbilityCast.Light, 80, 60f, 60, 80, Resources.Load<Sprite>("Sprites/Demon/Abilities/BasicAttacks/BasicAttack1")); #endregion }
// Handles cooldown values for players skill bar private void HandleCooldown(AbilityTest ability) { SkillBarElement hudElement = DetermineHudElement(ability.equippedSlot); StartCoroutine(CooldownHandler(ability, hudElement)); }
// Coroutine used for ability cooldown IEnumerator CooldownHandler(AbilityTest ability, SkillBarElement hudElement) { hudElement.image.color = Color.black; yield return new WaitForSeconds(ability.cooldown); hudElement.image.color = Color.white; }