private IEnumerator AbilityCooldown(Ability currentActive, AbilityDelegate methodToCall) { cooldownComplete = false; // Deactivate button yield return(new WaitForSeconds(currentActive.cooldownTime)); cooldownComplete = true; // Reactivate button }
private IEnumerator AbilityDuration(Ability currentActive, AbilityDelegate methodToCall) { methodToCall(); // Activate skill yield return(new WaitForSeconds(currentActive.duration)); methodToCall(); // Deactivate skill }
private IEnumerator AbilityCooldown(Ability currentActive, AbilityDelegate methodToCall) { cooldownComplete = false; // Deactivate button GameManager.instance.ActionSkillCooldownDisplay(currentActive.cooldownTime); yield return(new WaitForSeconds(currentActive.cooldownTime)); cooldownComplete = true; // Reactivate button }
public PlayerAbility(string abilityName, AbilityTypeEnum abilityType, AbilityCategoryEnum abilityCategory, AbilityDelegate abilityAction, GameObject playerReference, bool isCommandPhaseMandatory = false) { AbilityName = abilityName; AbilityType = abilityType; AbilityAction = abilityAction; AbilityCategory = abilityCategory; PlayerReference = playerReference; IsCommandPhaseMandatory = isCommandPhaseMandatory; }
public void ActivateAbility() { // If pressed and active ability assigned ... if (cooldownComplete) { // Disable active abilities until specific cooldown is complete switch (activeSkills) { case ActiveSkills.None: break; case ActiveSkills.DropMine: currentActive = activeAbilities[0]; methodToCall = playerCombat.PlaceDropMine; methodToCall(); StartCoroutine(AbilityCooldown(currentActive, methodToCall)); break; case ActiveSkills.Rewind: currentActive = activeAbilities[1]; methodToCall = playerRewind.Rewind; methodToCall(); StartCoroutine(AbilityCooldown(currentActive, methodToCall)); SoundManager.instance.PlaySFX("Rewind"); break; case ActiveSkills.Shotgun: currentActive = activeAbilities[2]; methodToCall = playerCombat.ShotgunShoot; methodToCall(); StartCoroutine(AbilityCooldown(currentActive, methodToCall)); SoundManager.instance.PlaySFX("Shotgun"); break; case ActiveSkills.Stealth: currentActive = activeAbilities[3]; methodToCall = Stealth; StartCoroutine(AbilityDuration(currentActive, methodToCall)); StartCoroutine(AbilityCooldown(currentActive, methodToCall)); SoundManager.instance.PlaySFX("Stealth"); break; case ActiveSkills.TempShield: currentActive = activeAbilities[4]; methodToCall = TempShield; StartCoroutine(AbilityDuration(currentActive, methodToCall)); StartCoroutine(AbilityCooldown(currentActive, methodToCall)); break; default: break; } methodToCall = null; } }
public MonsterAbility(Ability ability, Monster owner) { Ability = ability; Owner = owner; castingAmmo = ability.castingAmmo; castingCount = ability.castingCount; abilityName = ability.name; description = ability.description; //get string of the name of the ability string name = string.Concat(ability.name.Where(c => !char.IsWhiteSpace(c))); //convert string to a delegate to call the method of the name of the ability abilityMethod = DelegateCreation(this, name); }
public void ActivateAbility() { // If pressed and active ability assigned ... if (cooldownComplete) { // Disable active abilities until specific cooldown is complete switch (activeSkills) { case ActiveSkills.None: break; case ActiveSkills.DropMine: currentActive = activeAbilities[0]; break; case ActiveSkills.Rewind: currentActive = activeAbilities[1]; break; case ActiveSkills.Shotgun: currentActive = activeAbilities[2]; break; case ActiveSkills.Stealth: currentActive = activeAbilities[3]; methodToCall = Stealth; StartCoroutine(AbilityDuration(currentActive, methodToCall)); StartCoroutine(AbilityCooldown(currentActive, methodToCall)); break; case ActiveSkills.TempShield: currentActive = activeAbilities[4]; methodToCall = TempShield; StartCoroutine(AbilityDuration(currentActive, methodToCall)); StartCoroutine(AbilityCooldown(currentActive, methodToCall)); break; default: break; } methodToCall = null; } }
//create the method delegate for each ability AbilityDelegate DelegateCreation(object target, string functionName) { AbilityDelegate ab = (AbilityDelegate)Delegate.CreateDelegate(typeof(AbilityDelegate), target, functionName); return(ab); }
public ability(AbilityDelegate call) { this.call = call; }