116 lines
3.3 KiB
C#
116 lines
3.3 KiB
C#
using HighlightPlus;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Serialization;
|
|
using TMPro;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
[Serializable]
|
|
public class ItemInfo
|
|
{
|
|
public int toolId;
|
|
public int triggerID;
|
|
public string toolName;
|
|
public E_ToolOrDeviceOrMaterials toolOrDeviceOrMaterial;
|
|
public GameObject objPrefab;
|
|
public Vector3 selfPosInToolRoom;
|
|
}
|
|
/// <summary>
|
|
/// 工具或者材料基类,此脚本必须挂在工具或者材料上
|
|
/// </summary>
|
|
public abstract class BaseToolOrDevice : MonoBehaviour
|
|
{
|
|
public ItemInfo itemInfo;
|
|
[HideInInspector]
|
|
public HighlightEffect _highlight;
|
|
private void Awake()
|
|
{
|
|
_highlight = GetComponent<HighlightEffect>();
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
GameManager.EventMgr.AddEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
|
|
}
|
|
|
|
private void SwitchSubProcessStepTriggerID(string arg0)
|
|
{
|
|
if (itemInfo.toolName == arg0)
|
|
{
|
|
_highlight.SetHighlighted(true);
|
|
}
|
|
else
|
|
{
|
|
_highlight.SetHighlighted(false);
|
|
}
|
|
}
|
|
|
|
public void GetInfo()
|
|
{
|
|
//_highlight = GetComponent<HighlightEffect>();
|
|
D_ToolAndMaterialData dTMD = GameManager.ToolAndmaterialMgr.GetToolOrMaterialOrDeviceInfoByObjName(gameObject.name);
|
|
if (dTMD != null)
|
|
{
|
|
itemInfo.toolId = dTMD.id;
|
|
itemInfo.triggerID = dTMD.id;
|
|
itemInfo.toolName = dTMD.objName;
|
|
itemInfo.toolOrDeviceOrMaterial = (E_ToolOrDeviceOrMaterials)dTMD.type;
|
|
gameObject.SetActive(true);
|
|
itemInfo.objPrefab = Resources.Load<GameObject>("Prefabs/Objects/Tools/" + gameObject.name);
|
|
Debug.Log("生成");
|
|
itemInfo.selfPosInToolRoom = transform.position;
|
|
}
|
|
else
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
|
|
private void OnMouseEnter()
|
|
{
|
|
if (GameManager.RunModelMgr.SceneType != E_SceneType.ToolRoom) return;
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
OnEnter();
|
|
}
|
|
|
|
private void OnMouseDown()
|
|
{
|
|
if (GameManager.RunModelMgr.SceneType != E_SceneType.ToolRoom) return;
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
OnDown();
|
|
}
|
|
|
|
private void OnMouseExit()
|
|
{
|
|
if (GameManager.RunModelMgr.SceneType != E_SceneType.ToolRoom) return;
|
|
OnExit();
|
|
if (EventSystem.current.IsPointerOverGameObject()) return;
|
|
}
|
|
|
|
|
|
public virtual void OnEnter()
|
|
{
|
|
//Debug.Log("进入");
|
|
}
|
|
|
|
public virtual void OnDown()
|
|
{
|
|
//Debug.Log("点击");
|
|
}
|
|
|
|
public virtual void OnExit()
|
|
{
|
|
//Debug.Log("离开");
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if (GameManager.RunModelMgr.ModeType == E_ModeType.Study)
|
|
GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
|
|
}
|
|
//private void OnDisable()
|
|
//{
|
|
// GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
|
|
//}
|
|
} |