353 lines
12 KiB
C#
353 lines
12 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 MagicCombinWnd : MonoBehaviour
|
|
{
|
|
public Image UpQuilityImage;
|
|
public Image PayQuilityImage1;
|
|
public Image PayQuilityImage2;
|
|
public Image NewQuilityImage;
|
|
public Image UpImage;
|
|
public Image PayImage1;
|
|
public Image PayImage2;
|
|
public Image NewImage;
|
|
public GameObject UpBtn;
|
|
public GameObject Disable_UpBtn;
|
|
public GameObject newNameGo;
|
|
public Text newName;
|
|
public GameObject m_NoMagicTip;
|
|
public GameObject m_QuilityTip;
|
|
|
|
GameItem UpSelect = null;
|
|
GameItem PaySelect1 = null;
|
|
GameItem PaySelect2 = null;
|
|
|
|
public UIContainerSelect m_UIContainer;
|
|
|
|
public void InitStart()
|
|
{
|
|
UpQuilityImage.gameObject.SetActive(false);
|
|
PayQuilityImage1.gameObject.SetActive(false);
|
|
PayQuilityImage2.gameObject.SetActive(false);
|
|
NewQuilityImage.gameObject.SetActive(false);
|
|
UpImage.gameObject.SetActive(false);
|
|
PayImage1.gameObject.SetActive(false);
|
|
PayImage2.gameObject.SetActive(false);
|
|
NewImage.gameObject.SetActive(false);
|
|
newNameGo.SetActive(false);
|
|
UpSelect = null;
|
|
PaySelect1 = null;
|
|
PaySelect2 = null;
|
|
UpBtnState();
|
|
ShowMagicInBag();
|
|
}
|
|
public void ShowMagicInBag()
|
|
{
|
|
if (GameManager.gameManager.PlayerDataPool == null)
|
|
return;
|
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|
if (Container == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
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 = IsCanUP(gameItem.DataID) ? 1 : 0;
|
|
itemInfo._GameItem = gameItem;
|
|
showList.Add(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 = IsCanUP(gameItem.DataID) ? 1 : 0;
|
|
itemInfo._GameItem = gameItem;
|
|
showList.Add(itemInfo);
|
|
}
|
|
}
|
|
if (m_UIContainer != null)
|
|
{
|
|
m_UIContainer.InitContentItem(showList, OnClickItemList, null);
|
|
}
|
|
m_NoMagicTip.SetActive(showList.Count <= 0);
|
|
}
|
|
|
|
public static bool IsCanUP(int ItemID)
|
|
{
|
|
Tab_MagicWeaponUpgrade upGrade = TableManager.GetMagicWeaponUpgradeByID(ItemID, 0);
|
|
if (upGrade == null)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
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;
|
|
|
|
if (IsCanUP(tabItem.Id) == false)
|
|
return;
|
|
GameItemContainer Container = GameManager.gameManager.PlayerDataPool.GetItemContainer(GameItemContainer.Type.TYPE_MAGICPACK);
|
|
if (Container == null)
|
|
{
|
|
return;
|
|
}
|
|
if (Container.GetItemIdx(gameItem._GameItem) >=0)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{41013}"));
|
|
return;
|
|
}
|
|
int num = GameManager.gameManager.PlayerDataPool.BackPack.GetItemCountByDataId(tabItem.Id);
|
|
if (UpSelect != null && gameItem._GameItem == UpSelect)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{40308}"));
|
|
return;
|
|
}
|
|
if (PaySelect1 != null && gameItem._GameItem == PaySelect1)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{40308}"));
|
|
return;
|
|
}
|
|
if (PaySelect2 != null && gameItem._GameItem == PaySelect2)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{40308}"));
|
|
return;
|
|
}
|
|
if (UpSelect==null)
|
|
{
|
|
UpImage.gameObject.SetActive(true);
|
|
UpQuilityImage.gameObject.SetActive(true);
|
|
LoadAssetBundle.Instance.SetImageSprite(UpQuilityImage, GCGame.Utils.GetItemQualityFrame(tabItem.Quality));
|
|
LoadAssetBundle.Instance.SetImageSprite(UpImage, tabItem.Icon);
|
|
if (tabItem.QualityEffect > 0)
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(true, tabItem.QualityEffect, UpImage.transform);
|
|
}
|
|
else
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(false, tabItem.QualityEffect, UpImage.transform);
|
|
}
|
|
|
|
Tab_MagicWeaponUpgrade upGrade = TableManager.GetMagicWeaponUpgradeByID(tabItem.Id, 0);
|
|
if (upGrade != null)
|
|
{
|
|
Tab_CommonItem item1 = TableManager.GetCommonItemByID(upGrade.NewItemId, 0);
|
|
if(item1!=null)
|
|
{
|
|
NewImage.gameObject.SetActive(true);
|
|
NewQuilityImage.gameObject.SetActive(true);
|
|
LoadAssetBundle.Instance.SetImageSprite(NewQuilityImage, GCGame.Utils.GetItemQualityFrame(item1.Quality));
|
|
LoadAssetBundle.Instance.SetImageSprite(NewImage, item1.Icon);
|
|
if (item1.QualityEffect > 0)
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(true, item1.QualityEffect, NewImage.transform);
|
|
}
|
|
else
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(false, item1.QualityEffect, NewImage.transform);
|
|
}
|
|
|
|
newNameGo.SetActive(true);
|
|
newName.text = item1.Name;
|
|
}
|
|
}
|
|
UpSelect = gameItem._GameItem;
|
|
UpBtnState();
|
|
m_QuilityTip.SetActive((int)UpSelect.GetQuality() >= (int)ItemQuality.QUALITY_GOLD);
|
|
return;
|
|
}
|
|
m_QuilityTip.SetActive((int)UpSelect.GetQuality() >= (int)ItemQuality.QUALITY_GOLD);
|
|
Tab_CommonItem upselectItem = TableManager.GetCommonItemByID(UpSelect.DataID, 0);
|
|
if (upselectItem == null)
|
|
return;
|
|
if(upselectItem.MinLevelRequire!=tabItem.MinLevelRequire || upselectItem.Quality != tabItem.Quality)
|
|
{
|
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{41014}"));
|
|
return;
|
|
}
|
|
|
|
if (PaySelect1 == null)
|
|
{
|
|
PayImage1.gameObject.SetActive(true);
|
|
PayQuilityImage1.gameObject.SetActive(true);
|
|
LoadAssetBundle.Instance.SetImageSprite(PayQuilityImage1, GCGame.Utils.GetItemQualityFrame(tabItem.Quality));
|
|
LoadAssetBundle.Instance.SetImageSprite(PayImage1, tabItem.Icon);
|
|
if (tabItem.QualityEffect > 0)
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(true, tabItem.QualityEffect, PayImage1.transform);
|
|
}
|
|
else
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(false, tabItem.QualityEffect, PayImage1.transform);
|
|
}
|
|
|
|
PaySelect1 = gameItem._GameItem;
|
|
UpBtnState();
|
|
return;
|
|
}
|
|
|
|
if (PaySelect2 == null)
|
|
{
|
|
PayImage2.gameObject.SetActive(true);
|
|
PayQuilityImage2.gameObject.SetActive(true);
|
|
LoadAssetBundle.Instance.SetImageSprite(PayQuilityImage2, GCGame.Utils.GetItemQualityFrame(tabItem.Quality));
|
|
LoadAssetBundle.Instance.SetImageSprite(PayImage2, tabItem.Icon);
|
|
if (tabItem.QualityEffect > 0)
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(true, tabItem.QualityEffect, PayImage2.transform);
|
|
}
|
|
else
|
|
{
|
|
CommonItemContainerItem.ShowQualityEffect(false, tabItem.QualityEffect, PayImage2.transform);
|
|
}
|
|
|
|
PaySelect2 = gameItem._GameItem;
|
|
UpBtnState();
|
|
return;
|
|
}
|
|
}
|
|
|
|
public void UpdateSelects()
|
|
{
|
|
List<GameItem> selects = new List<GameItem>();
|
|
if (UpSelect != null)
|
|
selects.Add(UpSelect);
|
|
if (PaySelect1 != null)
|
|
selects.Add(PaySelect1);
|
|
if (PaySelect2 != null)
|
|
selects.Add(PaySelect2);
|
|
m_UIContainer.SetSelect(selects);
|
|
}
|
|
|
|
public void Click_Item(int index)
|
|
{
|
|
if(index==0)
|
|
{
|
|
PaySelect1 = null;
|
|
PayImage1.gameObject.SetActive(false);
|
|
PayQuilityImage1.gameObject.SetActive(false);
|
|
}
|
|
if (index == 2)
|
|
{
|
|
PaySelect2 = null;
|
|
PayImage2.gameObject.SetActive(false);
|
|
PayQuilityImage2.gameObject.SetActive(false);
|
|
}
|
|
if (index == 1)
|
|
{
|
|
PaySelect1 = null;
|
|
PayImage1.gameObject.SetActive(false);
|
|
PaySelect2 = null;
|
|
PayImage2.gameObject.SetActive(false);
|
|
UpSelect = null;
|
|
UpImage.gameObject.SetActive(false);
|
|
NewImage.gameObject.SetActive(false);
|
|
newNameGo.SetActive(false);
|
|
|
|
UpQuilityImage.gameObject.SetActive(false);
|
|
PayQuilityImage1.gameObject.SetActive(false);
|
|
PayQuilityImage2.gameObject.SetActive(false);
|
|
NewQuilityImage.gameObject.SetActive(false);
|
|
|
|
}
|
|
UpBtnState();
|
|
}
|
|
|
|
public void UpBtnState()
|
|
{
|
|
if (UpSelect != null && PaySelect1 != null && PaySelect2 != null)
|
|
{
|
|
UpBtn.SetActive(true);
|
|
Disable_UpBtn.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
UpBtn.SetActive(false);
|
|
Disable_UpBtn.SetActive(true);
|
|
}
|
|
UpdateSelects();
|
|
}
|
|
|
|
private void SendUpMsg()
|
|
{
|
|
CG_MAGIC_WEAPON_UPGRADE send = (CG_MAGIC_WEAPON_UPGRADE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_MAGIC_WEAPON_UPGRADE);
|
|
|
|
GameItem upitem = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByGuid(UpSelect.Guid);
|
|
if (upitem == null)
|
|
return;
|
|
send.AddItemguids(upitem.Guid);
|
|
GameItem pay1item = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByGuid(PaySelect1.Guid);
|
|
if (pay1item == null)
|
|
return;
|
|
send.AddItemguids(pay1item.Guid);
|
|
GameItem pay2item = GameManager.gameManager.PlayerDataPool.BackPack.GetItemByGuid(PaySelect2.Guid);
|
|
if (pay2item == null)
|
|
return;
|
|
send.AddItemguids(pay2item.Guid);
|
|
send.SendPacket();
|
|
}
|
|
|
|
public void UpClick()
|
|
{
|
|
if (UpSelect == null || PaySelect1==null || PaySelect2==null)
|
|
return;
|
|
|
|
if(UpSelect.BindFlag == true || PaySelect1.BindFlag == true || PaySelect2.BindFlag == true)
|
|
{
|
|
MessageBoxLogic.OpenOKCancelBox(41026, 1000, delegate ()
|
|
{
|
|
SendUpMsg();
|
|
}, null);
|
|
return;
|
|
}
|
|
|
|
SendUpMsg();
|
|
}
|
|
|
|
public void Click_Tip()
|
|
{
|
|
MessageHelpLogic.ShowHelpMessage(37);
|
|
}
|
|
|
|
public void Click_NewItem()
|
|
{
|
|
if (UpSelect != null)
|
|
{
|
|
Tab_MagicWeaponUpgrade upGrade = TableManager.GetMagicWeaponUpgradeByID(UpSelect.DataID, 0);
|
|
if (upGrade != null)
|
|
{
|
|
Tab_CommonItem item = TableManager.GetCommonItemByID(upGrade.NewItemId, 0);
|
|
if (item != null)
|
|
{
|
|
GameItem gameItem = new GameItem();
|
|
gameItem.DataID = upGrade.NewItemId;
|
|
MagicTooltipLogic.ShowEquipTooltip(gameItem, ItemTooltipsLogic.ShowType.UnEquiped);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |