Skip to content
Snippets Groups Projects
Commit 62bcf526 authored by Robin Halseth Sandvik's avatar Robin Halseth Sandvik
Browse files

Added dodge ability.

parent 24a1bfd2
No related branches found
No related tags found
1 merge request!34Dodge
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
fileFormatVersion: 2
guid: c7c0fcb77471bc0469856ad6f91803c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment