/// <summary> /// Makes the skill go on cooldown. /// </summary> protected void GoOnCooldown() { if (_cooldown != 0) { // Sets cooldown timer to cooldown. When cooldown timer reaches 0, we can use the skill again _cooldownTimer = _cooldown; // If the current character is an ally, we also want them to reset their skill to basic attack if (_maRef.WhatAmI == CharacterType.Ally) { // Get the ally skill controller AllySkillController allyskillContRef = _maRef.GetComponent <AllySkillController>(); if (allyskillContRef == null) { Debug.Log("No AllySkillController was attached to " + _maRef.name); return; } // De activate the special skill (if it was one) allyskillContRef.DeactivateSkill(); } OnCooldownStart?.Invoke(); } }
/// <summary> /// Sets the button on cooldown. Defaults to <see cref="CooldownDuration"/>. /// </summary> /// <remarks>Raises the <see cref="OnCooldownStart"/> or <see cref="OnCooldownEnd"/> events depending on whether the button wasn't or was on cooldown, respectively.</remarks> /// <remarks>Ends effect duration if the effect is active when called.</remarks> /// <param name="customCooldown">Optional custom cooldown duration (does not affect <see cref="CooldownDuration"/>, may be longer or shorter than <see cref="CooldownDuration"/>)</param> public void ApplyCooldown(float?customCooldown = null) { if (IsEffectActive) { EndEffect(false); } bool wasCoolingDown = IsCoolingDown; CooldownTime = customCooldown ?? CooldownDuration; if (!wasCoolingDown && IsCoolingDown) { OnCooldownStart?.SafeInvoke(this, EventArgs.Empty, nameof(OnCooldownStart)); } else if (wasCoolingDown && !IsCoolingDown) { OnCooldownEnd?.SafeInvoke(this, EventArgs.Empty, nameof(OnCooldownEnd)); } }
/// <summary> /// Invoke cooldown start at the end of an attack for the current weapon /// </summary> public void InvokeCooldownStart() => OnCooldownStart?.Invoke();