122 lines
2.9 KiB
C#
122 lines
2.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using GCGame.Table;
|
|
using Module.Log;
|
|
|
|
public class TestingCopyBuffInfoCtr : MonoBehaviour {
|
|
|
|
public List<BufferItem> buffs;
|
|
public GameObject descPanel;
|
|
public Text bufferDesc;
|
|
private object preShowBuff;
|
|
|
|
private static TestingCopyBuffInfoCtr _instance;
|
|
public static TestingCopyBuffInfoCtr Instance
|
|
{
|
|
get
|
|
{
|
|
if(_instance != null)
|
|
{
|
|
return _instance;
|
|
}
|
|
|
|
// LogModule.ErrorLog("TestingCopyBuffInfoCtr instance is null");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if(_instance == null)
|
|
{
|
|
_instance = this;
|
|
}
|
|
|
|
if(buffs != null && buffs.Count <= 0)
|
|
{
|
|
LogModule.ErrorLog("No buffs slot !!!");
|
|
}
|
|
|
|
for(int i = 0; i < buffs.Count; ++i)
|
|
{
|
|
buffs[i].Show(null);
|
|
buffs[i]._ClickEvent += OnBuffSelect;
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
descPanel.SetActive(false);
|
|
FunctionButtonLogic.Instance().HideBaseBtns();
|
|
FunctionButtonLogic.Instance().TempSwitchPanels.Add(this.gameObject);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
preShowBuff = null;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
FunctionButtonLogic.Instance().TempSwitchPanels.Remove(this.gameObject);
|
|
_instance = null;
|
|
}
|
|
|
|
public void SetBuffer(int buffId, int index = -1)
|
|
{
|
|
if(index == -1)
|
|
{
|
|
for (int i = 0; i < buffs.Count; ++i)
|
|
{
|
|
if (buffs[i].BuffInfo == null)
|
|
{
|
|
Hashtable hash = new Hashtable() { { "Info", buffId } };
|
|
buffs[i].Show(hash);
|
|
break;
|
|
}
|
|
|
|
if (i == buffs.Count - 1)
|
|
{
|
|
LogModule.ErrorLog("Can't replace, please specify index !!!");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(index >= buffs.Count || index < 0)
|
|
{
|
|
LogModule.ErrorLog("Wrong index");
|
|
return;
|
|
}
|
|
|
|
Hashtable hash = new Hashtable() { { "Info", buffId } };
|
|
buffs[index].Show(hash);
|
|
}
|
|
}
|
|
|
|
private void OnBuffSelect(object buffInfo)
|
|
{
|
|
Tab_Impact selectedBuffTab = buffInfo as Tab_Impact;
|
|
if(selectedBuffTab != null)
|
|
{
|
|
if(buffInfo == preShowBuff)
|
|
{
|
|
preShowBuff = null;
|
|
descPanel.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
preShowBuff = buffInfo;
|
|
bufferDesc.text = selectedBuffTab.Instruction;
|
|
descPanel.SetActive(true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
descPanel.SetActive(false);
|
|
}
|
|
}
|
|
}
|