slimecing

a fighting game featuring slimes and swords
Log | Files | Refs | README

DashAbility.cs (1055B)


      1 using Slimecing.Abilities.AbilityEffects;
      2 using Slimecing.Characters;
      3 using UnityEngine;
      4 
      5 namespace Slimecing.Abilities.UseAbilities
      6 {
      7     [CreateAssetMenu(fileName = "DashAbility", menuName = "Abilities/DashAbility")]
      8     public class DashAbility : Ability
      9     {
     10         [SerializeField] private float dashForce;
     11         [SerializeField] private float dashLength;
     12         [SerializeField] private int dashUseAmount;
     13         
     14         protected override void PutOnCooldown(AbilityUser aUser)
     15         {
     16             aUser.AddAbilityOnCooldown(new CooldownData(this, abilityCooldown, dashUseAmount));
     17         }
     18 
     19         public override void Use(AbilityUser aUser)
     20         {
     21             var characterMovementController = aUser.gameObject.GetComponent<CharacterMovementController>();
     22             if (characterMovementController == null) return;
     23             aUser.AddTimedAbilityEffect(new DashAbilityEffect(dashLength, this, aUser, characterMovementController,
     24                 dashForce));
     25             aUser.Audio.PlayOneShot(abilitySound);
     26         }
     27     }
     28 }