Compare commits
No commits in common. "e16e5d4c09f7dec449fd54f3bfa29a06feea86be" and "dd94f0cb87568878b7f2acca2fead6c2323e89e9" have entirely different histories.
e16e5d4c09
...
dd94f0cb87
|
|
@ -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: 0
|
value: -1.134
|
||||||
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.5
|
value: 1.24
|
||||||
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: 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.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: 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.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: 180
|
value: 0
|
||||||
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,10 +6201,6 @@ 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:
|
||||||
|
|
|
||||||
|
|
@ -8,31 +8,37 @@ using UnityEngine;
|
||||||
public class PacksackBagMgr : BaseManager<PacksackBagMgr>
|
public class PacksackBagMgr : BaseManager<PacksackBagMgr>
|
||||||
{
|
{
|
||||||
//包里用了哪些工器具
|
//包里用了哪些工器具
|
||||||
private readonly Dictionary<int, List<ItemInfo>> toolAndMaterialDic = new Dictionary<int, List<ItemInfo>>();
|
private readonly Dictionary<string, ToolAndMaterialData> toolAndMaterialDic =
|
||||||
|
new Dictionary<string, ToolAndMaterialData>();
|
||||||
|
|
||||||
private PacksackBagMgr()
|
private PacksackBagMgr()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<int, List<ItemInfo>> GetCurrentBagData()
|
public Dictionary<string, ToolAndMaterialData> GetCurrentBagData()
|
||||||
{
|
{
|
||||||
return toolAndMaterialDic;
|
return toolAndMaterialDic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一个工器具或材料
|
/// 添加一个工器具或材料
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
public void AddOneToolOrMater(ItemInfo itemInfo)
|
public void AddOneToolOrMater(string name)
|
||||||
{
|
{
|
||||||
if (toolAndMaterialDic.ContainsKey(itemInfo.toolId))
|
if (toolAndMaterialDic.ContainsKey(name))
|
||||||
{
|
{
|
||||||
toolAndMaterialDic[itemInfo.toolId].Add(itemInfo);
|
toolAndMaterialDic[name].count++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
toolAndMaterialDic.Add(itemInfo.toolId, new List<ItemInfo>() { itemInfo });
|
//从配置里得知是tool or Material
|
||||||
|
var tempToolOrMaterType = GameManager.ToolAndmaterialMgr.GetObjType(name);
|
||||||
|
if (tempToolOrMaterType == -1) return;
|
||||||
|
var tempToolAndMaterData = new ToolAndMaterialData()
|
||||||
|
{ count = 1, objName = name, type = tempToolOrMaterType };
|
||||||
|
toolAndMaterialDic.Add(name, tempToolAndMaterData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,17 +46,14 @@ public class PacksackBagMgr : BaseManager<PacksackBagMgr>
|
||||||
/// 移除一个工器具或材料
|
/// 移除一个工器具或材料
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
public void RemoveOneToolOrMater(ItemInfo itemInfo)
|
public void RemoveOneToolOrMater(string name)
|
||||||
{
|
{
|
||||||
if (toolAndMaterialDic.ContainsKey(itemInfo.toolId))
|
if (toolAndMaterialDic.ContainsKey(name))
|
||||||
{
|
{
|
||||||
if (toolAndMaterialDic[itemInfo.toolId].Count > 1)
|
var toolAndMaterCount = toolAndMaterialDic[name].count--;
|
||||||
|
if (toolAndMaterCount <= 0)
|
||||||
{
|
{
|
||||||
toolAndMaterialDic[itemInfo.toolId].Remove(itemInfo);
|
toolAndMaterialDic.Remove(name);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
toolAndMaterialDic.Remove(itemInfo.toolId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,103 +1,65 @@
|
||||||
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
|
||||||
{
|
{
|
||||||
public ItemInfo itemInfo;
|
/// <summary>
|
||||||
|
/// 工具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(string itemName)
|
public void GetInfo()
|
||||||
{
|
{
|
||||||
|
//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();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public class Tool_SelectComponent : BaseToolOrDevice
|
||||||
if (IsClick)
|
if (IsClick)
|
||||||
{
|
{
|
||||||
//묏야츰냔뵨묏야렴흙묏야움
|
//묏야츰냔뵨묏야렴흙묏야움
|
||||||
GameManager.PacksackBagMgr.AddOneToolOrMater(itemInfo);
|
GameManager.PacksackBagMgr.AddOneToolOrMater(gameObject.name);
|
||||||
this.gameObject.SetActive(false);
|
this.gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,5 @@ using UnityEngine;
|
||||||
|
|
||||||
public class UI_ToolAndMaterialsItem : BaseItem
|
public class UI_ToolAndMaterialsItem : BaseItem
|
||||||
{
|
{
|
||||||
public void Init(int count, string toolName)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,5 +86,15 @@ public class UI_MainTitlePanel : BasePanel
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Button]
|
||||||
|
public void Test1()
|
||||||
|
{
|
||||||
|
GameManager.UIMgr.ShowPanel<UI_ToolAndMaterialPanel>();
|
||||||
|
}
|
||||||
|
[Button]
|
||||||
|
public void Test2()
|
||||||
|
{
|
||||||
|
GameManager.PacksackBagMgr.AddOneToolOrMater("万用表");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,27 +21,28 @@ public class UI_ToolAndMaterialPanel : BasePanel
|
||||||
|
|
||||||
private void CreatItem(int type)
|
private void CreatItem(int type)
|
||||||
{
|
{
|
||||||
Dictionary<int, List<ItemInfo>> bagDatas = GameManager.PacksackBagMgr.GetCurrentBagData();
|
var bagData = GameManager.PacksackBagMgr.GetCurrentBagData();
|
||||||
|
|
||||||
foreach (var toolAndMaterialData in bagDatas.Values)
|
foreach (var toolAndMaterialData in bagData.Values)
|
||||||
{
|
{
|
||||||
foreach (var item in toolAndMaterialData)
|
if (toolAndMaterialData.type != type)
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
//string iconName = GameManager.ToolAndmaterialMgr.GetIconSpriteName(toolAndMaterialData.objName);
|
|
||||||
//if (iconName != null)
|
|
||||||
//{
|
|
||||||
// var toolAndMaterItem = GameManager.ResourcesMgr.Load<GameObject>(Const.UI_Item +
|
|
||||||
// "UI_ToolAndMaterialPanel/" +s
|
|
||||||
// "ToolAndMeterialItem");
|
|
||||||
|
|
||||||
// toolAndMaterItem.GetComponent<Image>().sprite =
|
string iconName = GameManager.ToolAndmaterialMgr.GetIconSpriteName(toolAndMaterialData.objName);
|
||||||
// GameManager.ResourcesMgr.Load<Sprite>(Const.TitleSpritePath + iconName);
|
if (iconName != null)
|
||||||
// toolAndMaterItem.GetComponentInChildren<Text>().text = toolAndMaterialData.count.ToString();
|
{
|
||||||
|
var toolAndMaterItem = GameManager.ResourcesMgr.Load<GameObject>(Const.UI_Item +
|
||||||
|
"UI_ToolAndMaterialPanel/" +
|
||||||
|
"ToolAndMeterialItem");
|
||||||
|
|
||||||
// toolAndMaterItem.transform.parent = GetControl<ScrollRect>("itemScrollView").content;
|
toolAndMaterItem.GetComponent<Image>().sprite =
|
||||||
//}
|
GameManager.ResourcesMgr.Load<Sprite>(Const.TitleSpritePath + iconName);
|
||||||
|
toolAndMaterItem.GetComponentInChildren<Text>().text = toolAndMaterialData.count.ToString();
|
||||||
|
|
||||||
|
toolAndMaterItem.transform.parent = GetControl<ScrollRect>("itemScrollView").content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue