RiftMayhem/Assets/Scripts/NPC/NPCControllers_v2/NPCAnimatorControllerBase.cs

74 lines
2.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class NPCAnimatorControllerBase : MonoBehaviour
{
protected Animator anim;
protected NavMeshAgent agent;
protected NPCControllerBase npcController;
protected bool isLockedInAnimation = false;
protected virtual void Awake()
{
anim = GetComponent<Animator>();
agent = GetComponentInParent<NavMeshAgent>();
npcController = GetComponentInParent<NPCControllerBase>();
}
protected virtual void Start()
{
}
protected virtual void Update()
{
anim.SetFloat("movementSpeed", agent.velocity.magnitude);
}
protected virtual void OnAttackAnimationEvent()
{
// Debug.Log(this.transform.parent.name + " Sending Notice On Attack Animation Event Trigger");
//send notice for brain/abilitybinder to execute queued action/ability
npcController.OnAttackAnimationEventTriggered();
}
protected virtual void OnDeathAnimationEvent()
{
//send notice for brain/abilitybinder to execute queued action/ability
npcController.OnDeathAnimationEventTriggered();
}
public void SetDead()
{
anim.SetTrigger("dead");
}
public virtual void SetTriggerBasedOnAbility(AbilityAnimationType animationType)
{
//Debug.Log("Setting animation trigger = " + animationType);
switch (animationType)
{
case AbilityAnimationType.Throw:
anim.SetTrigger("throw");
break;
case AbilityAnimationType.Spell:
anim.SetTrigger("cast");
break;
case AbilityAnimationType.Melee:
anim.SetTrigger("melee");
break;
case AbilityAnimationType.Jump:
anim.SetTrigger("jump");
break;
case AbilityAnimationType.Summon:
anim.SetTrigger("summon");
break;
default:
break;
}
}
}