YanCheng_Metrology/Assets/Scripts/Project/Objects/ToolAndMaterial/BaseToolOrDevice.cs

122 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
// 你可以在这里添加更多的属性和方法
}
/// <summary>
/// 工具或者材料基类,此脚本必须挂在工具或者材料上
/// </summary>
public abstract class BaseToolOrDevice : MonoBehaviour
{
public ItemInfo itemInfo;
public HighlightEffect _highlight;
public bool IsClick = true;
private void Start()
{
_highlight = GetComponent<HighlightEffect>();
}
[ContextMenu("GetInfo")]
public void GetInfo(string itemName)
{
}
//public void GetInfo(string itemName)
//{
// if (itemDatabase.ContainsKey(itemName))
// {
// ItemInfo info = itemDatabase[itemName];
// OnItemInfoReceived?.Invoke(info);
// }
//}
//public void GetInfo(GameObject Item,string ItemName,E_ToolOrDeviceOrMaterials E_Item)
//{
// Item.SetActive(false);
// if (itemDatabase.ContainsKey(ItemName))
// {
// // 获取物品信息
// ItemInfo info = itemDatabase[ItemName];
// // TODO: 后续处理例如更新UI或执行其他逻辑
// }
// else
// {
// Debug.LogWarning($"物品 '{ItemName}' 不存在于数据库中");
// }
// switch (E_Item)
// {
// case E_ToolOrDeviceOrMaterials.Tool:
// break;
// case E_ToolOrDeviceOrMaterials.Materials:
// break;
// }
// //TODO:后续 根据英文名称去获取ID 中文名 和其它
//}
private void OnMouseEnter()
{
if (GameManager.RunModelMgr.SceneType != E_SceneType.ToolRoom) return;
if (EventSystem.current.IsPointerOverGameObject()) return;
OnEnter();
UIManager.Instance.ShowPanel<ItemTips>(E_UI_Layer.System, (panel) =>
{
panel.Init(gameObject.name);
}); //提示面板
}
private void OnMouseDown()
{
if (GameManager.RunModelMgr.SceneType != E_SceneType.ToolRoom) return;
if (EventSystem.current.IsPointerOverGameObject()) return;
OnDown();
UIManager.Instance.HidePanel<ItemTips>();//提示面板
//gameObject.SetActive(false);
}
private void OnMouseExit()
{
//TODO: 这里写提示关闭的代码
if (GameManager.RunModelMgr.SceneType != E_SceneType.ToolRoom) return;
if (EventSystem.current.IsPointerOverGameObject()) return;
OnExit();
UIManager.Instance.HidePanel<ItemTips>();//提示面板
}
public virtual void OnEnter()
{
Debug.Log("进入");
}
public virtual void OnDown()
{
Debug.Log("点击");
}
public virtual void OnExit()
{
Debug.Log("离开");
}
}