DashAbilityEffect.cs (1361B)
1 using Slimecing.Abilities.UseAbilities; 2 using Slimecing.Characters; 3 using UnityEngine; 4 5 namespace Slimecing.Abilities.AbilityEffects 6 { 7 public class DashAbilityEffect : TimedAbilityEffect 8 { 9 private DashAbility _ability; 10 private readonly AbilityUser _aUser; 11 private readonly CharacterMovementController _characterMovementController; 12 private readonly float _dashForce; 13 14 public DashAbilityEffect(float duration, Ability ability, AbilityUser aUser, 15 CharacterMovementController controller, float dashForce) : base(duration, ability, aUser) 16 { 17 _aUser = aUser; 18 _characterMovementController = controller; 19 _dashForce = dashForce; 20 _ability = (DashAbility) ability; 21 } 22 23 public override void Activate() 24 { 25 Vector3 dashDir = _aUser.transform.forward; 26 if (_characterMovementController.MoveInput != Vector2.zero) 27 { 28 Vector2 moveInputDir = _characterMovementController.MoveInput; 29 dashDir = new Vector3(moveInputDir.x, 0, moveInputDir.y); 30 } 31 32 _characterMovementController.AddForceTo(dashDir, _dashForce); 33 } 34 public override void End() 35 { 36 _characterMovementController.SetBackToNormalForces(); 37 } 38 } 39 }