149 lines
3.9 KiB
C#
149 lines
3.9 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using GCGame.Table;
|
|||
|
using Module.Log;
|
|||
|
using System;
|
|||
|
|
|||
|
public class DailyCopyInfoItemsPanelCtr : MonoBehaviour {
|
|||
|
|
|||
|
private static DailyCopyInfoItemsPanelCtr instance;
|
|||
|
public static DailyCopyInfoItemsPanelCtr Instance
|
|||
|
{
|
|||
|
get { return instance; }
|
|||
|
}
|
|||
|
|
|||
|
public Button closeUseItemsPanelBtn;
|
|||
|
public UIContainerBase useItemContainer;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
if (instance == null)
|
|||
|
{
|
|||
|
instance = this;
|
|||
|
}
|
|||
|
|
|||
|
closeUseItemsPanelBtn.onClick.AddListener(OnHideUseItemPanelBtnClick);
|
|||
|
}
|
|||
|
|
|||
|
public static void Show(int copyID = -1)
|
|||
|
{
|
|||
|
UIManager.ShowUI(UIInfo.DailyCopyInfoItemsPanel,
|
|||
|
(bool isSuccess, object param) =>
|
|||
|
{
|
|||
|
if (isSuccess && DailyCopyInfoItemsPanelCtr.Instance != null)
|
|||
|
{
|
|||
|
DailyCopyInfoItemsPanelCtr.Instance.ShowWithCopyID((int)param);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
LogModule.ErrorLog("Can't show DailyCopyInfoItemsPanel !");
|
|||
|
}
|
|||
|
}, copyID);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public void ShowWithCopyID(int copyID)
|
|||
|
{
|
|||
|
Tab_DailyCopy tab = TableManager.GetDailyCopyByID(copyID);
|
|||
|
if (tab == null)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("Can't show UseableItemPanel, table is null");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
string rawParam = tab.UseItemParam;
|
|||
|
string[] param = rawParam.Trim('"', ' ', '\'').Split('*');
|
|||
|
List<int> itemIDs = new List<int>();
|
|||
|
for (int i = 0; i < param.Length; ++i)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
int id = -1;
|
|||
|
if (!string.IsNullOrEmpty(param[i]))
|
|||
|
{
|
|||
|
id = Convert.ToInt32(param[i].Trim(' ', '"'));
|
|||
|
}
|
|||
|
|
|||
|
if (id > 0)
|
|||
|
{
|
|||
|
itemIDs.Add(id);
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < itemIDs.Count; ++i)
|
|||
|
{
|
|||
|
useItemContainer.InitContentItem(itemIDs);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region 试炼谷(副本id=6200到6210)增加一个界面按钮
|
|||
|
public static void L_Show(int SystemParamID = -1)
|
|||
|
{
|
|||
|
UIManager.ShowUI(UIInfo.DailyCopyInfoItemsPanel,
|
|||
|
(bool isSuccess, object param) =>
|
|||
|
{
|
|||
|
if (isSuccess && DailyCopyInfoItemsPanelCtr.Instance != null)
|
|||
|
{
|
|||
|
DailyCopyInfoItemsPanelCtr.Instance.L_ShowWithSystemParamID((int)param);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
LogModule.ErrorLog("Can't show DailyCopyInfoItemsPanel !");
|
|||
|
}
|
|||
|
}, SystemParamID);
|
|||
|
}
|
|||
|
public void L_ShowWithSystemParamID(int systemParamID)
|
|||
|
{
|
|||
|
Tab_SystemParam tab = TableManager.GetSystemParamByID(systemParamID, 0);
|
|||
|
if (tab == null)
|
|||
|
{
|
|||
|
LogModule.ErrorLog("Can't show UseableItemPanel, table is null");
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
string rawParam = tab.StringValue;
|
|||
|
string[] param = rawParam.Trim('"', ' ', '\'').Split('|');
|
|||
|
List<int> itemIDs = new List<int>();
|
|||
|
for (int i = 0; i < param.Length; ++i)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
int id = -1;
|
|||
|
if (!string.IsNullOrEmpty(param[i]))
|
|||
|
{
|
|||
|
id = Convert.ToInt32(param[i].Trim(' ', '"'));
|
|||
|
}
|
|||
|
|
|||
|
if (id > 0)
|
|||
|
{
|
|||
|
itemIDs.Add(id);
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < itemIDs.Count; ++i)
|
|||
|
{
|
|||
|
useItemContainer.InitContentItem(itemIDs);
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
|
|||
|
private void OnHideUseItemPanelBtnClick()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.DailyCopyInfoItemsPanel);
|
|||
|
}
|
|||
|
|
|||
|
}
|