251 lines
8.0 KiB
C#
251 lines
8.0 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Games.Item;
|
|
using GCGame.Table;
|
|
using Module.Log;
|
|
using GCGame;
|
|
|
|
public class EquipGemLvUpLvPanel : UIControllerBase<EquipGemLvUpLvPanel>
|
|
{
|
|
void OnEnable()
|
|
{
|
|
SetInstance(this);
|
|
|
|
if (EquipGemLvUpRoot.Instance().SelectGem != null)
|
|
{
|
|
OnGemSelect();
|
|
}
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
SetInstance(null);
|
|
}
|
|
|
|
public void UpdateEquip()
|
|
{
|
|
_DestLevel = 0;
|
|
|
|
_MaterialSlot.UpdateNum(GetMatGemNum());
|
|
}
|
|
|
|
public void CloseWindow()
|
|
{
|
|
UIManager.ShowUI(UIInfo.EquipEnhance);
|
|
UIManager.CloseUI(UIInfo.EquipGemLvUp);
|
|
}
|
|
|
|
#region gem
|
|
|
|
public Text _CurName;
|
|
public Text _CurDesc;
|
|
public UIImgText _CurCombat;
|
|
public Text _DestName;
|
|
public Text _DestDesc;
|
|
public UIImgText _DestCombat;
|
|
public Text _DestNeedLevel;
|
|
public CommonItemMaterialSlot _MaterialSlot;
|
|
public GameObject _DestSelectPanel;
|
|
public UIContainerSelect _DestContainer;
|
|
public GameObject _CurLevelPanel;
|
|
public Vector3 _LvUpPos;
|
|
public Vector3 _LvMaxPos;
|
|
public GameObject _DescLevelPanel;
|
|
public GameObject _MaxLevelPanel;
|
|
|
|
private List<Tab_GemLvlUpConsume> _DestGems = new List<Tab_GemLvlUpConsume>();
|
|
private Tab_GemLvlUpConsume _SelectDest;
|
|
private Tab_GemLvlUpConsume _CurGemConsume;
|
|
private int _DestLevel = 0;
|
|
|
|
public void OnGemSelect()
|
|
{
|
|
|
|
var tabGem = TableManager.GetCommonItemByID(EquipGemLvUpRoot.Instance().SelectGem.DataID, 0);
|
|
|
|
string gemName = tabGem.Name;
|
|
//string levelStr = StrDictionary.GetClientDictionaryString("#{1166}", EquipGemLvUpRoot.Instance().SelectGem.Level);
|
|
_CurName.text = Utils.GetItemQualityColor(EquipGemLvUpRoot.Instance().SelectGem.GetQuality()) + gemName + "</color>";
|
|
|
|
int equipPos = EquipGemLvUpRoot.Instance().SelectEquip.GetEquipSlotIndex();
|
|
var propTab = EquipGemLvUpRoot.Instance().SelectGem.GetGemPropTab(equipPos);
|
|
string attrProStr = GemData.GetPropStr(propTab);
|
|
_CurGemConsume = EquipGemLvUpRoot.Instance().SelectGem.GetGemLvUpConsumeTab();
|
|
|
|
_CurDesc.text = attrProStr;
|
|
_CurCombat.text = StrDictionary.GetClientDictionaryString("#{2829}", propTab.CombatValue);
|
|
|
|
_DestGems.Clear();
|
|
var tabGemLvUps = TableManager.GetGemLvlUpConsume().Values;
|
|
foreach (var tabGemlvUP in tabGemLvUps)
|
|
{
|
|
if (tabGemlvUP.ConsumeSubType == _CurGemConsume.ConsumeSubType && tabGemlvUP.DesLevel > EquipGemLvUpRoot.Instance().SelectGem.Level)
|
|
{
|
|
_DestGems.Add(tabGemlvUP);
|
|
}
|
|
}
|
|
|
|
if (_DestGems.Count > 0)
|
|
{
|
|
_SelectDest = _DestGems[0];
|
|
SetDestGemInfo(_DestGems[0]);
|
|
_CurLevelPanel.transform.localPosition = _LvUpPos;
|
|
}
|
|
else
|
|
{
|
|
SetDestGemInfo(null);
|
|
_CurLevelPanel.transform.localPosition = _LvMaxPos;
|
|
}
|
|
|
|
}
|
|
|
|
private void SetDestGemInfo(Tab_GemLvlUpConsume tabNextGem)
|
|
{
|
|
if (tabNextGem == null)
|
|
{
|
|
_DescLevelPanel.gameObject.SetActive(false);
|
|
_MaxLevelPanel.gameObject.SetActive(true);
|
|
return;
|
|
}
|
|
_DescLevelPanel.gameObject.SetActive(true);
|
|
_MaxLevelPanel.gameObject.SetActive(false);
|
|
|
|
var tabDestGem = TableManager.GetCommonItemByID(tabNextGem.Id, 0);
|
|
|
|
string gemName = tabDestGem.Name;
|
|
_DestName.text = Utils.GetItemQualityColor(EquipGemLvUpRoot.Instance().SelectGem.GetQuality()) + gemName + "</color>";
|
|
|
|
int equipPos = EquipGemLvUpRoot.Instance().SelectEquip.GetEquipSlotIndex();
|
|
var propTab = GemData.GetGemPropTab(tabNextGem.Id, tabNextGem.DesLevel, equipPos) ;
|
|
string attrProStr = "";
|
|
for (int i = 0; i < propTab.getPropIDCount(); ++i)
|
|
{
|
|
if (propTab.GetPropIDbyIndex(i) < 0)
|
|
continue;
|
|
|
|
if (!string.IsNullOrEmpty(attrProStr))
|
|
{
|
|
attrProStr += "\n";
|
|
}
|
|
attrProStr += PropID.GetAttrValue((PropID.PropertyID)propTab.GetPropIDbyIndex(i), propTab.GetPropSubIDbyIndex(i), propTab.GetPropValuebyIndex(i));
|
|
}
|
|
_DestDesc.text = attrProStr;
|
|
_DestCombat.text = StrDictionary.GetClientDictionaryString("#{2829}", propTab.CombatValue);
|
|
|
|
var levelLimitTab = TableManager.GetGemInlayLvlLimitByID(tabNextGem.DesLevel, 0);
|
|
_DestLevel = levelLimitTab.MinLvl;
|
|
if (_DestLevel > 0)
|
|
{
|
|
if (_DestLevel > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level)
|
|
{
|
|
_DestNeedLevel.text = StrDictionary.GetClientDictionaryString("#{5530}") + StrDictionary.GetClientDictionaryString("#{4750}", _DestLevel) + "</color>";
|
|
}
|
|
else
|
|
{
|
|
_DestNeedLevel.text = StrDictionary.GetClientDictionaryString("#{4750}", _DestLevel);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_DestNeedLevel.text = "";
|
|
}
|
|
|
|
var matCnt = GetMatGemNum();
|
|
int comsumCnt = 0;
|
|
int lvUpIndex = _DestGems.IndexOf(tabNextGem);
|
|
for (int i = 0; i < lvUpIndex; ++i)
|
|
{
|
|
comsumCnt += _DestGems[i].ConsumeNum;
|
|
}
|
|
comsumCnt += _CurGemConsume.ConsumeNum;
|
|
_MaterialSlot.InitMaterial(_CurGemConsume.ConsumeSubType, comsumCnt, false, matCnt);
|
|
_MaterialSlot.UpdateNum(matCnt);
|
|
}
|
|
|
|
public void OnDestShow()
|
|
{
|
|
LogModule.DebugLog("OnDestShow");
|
|
if (_DestGems.Count == 0)
|
|
{
|
|
LogModule.DebugLog("满级");
|
|
return;
|
|
}
|
|
_DestSelectPanel.SetActive(true);
|
|
_DestContainer.InitSelectContent(_DestGems, new List<Tab_GemLvlUpConsume>() { _SelectDest }, OnDestSelect);
|
|
}
|
|
|
|
public void OnDestHide()
|
|
{
|
|
LogModule.DebugLog("OnDestHide");
|
|
_DestSelectPanel.SetActive(false);
|
|
}
|
|
|
|
public void OnDestSelect(object destObj)
|
|
{
|
|
Tab_GemLvlUpConsume gemLvUp = destObj as Tab_GemLvlUpConsume;
|
|
if (gemLvUp == null)
|
|
return;
|
|
|
|
_SelectDest = gemLvUp;
|
|
SetDestGemInfo(_SelectDest);
|
|
//OnDestHide();
|
|
}
|
|
|
|
public void OnBtnLevelUp()
|
|
{
|
|
//TestGem();
|
|
if (_DestLevel > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level)
|
|
{
|
|
GUIData.AddNotifyData("#{5327}");
|
|
return;
|
|
}
|
|
if (_MaterialSlot.IsMaterialEnough())
|
|
{
|
|
CG_GEM_LVL_UP packet = (CG_GEM_LVL_UP)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GEM_LVL_UP);
|
|
if (EquipGemLvUpRoot.Instance().SelectEquip.IsPlayerEquiped())
|
|
{
|
|
packet.Packtype = (int)GameItemContainer.Type.TYPE_EQUIPPACK;
|
|
}
|
|
else
|
|
{
|
|
packet.Packtype = (int)GameItemContainer.Type.TYPE_BACKPACK;
|
|
}
|
|
packet.Equipguid = EquipGemLvUpRoot.Instance().SelectEquip.Guid;
|
|
packet.Gemdataid = EquipGemLvUpRoot.Instance().SelectGem.DataID;
|
|
packet.Deslvl = _SelectDest.DesLevel;
|
|
packet.SendPacket();
|
|
}
|
|
else
|
|
{
|
|
_MaterialSlot.ShowGetPath();
|
|
}
|
|
}
|
|
|
|
private int GetMatGemNum()
|
|
{
|
|
int matCnt = 0;
|
|
var itemList = ItemTool.ItemFilter(GameManager.gameManager.PlayerDataPool.BackPack, 3, 5, true);
|
|
foreach (var gemItem in itemList)
|
|
{
|
|
var consumeTab = TableManager.GetGemLvlUpConsumeByID(gemItem.DataID);
|
|
if (consumeTab == null)
|
|
continue;
|
|
Debug.Log("gemItem.DataID:" + gemItem.DataID);
|
|
if (consumeTab.ConsumeSubType == _CurGemConsume.ConsumeSubType)
|
|
{
|
|
matCnt += consumeTab.GemMaterialCnt * gemItem.StackCount;
|
|
}
|
|
}
|
|
return matCnt;
|
|
}
|
|
|
|
private void TestGem()
|
|
{
|
|
EquipGemLvUpRoot.Instance().SelectGem.Level = _SelectDest.DesLevel;
|
|
UpdateEquip();
|
|
}
|
|
#endregion
|
|
}
|