using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using Games.GlobeDefine; using GCGame.Table; using Games.Item; public class TreasureItemLogic : UIControllerBase { public Transform m_Trans; public CommonItemPlotBase m_ItemSlot; public Text _BtnText; private GameItem _ShowingItem; private int _CommonItemID; void OnEnable() { SetInstance(this); } void OnDisable() { SetInstance(null); } // Update is called once per frame void Update () { ShowRemind(); } public void CloseWindow() { UIManager.CloseUI(UIInfo.TreasureItemRoot); } public static void InitItemInfo(GameItem gameItem) { Hashtable hash = new Hashtable(); hash.Add("GameItem", gameItem); UIManager.ShowUI(UIInfo.TreasureItemRoot, ShowUIOver, hash); } static void ShowUIOver(bool bSuccess, object param) { if (bSuccess) { Hashtable hash = param as Hashtable; GameItem gameItem = hash["GameItem"] as GameItem; if (TreasureItemLogic.Instance() != null) { TreasureItemLogic.Instance().ShowRemindItem(gameItem); } } } private void ShowRemindItem(GameItem gameitem) { _ShowingItem = gameitem; _CommonItemID = _ShowingItem.DataID; ShowRemind(); } void ShowRemind() { if (_ShowingItem == null) { return; } if (_ShowingItem.DataID != _CommonItemID) { GameItemContainer BackPack = GameManager.gameManager.PlayerDataPool.BackPack; var newItem = BackPack.GetItemByDataID(_CommonItemID); if (newItem == null) { CloseWindow(); return; } else { _ShowingItem = newItem; if (TresureItem.Instance.SearchItem != null) { TresureItem.Instance.UseTresureInUI(_ShowingItem); } } } if (!_ShowingItem.IsValid()) { CloseWindow(); return; } var showItem = _ShowingItem; m_ItemSlot.ShowItem(_ShowingItem); m_ItemSlot._ClickEvent = ShowItemTipsInfo; } 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() { TresureItem.Instance.UseTresureInUI(_ShowingItem); } }