422 lines
13 KiB
C#
422 lines
13 KiB
C#
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using GCGame.Table;
|
|
using Games.Item;
|
|
using GCGame;
|
|
using System.Collections.Generic;
|
|
using Games.GlobeDefine;
|
|
using Games.LogicObj;
|
|
using Module.Log;
|
|
using Games.UserCommonData;
|
|
using System;
|
|
|
|
public class MagicTooltipLogic : MonoBehaviour
|
|
{
|
|
public MagicTooltipsInfo _ShowingMagicInfo;
|
|
public MagicTooltipsInfo _CompareMagicInfo;
|
|
public UISubScollMenu _PopMenu;
|
|
|
|
private GameItem m_Equip;
|
|
private ItemTooltipsLogic.ShowType m_Type;
|
|
|
|
private static GameItem m_curItem;
|
|
private static ItemTooltipsLogic.ShowType m_curType;
|
|
private static MagicTooltipLogic m_Instance = null;
|
|
public static MagicTooltipLogic Instance()
|
|
{
|
|
return m_Instance;
|
|
}
|
|
|
|
void Awake()
|
|
{
|
|
m_Instance = this;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
m_Instance = null;
|
|
}
|
|
|
|
public static void ShowEquipTooltip(GameItem equip, ItemTooltipsLogic.ShowType type, bool showCompare = true)
|
|
{
|
|
m_curItem = equip;
|
|
m_curType = type;
|
|
UIManager.ShowUI(UIInfo.MagicTooltipsRoot, MagicTooltipLogic.OnShowEquipTip, showCompare);
|
|
}
|
|
|
|
private static void OnShowEquipTip(bool bSuccess, object param)
|
|
{
|
|
if (!bSuccess)
|
|
{
|
|
LogModule.ErrorLog("load equiptooltip error");
|
|
return;
|
|
}
|
|
|
|
MagicTooltipLogic.Instance().ShowTooltips(m_curItem, m_curType, (bool)param);
|
|
}
|
|
|
|
public void CloseWindow()
|
|
{
|
|
UIManager.CloseUI(UIInfo.MagicTooltipsRoot);
|
|
}
|
|
|
|
private void ShowTooltips(GameItem equip, ItemTooltipsLogic.ShowType type, bool showCompare = true)
|
|
{
|
|
if (equip == null)
|
|
{
|
|
CloseWindow();
|
|
return;
|
|
}
|
|
if (equip.IsValid() == false)
|
|
{
|
|
CloseWindow();
|
|
return;
|
|
}
|
|
|
|
m_Equip = equip;
|
|
m_Type = type;
|
|
|
|
_ShowingMagicInfo.SetMagicInfo(equip);
|
|
_CompareMagicInfo.gameObject.SetActive(false);
|
|
|
|
_PopMenu.Clear();
|
|
_PopMenu.gameObject.SetActive(true);
|
|
|
|
if (type == ItemTooltipsLogic.ShowType.Info) //仅显示信息 没有操作按钮的tips
|
|
{
|
|
_PopMenu.gameObject.SetActive(false);
|
|
}
|
|
else if (type == ItemTooltipsLogic.ShowType.ShopBuy)
|
|
{
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4549}"));
|
|
}
|
|
else if (type == ItemTooltipsLogic.ShowType.ShopBuyBatch)
|
|
{
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4549}"));
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4574}"));
|
|
}
|
|
else if (type == ItemTooltipsLogic.ShowType.CangKu) //仓库界面 仓库物品tips
|
|
{
|
|
//显示取回按钮
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4576}"));
|
|
}
|
|
else if (type == ItemTooltipsLogic.ShowType.CangKuBackPack) //仓库界面 背包物品tips
|
|
{
|
|
//显示放入仓库按钮
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4573}"));
|
|
}
|
|
else if (type == ItemTooltipsLogic.ShowType.BuyBack) //回购
|
|
{
|
|
//显示回购按钮
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{1086}"));
|
|
}
|
|
else if (type == ItemTooltipsLogic.ShowType.GetPath)
|
|
{
|
|
//显示获取路径
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{5005}"));
|
|
}
|
|
else if (type == ItemTooltipsLogic.ShowType.LiveSkillGet)
|
|
{
|
|
//显示获取路径
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4753}"));
|
|
}
|
|
else if(type == ItemTooltipsLogic.ShowType.Equiped) //点击槽位弹出的tips
|
|
{
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{3876}"));
|
|
|
|
}
|
|
else if(type == ItemTooltipsLogic.ShowType.UnEquiped) //点击物品背包弹出的tips
|
|
{
|
|
if(HasMagic(equip.DataID))
|
|
{
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{42004}")); //佩戴
|
|
|
|
if (MagicClearWnd.IsCanClear(TableManager.GetCommonItemByID(equip.DataID, 0)) != null)
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{42006}")); //锻造
|
|
if (MagicCombinWnd.IsCanUP(equip.DataID))
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{42007}")); //合成
|
|
//售出按钮 显示
|
|
int cansell = TableManager.GetCommonItemByID(equip.DataID, 0).CanSell;
|
|
if (cansell == 1 && !equip.BindFlag)
|
|
{
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4578}")); //出售
|
|
}
|
|
|
|
|
|
_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{3877}")); //回收
|
|
}
|
|
else
|
|
{
|
|
_PopMenu.gameObject.SetActive(false);
|
|
}
|
|
//如果本装备位已经装备物品 弹出对比tips
|
|
int slotindex = equip.GetMagicSlotIndex();
|
|
GameItem CompareEquip = GameManager.gameManager.PlayerDataPool.MagicPack.GetItem(slotindex-1);
|
|
if (showCompare && CompareEquip != null && CompareEquip.IsValid())
|
|
{
|
|
OpenCompare(slotindex - 1);
|
|
}
|
|
}
|
|
else if(type == ItemTooltipsLogic.ShowType.Compare)
|
|
{
|
|
int slotindex = equip.GetMagicSlotIndex();
|
|
GameItem CompareEquip = GameManager.gameManager.PlayerDataPool.MagicPack.GetItem(slotindex - 1);
|
|
if (showCompare && CompareEquip != null && CompareEquip.IsValid())
|
|
{
|
|
OpenCompare(slotindex - 1);
|
|
}
|
|
|
|
_PopMenu.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
bool HasMagic(int ItemID)
|
|
{
|
|
GameItem gameItem = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByDataID(ItemID);
|
|
if (gameItem == null)
|
|
{
|
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|
if (Container != null)
|
|
{
|
|
gameItem = Container.GetItemByDataID(ItemID);
|
|
}
|
|
}
|
|
if (gameItem == null)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
void OpenCompare(int nEquipSlot)
|
|
{
|
|
GameItem equip = GameManager.gameManager.PlayerDataPool.MagicPack.GetItem(nEquipSlot);
|
|
if (equip != null && equip.IsValid())
|
|
{
|
|
_CompareMagicInfo.gameObject.SetActive(true);
|
|
_CompareMagicInfo.SetMagicInfo(equip);
|
|
}
|
|
}
|
|
|
|
public void OnBtnPopMenu(object menuObj)
|
|
{
|
|
string menuStr = menuObj as string;
|
|
|
|
if (menuStr == StrDictionary.GetClientDictionaryString("#{3876}"))
|
|
{
|
|
OnTakeOffClick(1);
|
|
}
|
|
else if (menuStr == StrDictionary.GetClientDictionaryString("#{3877}"))
|
|
{
|
|
EquipSell();
|
|
}
|
|
if (menuStr == StrDictionary.GetClientDictionaryString("#{42004}"))
|
|
{
|
|
if (m_Equip.BindFlag == false)
|
|
{
|
|
MessageBoxLogic.OpenOKCancelBox(41025, 1000, delegate ()
|
|
{
|
|
OnTakeOffClick(0);
|
|
}, null);
|
|
return;
|
|
}
|
|
|
|
OnTakeOffClick(0);
|
|
}
|
|
if (menuStr == StrDictionary.GetClientDictionaryString("#{42006}"))
|
|
{
|
|
OnShowMagicWin(1);
|
|
}
|
|
if (menuStr == StrDictionary.GetClientDictionaryString("#{42007}"))
|
|
{
|
|
OnShowMagicWin(2);
|
|
}
|
|
if (menuStr == StrDictionary.GetClientDictionaryString("#{4573}"))
|
|
{
|
|
CangKuIn();
|
|
}
|
|
if (menuStr == StrDictionary.GetClientDictionaryString("#{4576}"))
|
|
{
|
|
CangKuOut();
|
|
}
|
|
if (menuStr == StrDictionary.GetClientDictionaryString("#{3877}"))
|
|
{
|
|
ItemSell();
|
|
}
|
|
if (menuStr == StrDictionary.GetClientDictionaryString("#{1086}"))
|
|
{
|
|
ItemBuyBack();
|
|
}
|
|
if (menuStr == StrDictionary.GetClientDictionaryString("#{5005}"))
|
|
{
|
|
ShowItemGetPath();
|
|
}
|
|
else if (menuStr == StrDictionary.GetClientDictionaryString("#{4578}"))
|
|
{
|
|
// 出售
|
|
ItemMarket();
|
|
}
|
|
}
|
|
|
|
void ShowItemGetPath()
|
|
{
|
|
var pos = UIManager.Instance().UICamera.WorldToScreenPoint(transform.position);
|
|
ItemGetPathPopRoot.Show(m_Equip.DataID, pos);
|
|
|
|
CloseWindow();
|
|
}
|
|
|
|
void ItemBuyBack()
|
|
{
|
|
CG_SYSTEMSHOP_BUYBACK buyBackPacket = (CG_SYSTEMSHOP_BUYBACK)PacketDistributed.CreatePacket(MessageID.PACKET_CG_SYSTEMSHOP_BUYBACK);
|
|
buyBackPacket.SetShopId((int)GameItemContainer.Type.TYPE_BUYBACKPACK);
|
|
buyBackPacket.SetItemGuid(m_Equip.Guid);
|
|
buyBackPacket.SendPacket();
|
|
CloseWindow();
|
|
}
|
|
|
|
void ItemSellOK()
|
|
{
|
|
if (m_Equip != null && m_Equip.IsValid())
|
|
{
|
|
List<GameItem> selllist = new List<GameItem>();
|
|
selllist.Add(m_Equip);
|
|
SysShopController.SellItem((int)GameItemContainer.Type.TYPE_BACKPACK, selllist);
|
|
CloseWindow();
|
|
}
|
|
}
|
|
|
|
public void ItemSell()
|
|
{
|
|
if (m_Equip != null && m_Equip.IsValid())
|
|
{
|
|
SysShopController.m_TipSelDataID = m_Equip.DataID;
|
|
if (m_Equip.GetQuality() >= ItemQuality.QUALITY_BLUE)
|
|
{
|
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{4668}"), "", ItemSellOK, null);
|
|
}
|
|
else
|
|
{
|
|
ItemSellOK();
|
|
}
|
|
}
|
|
CloseWindow();
|
|
}
|
|
|
|
void ItemMarket()
|
|
{
|
|
var sysMarketItem = TableManager.GetExchangeMarketByID(m_Equip.DataID, 0);
|
|
if (sysMarketItem == null)
|
|
{
|
|
UIManager.ShowUI(UIInfo.MarketRoot, (sucess, param) =>
|
|
{
|
|
MarketLogic.Instance()._TagPanel.ShowPage(1);
|
|
MarketLogic.Instance()._MarketPlayerLogic._TagPanel.ShowPage(1);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
UIManager.ShowUI(UIInfo.MarketRoot, (sucess, param) =>
|
|
{
|
|
MarketLogic.Instance()._TagPanel.ShowPage(0);
|
|
MarketLogic.Instance()._MarketSysLogic.ShowSeletcedSell(m_Equip);
|
|
});
|
|
}
|
|
CloseWindow();
|
|
}
|
|
|
|
void CangKuIn()
|
|
{
|
|
if (m_Equip != null && m_Equip.IsValid() && null != Singleton<ObjManager>.Instance.MainPlayer)
|
|
{
|
|
Singleton<ObjManager>.Instance.MainPlayer.CangKuPutIn(m_Equip);
|
|
CloseWindow();
|
|
}
|
|
}
|
|
|
|
void CangKuOut()
|
|
{
|
|
if (m_Equip != null && m_Equip.IsValid() && null != Singleton<ObjManager>.Instance.MainPlayer)
|
|
{
|
|
Singleton<ObjManager>.Instance.MainPlayer.CangKuTakeOut(m_Equip);
|
|
CloseWindow();
|
|
}
|
|
}
|
|
|
|
|
|
public void OnShowMagicWin(int type)
|
|
{
|
|
MagicMain.ShowMagicPageStr(type);
|
|
CloseWindow();
|
|
}
|
|
|
|
public void EquipSell()
|
|
{
|
|
if (m_Equip != null && m_Equip.IsValid())
|
|
{
|
|
SysShopController.m_TipSelDataID = m_Equip.DataID;
|
|
if (m_Equip.GetQuality() >= ItemQuality.QUALITY_BLUE)
|
|
{
|
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{4668}"), "", EquipSellOK, null);
|
|
}
|
|
else
|
|
{
|
|
EquipSellOK();
|
|
}
|
|
}
|
|
CloseWindow();
|
|
}
|
|
|
|
void EquipSellOK()
|
|
{
|
|
if (m_Equip != null && m_Equip.IsValid())
|
|
{
|
|
List<GameItem> selllist = new List<GameItem>();
|
|
selllist.Add(m_Equip);
|
|
SysShopController.SellItem((int)GameItemContainer.Type.TYPE_BACKPACK, selllist);
|
|
CloseWindow();
|
|
}
|
|
}
|
|
|
|
public void OnTakeOffClick(int opera)
|
|
{
|
|
if (m_Equip == null || m_Equip.IsValid() == false)
|
|
return;
|
|
|
|
//if (Singleton<ObjManager>.Instance.MainPlayer == null)
|
|
// return;
|
|
int nPlayerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
|
if (nPlayerLevel < m_Equip.EquipUseLevel)
|
|
{
|
|
GUIData.AddNotifyData("#{1255}");
|
|
//Singleton<ObjManager>.GetInstance().MainPlayer.SendNoticMsg(false, "#{1255}");
|
|
return;
|
|
}
|
|
|
|
int equipProfession = m_Equip.GetProfessionRequire();
|
|
if (equipProfession > 0)
|
|
{
|
|
int nPlayerProfession = Singleton<ObjManager>.Instance.MainPlayer.Profession;
|
|
if (((equipProfession >> nPlayerProfession) & 1) == 0)
|
|
{
|
|
GUIData.AddNotifyData("#{1256}");
|
|
//Singleton<ObjManager>.GetInstance().MainPlayer.SendNoticMsg(false, "#{1256}");
|
|
return;
|
|
}
|
|
}
|
|
|
|
CG_HANDLE_MAGIC_WEAPON send = (CG_HANDLE_MAGIC_WEAPON)PacketDistributed.CreatePacket(MessageID.PACKET_CG_HANDLE_MAGIC_WEAPON);
|
|
send.SetGuid(m_Equip.Guid);
|
|
if(opera==0)
|
|
send.SetHandletype((int)CG_HANDLE_MAGIC_WEAPON.EMagicWeaponHandleType.EPutOn);
|
|
else
|
|
send.SetHandletype((int)CG_HANDLE_MAGIC_WEAPON.EMagicWeaponHandleType.ETakerOff);
|
|
send.SetPackType((int)GameItemContainer.Type.TYPE_MAGICPACK);
|
|
send.SendPacket();
|
|
CloseWindow();
|
|
}
|
|
} |