using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HighlightPlus;
using UnityEngine.EventSystems;
using System;
///
/// 常驻交互
///
public class PermanentTriggerBase : MonoBehaviour
{
public int triggerID;
public string triggerName;
public HighlightEffect _highlight;
///
/// 打分事件
///
private Action scoreAction;
///
/// 手中飞出时的回调
///
protected Action hand_out_action;
///
/// 收回手里的回调
///
protected Action hand_back_action;
private void Awake()
{
OnAwake();
AddScoreAction(ScoreManager.instance.Check);
}
private void Start()
{
OnStart();
}
private void SwitchSubProcessStepTriggerID(string arg0)
{
if (triggerName == arg0)
{
_highlight.SetHighlighted(true);
}
else
{
_highlight.SetHighlighted(false);
}
}
///
/// Awake
///
protected virtual void OnAwake()
{
if (GetComponent())
_highlight = GetComponent();
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
GameManager.EventMgr.AddEventListener(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
}
///
/// Start
///
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()
{
}
private void OnDestroy()
{
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
GameManager.EventMgr.RemoveEventListener(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
}
//private void OnDisable()
//{
// GameManager.EventMgr.RemoveEventListener(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
//}
public void AddScoreAction(Action back)
{
this.scoreAction = back;
}
///
/// 调用打分功能
///
/// 参数 默认不传
/// /// 触发的物体识别号 默认传自己的
/// 系统id 默认当前系统
/// 科目id 默认当前科目
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);
}
}