diff --git a/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs b/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs new file mode 100644 index 0000000000000000000000000000000000000000..6e2cccfffe11e147abdbf1cab26ef3b55ddb1275 --- /dev/null +++ b/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs @@ -0,0 +1,51 @@ +using System.Collections; +using System; +using System.Collections.Generic; + +using UnityEngine; +using UnityEngine.InputSystem; + +using BigSock.Service; + +namespace BigSock { + + /* + A basic dodge move that gives a push and a short invincibility. + */ + public class AbilityDodge : BaseAbility { + public static readonly float BASE_FORCE = 0.5f; + public static readonly TimeSpan IFRAME_DURATION = new TimeSpan(0, 0, 0, 0, 500); + + public override ulong Id => 201; + public override string Name => "Dodge"; + public override string Description => "A basic dodge move."; + + public AbilityDodge() { + StaminaCost = 4; + Cooldown = new TimeSpan(0, 0, 0, 1, 0); + } + + /* + Activates the ability. + */ + protected override bool Activate(Character actor, Vector3? target) { + if(target == null) return false; + + // Get direction. + var temp = (target.Value - actor.transform.position); + temp.z = 0; + var direction = (Vector2) temp.normalized; + + // Get the force. + var force = BASE_FORCE * actor.Stats.MoveSpeed; + + // Apply the push and iframes. + actor.KnockBack(force, direction); + actor.AddStatusEffect(StatusEffectType.Invincible, IFRAME_DURATION); + + return true; + } + + } + +} \ No newline at end of file diff --git a/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs.meta b/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs.meta new file mode 100644 index 0000000000000000000000000000000000000000..e4b53ef25aa2d1a5172738bc2068d8782df2efae --- /dev/null +++ b/MrBigsock/Assets/Code/Core/Abilities/AbilityDodge.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c7c0fcb77471bc0469856ad6f91803c5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: