79 lines
2.1 KiB
C#
79 lines
2.1 KiB
C#
using DG.Tweening.Core.Easing;
|
|
using HighlightPlus;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEditor.Timeline.Actions;
|
|
using UnityEngine;
|
|
using UnityEngine.SocialPlatforms;
|
|
using static UnityEngine.GraphicsBuffer;
|
|
|
|
public class NPCController : MonoBehaviour
|
|
{
|
|
public HighlightEffect _highlight;
|
|
|
|
public SpriteRenderer spriteRenderer;
|
|
public Transform target;
|
|
private float distance;
|
|
public float minDistance;
|
|
/// <summary>
|
|
/// 是否靠近
|
|
/// </summary>
|
|
public bool isClose = false;
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (target != null)
|
|
distance = Vector3.Distance(transform.position, target.position);
|
|
if (distance < minDistance)
|
|
{
|
|
transform.LookAt(target.position);
|
|
transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
|
|
isClose = true;
|
|
}
|
|
else
|
|
{
|
|
isClose = false;
|
|
}
|
|
}
|
|
protected void OnMEnter()
|
|
{
|
|
if (!isClose) return;
|
|
_highlight.SetHighlighted(true);
|
|
}
|
|
protected void OnMExit()
|
|
{
|
|
_highlight.SetHighlighted(false);
|
|
|
|
}
|
|
protected void OnMDown()
|
|
{
|
|
if (!isClose)
|
|
{
|
|
//if (GameManager.UIMgr.GetPanel<UI_MiddleTipPanel>() != null)
|
|
// GameManager.UIMgr.GetPanel<UI_MiddleTipPanel>().Init("提示:请靠近交互对象");
|
|
//if (GameManager.UIMgr.GetPanel<UI_MiddleTipPanel>() == null)
|
|
//{
|
|
// GameManager.UIMgr.ShowPanel<UI_MiddleTipPanel>(E_UI_Layer.System, (p) =>
|
|
// {
|
|
// p.Init($"提示:请靠近交互对象");
|
|
// });
|
|
//}
|
|
//return;
|
|
}
|
|
|
|
//if (GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(triggerName, false) == 0)
|
|
//{
|
|
|
|
//talkAction?.Invoke();
|
|
//_highlight.SetHighlighted(false);
|
|
//if (spriteRenderer != null)
|
|
// spriteRenderer.gameObject.SetActive(false);
|
|
//if (animator != null)
|
|
//{
|
|
// animator.SetInteger(animatorParameters, 1);
|
|
//}
|
|
|
|
//}
|
|
}
|
|
}
|