117 lines
3.1 KiB
C#
117 lines
3.1 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.Item;
|
|||
|
|
|||
|
public class ItemRemindLogic : UIControllerBase<ItemRemindLogic>
|
|||
|
{
|
|||
|
public class ItemRemindInfo
|
|||
|
{
|
|||
|
public GameItem _GameItem;
|
|||
|
public string _BtnText;
|
|||
|
public UseItemCallBack _UseItemCallBack;
|
|||
|
}
|
|||
|
|
|||
|
public delegate bool UseItemCallBack(GameItem gameItem);
|
|||
|
|
|||
|
public Transform m_Trans;
|
|||
|
public CommonItemPlotBase m_ItemSlot;
|
|||
|
public Text _BtnText;
|
|||
|
|
|||
|
private Stack<ItemRemindInfo> m_ItemBuffer = new Stack<ItemRemindInfo>();
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
SetInstance(this);
|
|||
|
}
|
|||
|
|
|||
|
void OnDisable()
|
|||
|
{
|
|||
|
SetInstance(null);
|
|||
|
}
|
|||
|
|
|||
|
// Update is called once per frame
|
|||
|
void Update () {
|
|||
|
ShowRemind();
|
|||
|
}
|
|||
|
|
|||
|
public void CloseWindow()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.ItemRemindRoot);
|
|||
|
}
|
|||
|
|
|||
|
public static void InitItemInfo(GameItem gameItem, string useBtnText, UseItemCallBack useItemCallBack)
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash.Add("GameItem", gameItem);
|
|||
|
hash.Add("BtnText", useBtnText);
|
|||
|
hash.Add("UseItemCallBack", useItemCallBack);
|
|||
|
UIManager.ShowUI(UIInfo.ItemRemindRoot, ShowUIOver, hash);
|
|||
|
}
|
|||
|
|
|||
|
static void ShowUIOver(bool bSuccess, object param)
|
|||
|
{
|
|||
|
if (bSuccess)
|
|||
|
{
|
|||
|
Hashtable hash = param as Hashtable;
|
|||
|
GameItem gameItem = hash["GameItem"] as GameItem;
|
|||
|
string btnText = hash["BtnText"] as string;
|
|||
|
UseItemCallBack useItemCallBack = hash["UseItemCallBack"] as UseItemCallBack;
|
|||
|
if (ItemRemindLogic.Instance() != null)
|
|||
|
{
|
|||
|
//if (EquipRemindLogic.Instance() != null)
|
|||
|
//{
|
|||
|
// ItemRemindLogic.Instance().m_Trans.localPosition = new Vector3(210, 400, 0);
|
|||
|
//}
|
|||
|
ItemRemindLogic.Instance().ShowRemindItem(gameItem, btnText, useItemCallBack);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void ShowRemindItem(GameItem gameitem, string btnText, UseItemCallBack useItemCallBack)
|
|||
|
{
|
|||
|
ItemRemindInfo remindInfo = new ItemRemindInfo() { _GameItem = gameitem , _BtnText = btnText, _UseItemCallBack = useItemCallBack };
|
|||
|
m_ItemBuffer.Push(remindInfo);
|
|||
|
}
|
|||
|
|
|||
|
void ShowRemind()
|
|||
|
{
|
|||
|
if (m_ItemBuffer.Count == 0)
|
|||
|
return;
|
|||
|
|
|||
|
var showItem = m_ItemBuffer.Peek();
|
|||
|
m_ItemSlot.ShowItem(showItem._GameItem);
|
|||
|
m_ItemSlot._ClickEvent = ShowItemTipsInfo;
|
|||
|
_BtnText.text = showItem._BtnText;
|
|||
|
}
|
|||
|
|
|||
|
public void ShowItemTipsInfo(object itemObj)
|
|||
|
{
|
|||
|
GameItem gameItem = itemObj as GameItem;
|
|||
|
if (gameItem == null)
|
|||
|
return;
|
|||
|
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(gameItem, ItemTooltipsLogic.ShowType.Info, transform.position);
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnUse()
|
|||
|
{
|
|||
|
var useItem = m_ItemBuffer.Peek();
|
|||
|
bool isUseFinish = useItem._UseItemCallBack(useItem._GameItem);
|
|||
|
if (!isUseFinish)
|
|||
|
return;
|
|||
|
|
|||
|
if (m_ItemBuffer.Count > 0)
|
|||
|
{
|
|||
|
ShowRemind();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CloseWindow();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|