229 lines
8.4 KiB
C#
229 lines
8.4 KiB
C#
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using Games.Events;
|
|||
|
using Games.Item;
|
|||
|
|
|||
|
public class MagicClearWnd : MonoBehaviour
|
|||
|
{
|
|||
|
public Image MagicQuility;
|
|||
|
public Image CurrentSelectMagic;
|
|||
|
|
|||
|
public Image PayQuility;
|
|||
|
public Image PayIcon;
|
|||
|
public Text PayName;
|
|||
|
public Text PayNum;
|
|||
|
public GameObject PayBtn;
|
|||
|
public GameObject m_NoMagicTip;
|
|||
|
public GameObject m_QuilityTip;
|
|||
|
ulong currentSelect = Games.GlobeDefine.GlobeVar.INVALID_GUID;
|
|||
|
|
|||
|
public UIContainerSelect m_UIContainer;
|
|||
|
|
|||
|
public void InitStart()
|
|||
|
{
|
|||
|
PayBtn.SetActive(false);
|
|||
|
ShowMagicInBag();
|
|||
|
}
|
|||
|
|
|||
|
public static Tab_MagicWeaponRandCost IsCanClear(Tab_CommonItem tabItem)
|
|||
|
{
|
|||
|
if (tabItem == null)
|
|||
|
return null;
|
|||
|
foreach(var value in TableManager.GetMagicWeaponRandCost().Values)
|
|||
|
{
|
|||
|
if (tabItem.MinLevelRequire >= value.LevelMin && tabItem.MinLevelRequire <= value.LevelMax && tabItem.Quality == value.Color)
|
|||
|
return value;
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
public void ShowMagicInBag()
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool == null)
|
|||
|
return;
|
|||
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|||
|
if (Container == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
MagicQuility.gameObject.SetActive(false);
|
|||
|
CurrentSelectMagic.gameObject.SetActive(false);
|
|||
|
MagicClearItems.ItemInfo selectItem = null;
|
|||
|
List<MagicClearItems.ItemInfo> showList = new List<MagicClearItems.ItemInfo>();
|
|||
|
for (int i = 0; i < Container.ContainerSize; i++)
|
|||
|
{
|
|||
|
MagicClearItems.ItemInfo itemInfo = new MagicClearItems.ItemInfo();
|
|||
|
GameItem gameItem = Container.GetItem(i);
|
|||
|
if (gameItem.IsMagicMent())
|
|||
|
{
|
|||
|
itemInfo._canClear = IsCanClear(TableManager.GetCommonItemByID(gameItem.DataID, 0)) == null ? -1 : 1;
|
|||
|
itemInfo._GameItem = gameItem;
|
|||
|
showList.Add(itemInfo);
|
|||
|
if (MagicMain.Instance.needSelectId != Games.GlobeDefine.GlobeVar.INVALID_GUID && MagicMain.Instance.needSelectId == gameItem.Guid)
|
|||
|
{
|
|||
|
selectItem = itemInfo;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
List<GameItem> gameItems = GameManager.gameManager.PlayerDataPool.BackPack.GetList();
|
|||
|
int Count = gameItems.Count;
|
|||
|
for (int i = 0; i < Count; i++)
|
|||
|
{
|
|||
|
MagicClearItems.ItemInfo itemInfo = new MagicClearItems.ItemInfo();
|
|||
|
GameItem gameItem = gameItems[i];
|
|||
|
if (gameItem.IsMagicMent())
|
|||
|
{
|
|||
|
itemInfo._canClear = IsCanClear(TableManager.GetCommonItemByID(gameItem.DataID, 0)) == null ? -1 : 1;
|
|||
|
itemInfo._GameItem = gameItem;
|
|||
|
showList.Add(itemInfo);
|
|||
|
if (MagicMain.Instance.needSelectId != Games.GlobeDefine.GlobeVar.INVALID_GUID && MagicMain.Instance.needSelectId == gameItem.Guid)
|
|||
|
{
|
|||
|
selectItem = itemInfo;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
List<MagicClearItems.ItemInfo> selects = new List<MagicClearItems.ItemInfo>();
|
|||
|
if(showList.Count>0)
|
|||
|
{
|
|||
|
if (selectItem != null)
|
|||
|
selects.Add(selectItem);
|
|||
|
else
|
|||
|
selects.Add(showList[0]);
|
|||
|
}
|
|||
|
|
|||
|
if(m_UIContainer != null)
|
|||
|
{
|
|||
|
m_UIContainer.InitSelectContent(showList, selects, OnClickItemList, null);
|
|||
|
}
|
|||
|
m_NoMagicTip.SetActive(showList.Count <= 0);
|
|||
|
}
|
|||
|
|
|||
|
public void SetPayItem(int dataID)
|
|||
|
{
|
|||
|
Tab_CommonItem PayItem = TableManager.GetCommonItemByID(dataID, 0);
|
|||
|
if (PayItem != null && currentSelect == Games.GlobeDefine.GlobeVar.INVALID_GUID)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(PayIcon, PayItem.Icon);
|
|||
|
if (PayItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, PayItem.QualityEffect, PayIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, PayItem.QualityEffect, PayIcon.transform);
|
|||
|
}
|
|||
|
|
|||
|
PayName.text = PayItem.Name;
|
|||
|
int hasNum = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(dataID);
|
|||
|
PayNum.text = string.Format("{0}/{1}", hasNum, 0);
|
|||
|
PayBtn.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnClickItemList(object item)
|
|||
|
{
|
|||
|
if (item == null)
|
|||
|
return;
|
|||
|
MagicClearItems.ItemInfo gameItem = item as MagicClearItems.ItemInfo;
|
|||
|
if (gameItem == null || gameItem._GameItem==null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
Tab_CommonItem tabItem = TableManager.GetCommonItemByID(gameItem._GameItem.DataID, 0);
|
|||
|
if (tabItem == null)
|
|||
|
return;
|
|||
|
Tab_MagicWeaponRandCost data = IsCanClear(tabItem);
|
|||
|
if (data == null)
|
|||
|
{
|
|||
|
m_QuilityTip.SetActive(true);
|
|||
|
return;
|
|||
|
}
|
|||
|
m_QuilityTip.SetActive(false);
|
|||
|
currentSelect = gameItem._GameItem.Guid;
|
|||
|
CurrentSelectMagic.gameObject.SetActive(true);
|
|||
|
MagicQuility.gameObject.SetActive(true);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(MagicQuility, GCGame.Utils.GetItemQualityFrame(tabItem.Quality));
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(CurrentSelectMagic, tabItem.Icon);
|
|||
|
if (tabItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, tabItem.QualityEffect, CurrentSelectMagic.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, tabItem.QualityEffect, CurrentSelectMagic.transform);
|
|||
|
}
|
|||
|
|
|||
|
Tab_CommonItem PayItem = TableManager.GetCommonItemByID(data.ItemId, 0);
|
|||
|
if(PayItem!=null)
|
|||
|
{
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(PayIcon, PayItem.Icon);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(PayQuility, GCGame.Utils.GetItemQualityFrame(PayItem.Quality));
|
|||
|
if (tabItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, tabItem.QualityEffect, PayIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, tabItem.QualityEffect, PayIcon.transform);
|
|||
|
}
|
|||
|
|
|||
|
PayName.text = PayItem.Name;
|
|||
|
int hasNum = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(data.ItemId);
|
|||
|
if(hasNum<data.Num)
|
|||
|
{
|
|||
|
PayNum.text = string.Format("{2}{0}</color>/{1}",hasNum,data.Num, StrDictionary.GetClientDictionaryString("#{5526}"));
|
|||
|
PayBtn.SetActive(true);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PayNum.text = string.Format("{0}/{1}", hasNum, data.Num);
|
|||
|
PayBtn.SetActive(false);
|
|||
|
}
|
|||
|
m_currPayItemID = data.ItemId;
|
|||
|
}
|
|||
|
}
|
|||
|
int m_currPayItemID = -1;
|
|||
|
public void Click_GetPayItem()
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(m_currPayItemID, ItemTooltipsLogic.ShowType.GetPath, transform.position);
|
|||
|
}
|
|||
|
|
|||
|
public void Click_AskClear()
|
|||
|
{
|
|||
|
if(currentSelect == Games.GlobeDefine.GlobeVar.INVALID_GUID)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("{#41019}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
UIManager.ShowUI(UIInfo.MagicClearWndPath,delegate(bool sucee,object parma)
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
hash["GameItemID"] = currentSelect;
|
|||
|
EventDispatcher.Instance.SendMessage(Games.Events.EventId.MagicClearResult, hash);
|
|||
|
},null);
|
|||
|
}
|
|||
|
public void Click_NewItem()
|
|||
|
{
|
|||
|
GameItem gameItem = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByGuid(currentSelect);
|
|||
|
if (gameItem == null)
|
|||
|
{
|
|||
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|||
|
if (Container != null)
|
|||
|
{
|
|||
|
gameItem = Container.GetItemByGuid(currentSelect);
|
|||
|
if(gameItem!=null)
|
|||
|
{
|
|||
|
MagicTooltipLogic.ShowEquipTooltip(gameItem, ItemTooltipsLogic.ShowType.Equiped);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
MagicTooltipLogic.ShowEquipTooltip(gameItem, ItemTooltipsLogic.ShowType.UnEquiped);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|