Compare commits

...

5 Commits

Author SHA1 Message Date
taosuqi e16e5d4c09 修改工具面板 2024-08-15 21:28:36 +08:00
taosuqi bcb3764573 Merge branch 'main' of http://172.16.1.12/WangWeiZhi/YanCheng_Metrology into main 2024-08-15 20:38:50 +08:00
taosuqi 8e36bd262c 1 2024-08-15 20:38:45 +08:00
taosuqi b440a3f564 合并融合 2024-08-15 20:34:31 +08:00
taosuqi 2a27c3bf7a 融合 2024-08-15 20:33:25 +08:00
7 changed files with 101 additions and 70 deletions

View File

@ -144,11 +144,11 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3} - target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: -1.134 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3} - target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 1.24 value: 1.5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3} - target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
@ -156,7 +156,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3} - target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
propertyPath: m_LocalRotation.w propertyPath: m_LocalRotation.w
value: 1 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3} - target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
@ -164,7 +164,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3} - target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3} - target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
@ -176,7 +176,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3} - target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
propertyPath: m_LocalEulerAnglesHint.y propertyPath: m_LocalEulerAnglesHint.y
value: 0 value: 180
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3} - target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
@ -6201,6 +6201,10 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z propertyPath: m_LocalEulerAnglesHint.z
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2557768358979172441, guid: f8a9676618f065446b3926269089375e, type: 3}
propertyPath: toolId
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2557768358979172441, guid: f8a9676618f065446b3926269089375e, type: 3} - target: {fileID: 2557768358979172441, guid: f8a9676618f065446b3926269089375e, type: 3}
propertyPath: _highlight propertyPath: _highlight
value: value:

View File

@ -8,37 +8,31 @@ using UnityEngine;
public class PacksackBagMgr : BaseManager<PacksackBagMgr> public class PacksackBagMgr : BaseManager<PacksackBagMgr>
{ {
//包里用了哪些工器具 //包里用了哪些工器具
private readonly Dictionary<string, ToolAndMaterialData> toolAndMaterialDic = private readonly Dictionary<int, List<ItemInfo>> toolAndMaterialDic = new Dictionary<int, List<ItemInfo>>();
new Dictionary<string, ToolAndMaterialData>();
private PacksackBagMgr() private PacksackBagMgr()
{ {
} }
public Dictionary<string, ToolAndMaterialData> GetCurrentBagData() public Dictionary<int, List<ItemInfo>> GetCurrentBagData()
{ {
return toolAndMaterialDic; return toolAndMaterialDic;
} }
/// <summary> /// <summary>
/// 添加一个工器具或材料 /// 添加一个工器具或材料
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name"></param>
public void AddOneToolOrMater(string name) public void AddOneToolOrMater(ItemInfo itemInfo)
{ {
if (toolAndMaterialDic.ContainsKey(name)) if (toolAndMaterialDic.ContainsKey(itemInfo.toolId))
{ {
toolAndMaterialDic[name].count++; toolAndMaterialDic[itemInfo.toolId].Add(itemInfo);
} }
else else
{ {
//从配置里得知是tool or Material toolAndMaterialDic.Add(itemInfo.toolId, new List<ItemInfo>() { itemInfo });
var tempToolOrMaterType = GameManager.ToolAndmaterialMgr.GetObjType(name);
if (tempToolOrMaterType == -1) return;
var tempToolAndMaterData = new ToolAndMaterialData()
{ count = 1, objName = name, type = tempToolOrMaterType };
toolAndMaterialDic.Add(name, tempToolAndMaterData);
} }
} }
@ -46,14 +40,17 @@ public class PacksackBagMgr : BaseManager<PacksackBagMgr>
/// 移除一个工器具或材料 /// 移除一个工器具或材料
/// </summary> /// </summary>
/// <param name="name"></param> /// <param name="name"></param>
public void RemoveOneToolOrMater(string name) public void RemoveOneToolOrMater(ItemInfo itemInfo)
{ {
if (toolAndMaterialDic.ContainsKey(name)) if (toolAndMaterialDic.ContainsKey(itemInfo.toolId))
{ {
var toolAndMaterCount = toolAndMaterialDic[name].count--; if (toolAndMaterialDic[itemInfo.toolId].Count > 1)
if (toolAndMaterCount <= 0)
{ {
toolAndMaterialDic.Remove(name); toolAndMaterialDic[itemInfo.toolId].Remove(itemInfo);
}
else
{
toolAndMaterialDic.Remove(itemInfo.toolId);
} }
} }
} }

View File

@ -1,65 +1,103 @@
using HighlightPlus; using HighlightPlus;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.Serialization;
using TMPro; using TMPro;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
[Serializable]
public class ItemInfo
{
public int toolId;
public int triggerID;
public string toolName;
public E_ToolOrDeviceOrMaterials toolOrDeviceOrMaterial;
// 你可以在这里添加更多的属性和方法
}
/// <summary> /// <summary>
/// 工具或者材料基类,此脚本必须挂在工具或者材料上 /// 工具或者材料基类,此脚本必须挂在工具或者材料上
/// </summary> /// </summary>
public abstract class BaseToolOrDevice : MonoBehaviour public abstract class BaseToolOrDevice : MonoBehaviour
{ {
/// <summary> public ItemInfo itemInfo;
/// 工具Id
/// </summary>
public int toolId;
public string toolName;
/// <summary>
/// 工器具类型 工具/材质/设备
/// </summary>
public E_ToolOrDeviceOrMaterials toolOrDeviceOrMaterial;
public HighlightEffect _highlight; public HighlightEffect _highlight;
public bool IsClick = true; public bool IsClick = true;
private void Start() private void Start()
{ {
_highlight = GetComponent<HighlightEffect>(); _highlight = GetComponent<HighlightEffect>();
} }
[ContextMenu("GetInfo")] [ContextMenu("GetInfo")]
public void GetInfo() public void GetInfo(string itemName)
{ {
//TODO:后续 根据英文名称去获取ID 中文名 和其它
} }
//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() private void OnMouseEnter()
{ {
if (GameManager.RunModelMgr.SceneType!= E_SceneType.ToolRoom) return; if (GameManager.RunModelMgr.SceneType != E_SceneType.ToolRoom) return;
if (EventSystem.current.IsPointerOverGameObject()) return; if (EventSystem.current.IsPointerOverGameObject()) return;
OnEnter(); OnEnter();
//TODO: 这里写提示打开的代码
UIManager.Instance.ShowPanel<ItemTips>(E_UI_Layer.System, (panel) => UIManager.Instance.ShowPanel<ItemTips>(E_UI_Layer.System, (panel) =>
{ {
panel.Init(gameObject.name); panel.Init(gameObject.name);
//GetComponentInChildren<TextMeshProUGUI>().text = gameObject.name;
//transform.position = Input.mousePosition + new Vector3(10, 10, 0);
}); //提示面板 }); //提示面板
} }
private void OnMouseDown() private void OnMouseDown()
{ {
if (GameManager.RunModelMgr.SceneType!= E_SceneType.ToolRoom) return; if (GameManager.RunModelMgr.SceneType != E_SceneType.ToolRoom) return;
if (EventSystem.current.IsPointerOverGameObject()) return; if (EventSystem.current.IsPointerOverGameObject()) return;
OnDown(); OnDown();
gameObject.SetActive(false); //gameObject.SetActive(false);
} }
private void OnMouseExit() private void OnMouseExit()
{ {
UIManager.Instance.HidePanel<ItemTips>();//提示面板 UIManager.Instance.HidePanel<ItemTips>();//提示面板
//TODO: 这里写提示关闭的代码 //TODO: 这里写提示关闭的代码
if (GameManager.RunModelMgr.SceneType!= E_SceneType.ToolRoom) return; if (GameManager.RunModelMgr.SceneType != E_SceneType.ToolRoom) return;
if (EventSystem.current.IsPointerOverGameObject()) return; if (EventSystem.current.IsPointerOverGameObject()) return;
OnExit(); OnExit();
} }

View File

@ -19,7 +19,7 @@ public class Tool_SelectComponent : BaseToolOrDevice
if (IsClick) if (IsClick)
{ {
//묏야츰냔뵨묏야렴흙묏야움 //묏야츰냔뵨묏야렴흙묏야움
GameManager.PacksackBagMgr.AddOneToolOrMater(gameObject.name); GameManager.PacksackBagMgr.AddOneToolOrMater(itemInfo);
this.gameObject.SetActive(false); this.gameObject.SetActive(false);
} }
} }

View File

@ -4,5 +4,8 @@ using UnityEngine;
public class UI_ToolAndMaterialsItem : BaseItem public class UI_ToolAndMaterialsItem : BaseItem
{ {
public void Init(int count, string toolName)
{
}
} }

View File

@ -86,15 +86,5 @@ public class UI_MainTitlePanel : BasePanel
break; break;
} }
} }
[Button]
public void Test1()
{
GameManager.UIMgr.ShowPanel<UI_ToolAndMaterialPanel>();
}
[Button]
public void Test2()
{
GameManager.PacksackBagMgr.AddOneToolOrMater("万用表");
}
} }

View File

@ -21,28 +21,27 @@ public class UI_ToolAndMaterialPanel : BasePanel
private void CreatItem(int type) private void CreatItem(int type)
{ {
var bagData = GameManager.PacksackBagMgr.GetCurrentBagData(); Dictionary<int, List<ItemInfo>> bagDatas = GameManager.PacksackBagMgr.GetCurrentBagData();
foreach (var toolAndMaterialData in bagData.Values) foreach (var toolAndMaterialData in bagDatas.Values)
{ {
if (toolAndMaterialData.type != type) foreach (var item in toolAndMaterialData)
{ {
continue;
} }
//string iconName = GameManager.ToolAndmaterialMgr.GetIconSpriteName(toolAndMaterialData.objName);
//if (iconName != null)
//{
// var toolAndMaterItem = GameManager.ResourcesMgr.Load<GameObject>(Const.UI_Item +
// "UI_ToolAndMaterialPanel/" +s
// "ToolAndMeterialItem");
string iconName = GameManager.ToolAndmaterialMgr.GetIconSpriteName(toolAndMaterialData.objName); // toolAndMaterItem.GetComponent<Image>().sprite =
if (iconName != null) // GameManager.ResourcesMgr.Load<Sprite>(Const.TitleSpritePath + iconName);
{ // toolAndMaterItem.GetComponentInChildren<Text>().text = toolAndMaterialData.count.ToString();
var toolAndMaterItem = GameManager.ResourcesMgr.Load<GameObject>(Const.UI_Item +
"UI_ToolAndMaterialPanel/" +
"ToolAndMeterialItem");
toolAndMaterItem.GetComponent<Image>().sprite = // toolAndMaterItem.transform.parent = GetControl<ScrollRect>("itemScrollView").content;
GameManager.ResourcesMgr.Load<Sprite>(Const.TitleSpritePath + iconName); //}
toolAndMaterItem.GetComponentInChildren<Text>().text = toolAndMaterialData.count.ToString();
toolAndMaterItem.transform.parent = GetControl<ScrollRect>("itemScrollView").content;
}
} }
} }