开发完成背包功能
This commit is contained in:
parent
9e2177f4fa
commit
287973be2a
|
@ -6,6 +6,7 @@ using DefaultNamespace;
|
|||
using MotionFramework;
|
||||
using MotionFramework.Scripts.Runtime.Engine.Engine.Network.WebRequest;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using ToolsPack;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -87,9 +88,22 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
/// 删除工具包
|
||||
/// </summary>
|
||||
/// <param name="toolsName"></param>
|
||||
public void DeleteToolsPack(string toolsName)
|
||||
public void DeleteToolsPack(string toolsName, int index)
|
||||
{
|
||||
_toolsPack.Remove(toolsName);
|
||||
if (_toolsPack[toolsName].Count > 0)
|
||||
{
|
||||
for (int i = 0; i < _toolsPack[toolsName].Count; i++)
|
||||
{
|
||||
if (i == index)
|
||||
{
|
||||
_toolsPack[toolsName].RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_toolsPack.Remove(toolsName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -98,8 +112,6 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
/// <returns></returns>
|
||||
public Dictionary<string, List<GameObject>> GetToolsPack()
|
||||
{
|
||||
|
||||
|
||||
return _toolsPack;
|
||||
}
|
||||
|
||||
|
@ -107,7 +119,7 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
/// 根据名字查询工具包内容
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public GameObject GetToolsPack(string toolsName,int index)
|
||||
public GameObject GetToolsPack(string toolsName, int index)
|
||||
{
|
||||
List<GameObject> game;
|
||||
if (_toolsPack.TryGetValue(toolsName, out game))
|
||||
|
@ -185,7 +197,12 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
_toolsPackWindowItemBts.Clear();
|
||||
}
|
||||
|
||||
public void DeleteToolsPackWindowItemBts(string toolName)
|
||||
/// <summary>
|
||||
/// 删除背包里的UI按钮
|
||||
/// </summary>
|
||||
/// <param name="toolName"></param>
|
||||
/// <param name="index"></param>
|
||||
public void DeleteToolsPackWindowItemBts(string toolName, int index)
|
||||
{
|
||||
List<string> list = MotionEngine.GetModule<DataConfigManager>().GetToolsPackData(toolName);
|
||||
if (list != null)
|
||||
|
@ -194,7 +211,7 @@ public class ToolsPackManager : ModuleSingleton<ToolsPackManager>, IModule
|
|||
{
|
||||
for (int j = 0; j < list.Count; j++)
|
||||
{
|
||||
if (_toolsPackWindowItemBts[i].name == list[j])
|
||||
if (_toolsPackWindowItemBts[i].name == list[j] && _toolsPackWindowItemBts[i].GetComponent<ToolsPackWindowItemBtComponent>().GetIndex() == index)
|
||||
{
|
||||
GameObject g = _toolsPackWindowItemBts[i];
|
||||
_toolsPackWindowItemBts.Remove(g);
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace ToolsPack
|
|||
{
|
||||
GameObject toolsGame = MotionEngine.GetModule<ToolsPackManager>().GetToolsPack(btName,index);
|
||||
toolsGame.SetActive(true);
|
||||
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPack(btName);
|
||||
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPackWindowItemBts(btName);
|
||||
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPack(btName,index);
|
||||
MotionEngine.GetModule<ToolsPackManager>().DeleteToolsPackWindowItemBts(btName,index);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -52,5 +52,10 @@ namespace ToolsPack
|
|||
{
|
||||
btNameText.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public int GetIndex()
|
||||
{
|
||||
return index;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue