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

33 lines
1.3 KiB
C#
Raw Normal View History

2017-10-03 04:15:13 -05:00
using UnityEngine;
using System;
[CreateAssetMenu(menuName = "CharacterStateMachine/Actions/SpyInteract")]
public class SpyInteractAction : Action
2017-10-03 04:15:13 -05:00
{
public override void StartAct(StateController controller)
{
controller.characterAnimator.SetTrigger(controller.SelectedInteraction.characterInteraction);
2017-10-08 18:37:19 -05:00
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;
2017-10-03 04:15:13 -05:00
}
public override void Act(StateController controller)
{
2017-10-08 18:37:19 -05:00
controller.FaceSelectedObject();
2017-10-03 04:15:13 -05:00
AnimatorStateInfo info = controller.animator.GetCurrentAnimatorStateInfo(0);
2017-10-05 13:53:29 -05:00
if (info.IsName(CharacterAnimator.GetParamName(controller.SelectedInteraction.characterInteraction)))
{
float progress = info.normalizedTime;
ProgressPanelController.ActivePanel.Progress = progress;
}
2017-10-03 04:15:13 -05:00
}
public override void EndAct(StateController controller)
{
2017-10-05 13:53:29 -05:00
// Debug.Log("Ending SpyInteract");
2017-10-03 04:15:13 -05:00
ProgressPanelController.ActivePanel.Hide();
controller.FinishInteraction();
2017-10-03 04:15:13 -05:00
}
}