186 lines
4.5 KiB
C#
186 lines
4.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using HighlightPlus;
|
|
using UnityEngine.EventSystems;
|
|
using System;
|
|
using DG.Tweening;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
|
|
/// <summary>
|
|
/// 常驻交互
|
|
/// </summary>
|
|
public class PermanentTriggerBase : MonoBehaviour
|
|
{
|
|
public int triggerID;
|
|
public string triggerName;
|
|
public HighlightEffect _highlight;
|
|
|
|
/// <summary>
|
|
/// 打分事件
|
|
/// </summary>
|
|
private Action<string, object, int, int> scoreAction;
|
|
|
|
/// <summary>
|
|
/// 手中飞出时的回调
|
|
/// </summary>
|
|
protected Action hand_out_action;
|
|
|
|
/// <summary>
|
|
/// 收回手里的回调
|
|
/// </summary>
|
|
protected Action hand_back_action;
|
|
|
|
/// <summary>
|
|
/// 是否初始化了
|
|
/// </summary>
|
|
private bool isInit;
|
|
|
|
public Tween tween;
|
|
|
|
public void Awake()
|
|
{
|
|
if (!isInit)
|
|
{
|
|
isInit = true;
|
|
OnAwake();
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
OnStart();
|
|
}
|
|
|
|
private void SwitchSubProcessStepTriggerID(string arg0)
|
|
{
|
|
try
|
|
{
|
|
string info = "";
|
|
if (arg0.Contains("+"))
|
|
{
|
|
info = arg0.Split('+')[1];
|
|
}
|
|
else
|
|
{
|
|
info = arg0;
|
|
}
|
|
|
|
if (_highlight != null)
|
|
{
|
|
if (triggerName == info)
|
|
{
|
|
_highlight.SetHighlighted(true);
|
|
tween = DOVirtual.Float(1, 0f, 1f, t =>
|
|
{
|
|
_highlight.outline = t;
|
|
_highlight.innerGlow = t;
|
|
}).SetLoops(-1, LoopType.Yoyo);
|
|
}
|
|
else
|
|
{
|
|
_highlight.SetHighlighted(false);
|
|
if (tween != null)
|
|
tween.Kill(true);
|
|
}
|
|
|
|
_highlight.Refresh();
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.LogError(e.Message + " " + arg0);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Awake
|
|
/// </summary>
|
|
protected virtual void OnAwake()
|
|
{
|
|
if (GetComponent<HighlightEffect>())
|
|
{
|
|
_highlight = GetComponent<HighlightEffect>();
|
|
_highlight.outlineWidth = 0.5f;
|
|
float factor = Mathf.Pow(2, 3f);
|
|
Color tempColor = _highlight.outlineColor;
|
|
_highlight.innerGlowColor = tempColor;
|
|
if (triggerName != "收回工具" && triggerName != "NPC客户" && triggerName != "NPC负责人")
|
|
_highlight.outlineColor = new Color(tempColor.r * factor, tempColor.g * factor, tempColor.b * factor);
|
|
//_highlight.innerGlowColor.
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Start
|
|
/// </summary>
|
|
protected virtual void OnStart()
|
|
{
|
|
}
|
|
|
|
private void OnMouseEnter()
|
|
{
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
OnMEnter();
|
|
}
|
|
|
|
private void OnMouseDown()
|
|
{
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
OnMDown();
|
|
}
|
|
|
|
private void OnMouseExit()
|
|
{
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
OnMExit();
|
|
}
|
|
|
|
protected virtual void OnMEnter()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnMDown()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnMExit()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnDestroy()
|
|
{
|
|
}
|
|
|
|
|
|
//private void OnDisable()
|
|
//{
|
|
// GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
|
|
//}
|
|
|
|
public void AddScoreAction(Action<string, object, int, int> back)
|
|
{
|
|
this.scoreAction = back;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 调用打分功能
|
|
/// </summary>
|
|
/// <param name="para">参数 默认不传</param>
|
|
/// /// <param name="triggerName">触发的物体识别号 默认传自己的</param>
|
|
/// <param name="systemcid">系统id 默认当前系统</param>
|
|
/// <param name="shchmeid">科目id 默认当前科目</param>
|
|
public void CallScoreAction(object para = null, string triggerName = null, int systemcid = 0, int shchmeid = 0)
|
|
{
|
|
scoreAction?.Invoke(triggerName == null ? this.triggerName : triggerName, para, systemcid, shchmeid);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存Trigger的自身具体信息,参考scoreBase
|
|
/// </summary>
|
|
//public virtual string SaveCurrentTriggerStat() { return ""; }
|
|
/// <summary>
|
|
/// 加载Trigger的自身具体信息,参考scoreBase
|
|
/// </summary>
|
|
//public virtual void LoadCurrentTriggerStat(string triggerInfo) { }
|
|
} |