53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Unity.Mathematics;
|
|
using UnityEngine;
|
|
|
|
|
|
public class MeleeFighterAttackAnimator : MonoBehaviour {
|
|
public Player Player;
|
|
protected FloatingTextSpawner TextPopUp;
|
|
|
|
public Animator MeleeAnimator;
|
|
public List<string> MeleeAnimationNames;
|
|
public List<MeleeFighterClass.AttackState> MeleeAttackState;
|
|
private Dictionary<MeleeFighterClass.AttackState, string> MeleeAnimationNameDict;
|
|
|
|
public void Awake() {
|
|
TextPopUp = new FloatingTextSpawner(this.transform, 0.5f);
|
|
MeleeAnimationNameDict = new Dictionary<MeleeFighterClass.AttackState, string>();
|
|
for (int i = 0; i < MeleeAttackState.Count; i++)
|
|
MeleeAnimationNameDict.Add(MeleeAttackState[i], MeleeAnimationNames[i]);
|
|
}
|
|
|
|
|
|
public void RotateTowardsPlayerDirection() {
|
|
float angle = Mathf.Atan2(Player.PrevDirection.y, Player.PrevDirection.x) * Mathf.Rad2Deg;
|
|
transform.rotation = Quaternion.Euler(0, 0, angle);
|
|
}
|
|
|
|
public void MeleeResetKineticCharge() {
|
|
//Melee.CrossFade("Blank", 0, 1);
|
|
}
|
|
|
|
public void Stop() {
|
|
MeleeAnimator.CrossFade("Blank", 0, 0);
|
|
}
|
|
|
|
public void MeleeBasic(MeleeFighterClass.AttackState state) {
|
|
Debug.Log(state.ToString());
|
|
if (!MeleeAnimationNameDict.ContainsKey(state)) return;
|
|
RotateTowardsPlayerDirection();
|
|
|
|
MeleeAnimator.CrossFade(MeleeAnimationNameDict[state], 0, 0);
|
|
}
|
|
|
|
public void MeleeKineticSurge() {
|
|
return;
|
|
MeleeAnimator.CrossFade("KineticSurgeRelease", 0, 0);
|
|
}
|
|
}
|