This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
project-undercover/Project Undercover/Assets/Scripts/CharacterStateMachine/ActionScripts/SpyInteractAction.cs
2017-10-08 18:37:19 -05:00

33 lines
No EOL
1.3 KiB
C#

using UnityEngine;
using System;
[CreateAssetMenu(menuName = "CharacterStateMachine/Actions/SpyInteract")]
public class SpyInteractAction : Action
{
public override void StartAct(StateController controller)
{
controller.characterAnimator.SetTrigger(controller.SelectedInteraction.characterInteraction);
Vector3 awayDirection =(controller.transform.position - controller.SelectedObject.transform.position).normalized;
Vector3 newPos = controller.SelectedObject.transform.position + awayDirection * controller.SelectedInteraction.interactionDistance;
controller.navMeshAgent.stoppingDistance = 0.0f;
controller.Destination = newPos;
}
public override void Act(StateController controller)
{
controller.FaceSelectedObject();
AnimatorStateInfo info = controller.animator.GetCurrentAnimatorStateInfo(0);
if (info.IsName(CharacterAnimator.GetParamName(controller.SelectedInteraction.characterInteraction)))
{
float progress = info.normalizedTime;
ProgressPanelController.ActivePanel.Progress = progress;
}
}
public override void EndAct(StateController controller)
{
// Debug.Log("Ending SpyInteract");
ProgressPanelController.ActivePanel.Hide();
controller.FinishInteraction();
}
}