using vnxbqy.UI;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
class EquipEvolveWin : ILWindow
|
{
|
ScrollerController scrollerRealm;
|
ScrollerController scrollerEquip;
|
ItemCell tagetItemCell;
|
Transform proEmpty;
|
Transform proShow;
|
List<Text> countTexts = new List<Text>();
|
List<ItemCell> materialItems = new List<ItemCell>();
|
List<Image> lockImages = new List<Image>();
|
Text fromText;
|
Text toText;
|
Transform evolveShow;
|
ScrollerController scrollerProperty;
|
Button evolveBtn;
|
Button decomposeBtn;
|
|
Text Base1Txt_Current;
|
Text Base1Txt_Next;
|
Text Base2Txt_Current;
|
Text Base2Txt_Next;
|
List<Text> LegendCurrent = new List<Text>();
|
List<Text> LegendNext = new List<Text>();
|
List<Transform> PropertyLines = new List<Transform>();
|
Transform BasePropertyLine_2;
|
Transform LegendTitle;
|
|
int equipID = 0; //当前选中的装备
|
int finalEquipID = 0; //进阶到最高级时的装备ID
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
#region Built-in
|
protected override void BindController()
|
{
|
scrollerRealm = proxy.GetWidgtEx<ScrollerController>("ScrollerRealm");
|
scrollerEquip = proxy.GetWidgtEx<ScrollerController>("ScrollerEquip");
|
tagetItemCell = proxy.GetWidgtEx<ItemCell>("tagetItemCell");
|
materialItems.Add(proxy.GetWidgtEx<ItemCell>("Material1"));
|
materialItems.Add(proxy.GetWidgtEx<ItemCell>("Material2"));
|
proEmpty = proxy.GetWidgtEx<Transform>("Container_Empty");
|
proShow = proxy.GetWidgtEx<Transform>("Container_Details");
|
countTexts.Add(proxy.GetWidgtEx<Text>("Count1"));
|
countTexts.Add(proxy.GetWidgtEx<Text>("Count2"));
|
lockImages.Add(proxy.GetWidgtEx<Image>("Img_Lock1"));
|
lockImages.Add(proxy.GetWidgtEx<Image>("Img_Lock2"));
|
fromText = proxy.GetWidgtEx<Text>("fromText");
|
toText = proxy.GetWidgtEx<Text>("toText");
|
evolveShow = proxy.GetWidgtEx<Transform>("Container_EvolveText");
|
scrollerProperty = proxy.GetWidgtEx<ScrollerController>("ScrollerProperty");
|
evolveBtn = proxy.GetWidgtEx<Button>("Btn_Evolve");
|
decomposeBtn = proxy.GetWidgtEx<Button>("BtnDecompose");
|
|
Base1Txt_Current = proxy.GetWidgtEx<Text>("Base1Txt_Current");
|
Base1Txt_Next = proxy.GetWidgtEx<Text>("Base1Txt_Next");
|
Base2Txt_Current = proxy.GetWidgtEx<Text>("Base2Txt_Current");
|
Base2Txt_Next = proxy.GetWidgtEx<Text>("Base2Txt_Next");
|
LegendCurrent.Add(proxy.GetWidgtEx<Text>("Legend1Txt_Current"));
|
LegendCurrent.Add(proxy.GetWidgtEx<Text>("Legend2Txt_Current"));
|
LegendCurrent.Add(proxy.GetWidgtEx<Text>("Legend3Txt_Current"));
|
LegendNext.Add(proxy.GetWidgtEx<Text>("Legend1Txt_Next"));
|
LegendNext.Add(proxy.GetWidgtEx<Text>("Legend2Txt_Next"));
|
LegendNext.Add(proxy.GetWidgtEx<Text>("Legend3Txt_Next"));
|
PropertyLines.Add(proxy.GetWidgtEx<Transform>("PropertyLine_1"));
|
PropertyLines.Add(proxy.GetWidgtEx<Transform>("PropertyLine_2"));
|
PropertyLines.Add(proxy.GetWidgtEx<Transform>("PropertyLine_3"));
|
BasePropertyLine_2 = proxy.GetWidgtEx<Transform>("BasePropertyLine_2");
|
LegendTitle = proxy.GetWidgtEx<Transform>("Img_Title");
|
}
|
|
protected override void AddListeners()
|
{
|
decomposeBtn.SetListener(()=> {
|
WindowCenter.Instance.OpenIL<EquipShenDecomposeWin>();
|
});
|
|
evolveBtn.SetListener(OnEvolve);
|
}
|
|
/// <summary>
|
/// 没有红点提示,可以定位第一件可进阶装备
|
/// </summary>
|
protected override void OnPreOpen()
|
{
|
equipID = 0;
|
finalEquipID = 0;
|
if (EquipEvolveModel.Instance.materialJumpPos == Int2.zero)
|
{
|
var equipPos = EquipEvolveModel.Instance.FindSatisfyEquip();
|
EquipEvolveModel.Instance.selectLevelType = equipPos.x;
|
EquipEvolveModel.Instance.selectPlaceType = equipPos.y;
|
}
|
else
|
{
|
EquipEvolveModel.Instance.selectLevelType = EquipEvolveModel.Instance.materialJumpPos.x;
|
EquipEvolveModel.Instance.selectPlaceType = EquipEvolveModel.Instance.materialJumpPos.y;
|
EquipEvolveModel.Instance.materialJumpPos = Int2.zero;
|
}
|
|
scrollerRealm.OnRefreshCell += OnRefreshRealmCell;
|
scrollerEquip.OnRefreshCell += OnRefreshEquipCell;
|
EquipEvolveModel.Instance.SelectLevelEvent += SelectLevelEvent;
|
EquipEvolveModel.Instance.SelectPlaceEvent += SelectPlaceEvent;
|
packModel.refreshItemCountEvent += RefreshItemCount;
|
scrollerProperty.OnRefreshCell += OnRefreshProperty;
|
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
Display();
|
}
|
|
protected override void OnPreClose()
|
{
|
scrollerRealm.OnRefreshCell -= OnRefreshRealmCell;
|
scrollerEquip.OnRefreshCell -= OnRefreshEquipCell;
|
EquipEvolveModel.Instance.SelectLevelEvent -= SelectLevelEvent;
|
EquipEvolveModel.Instance.SelectPlaceEvent -= SelectPlaceEvent;
|
packModel.refreshItemCountEvent -= RefreshItemCount;
|
scrollerProperty.OnRefreshCell -= OnRefreshProperty;
|
}
|
|
#endregion
|
|
|
void Display()
|
{
|
CreateLevelBehaviours();
|
CreateEquipBehaviours();
|
ShowEvolveItem();
|
}
|
|
#region 境界装备
|
private void OnRefreshRealmCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetILBehaviour<EquipRealmCell>();
|
if (_cell == null) return;
|
Debug.LogFormat("OnRefreshRealmCell: {0}", cell.index);
|
_cell.Display(cell.index);
|
}
|
|
|
private void OnRefreshEquipCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetILBehaviour<EquipEvolveCell>();
|
if (_cell == null) return;
|
_cell.Display(cell.index);
|
}
|
|
|
|
private void CreateLevelBehaviours()
|
{
|
var levels = equipModel.GetUnLockedEquipSets();
|
|
scrollerRealm.Refresh();
|
for (int i = 0; i < levels.Count; i++)
|
{
|
scrollerRealm.AddCell(ScrollerDataType.Header, levels[i]);
|
}
|
scrollerRealm.Restart();
|
|
}
|
|
void CreateEquipBehaviours()
|
{
|
scrollerEquip.Refresh();
|
for (int j = 1; j < 12; j++)
|
{
|
scrollerEquip.AddCell(ScrollerDataType.Header, j);
|
|
}
|
scrollerEquip.Restart();
|
scrollerEquip.JumpIndex(EquipEvolveModel.Instance.selectPlaceType - 1);
|
}
|
|
void SelectLevelEvent()
|
{
|
scrollerRealm.m_Scorller.RefreshActiveCellViews();
|
scrollerEquip.m_Scorller.RefreshActiveCellViews();
|
ShowEvolveItem();
|
}
|
|
void SelectPlaceEvent()
|
{
|
scrollerEquip.m_Scorller.RefreshActiveCellViews();
|
ShowEvolveItem();
|
}
|
|
#endregion
|
|
#region 装备材料区
|
void ShowEvolveItem()
|
{
|
var position = new Int2(EquipEvolveModel.Instance.selectLevelType, EquipEvolveModel.Instance.selectPlaceType);
|
var equipGuid = equipModel.GetEquip(position);
|
for (int i = 0; i < materialItems.Count; i++)
|
{
|
materialItems[i].SetActiveIL(false);
|
countTexts[i].SetActiveIL(false);
|
lockImages[i].SetActiveIL(true);
|
}
|
proEmpty.SetActiveIL(false);
|
proShow.SetActiveIL(false);
|
evolveShow.SetActiveIL(false);
|
|
if (string.IsNullOrEmpty(equipGuid))
|
{
|
tagetItemCell.SetActiveIL(false);
|
proEmpty.SetActiveIL(true);
|
proShow.SetActiveIL(false);
|
return;
|
}
|
tagetItemCell.SetActiveIL(true);
|
var equipItem = packModel.GetItemByGuid(equipGuid);
|
if (equipItem == null)
|
return;
|
|
equipID = equipItem.itemId;
|
var model = new ItemCellModel(equipID, false, (ulong)equipItem.count);
|
tagetItemCell.Init(model);
|
tagetItemCell.button.SetListener(() =>
|
{
|
ItemTipUtility.Show(equipGuid, false);
|
});
|
|
var materials = ILEquipShenEvolveConfig.TryGetMaterial(equipID);
|
if (materials == null)
|
{
|
proEmpty.SetActiveIL(true);
|
proShow.SetActiveIL(false);
|
return;
|
}
|
|
proEmpty.SetActiveIL(false);
|
proShow.SetActiveIL(true);
|
evolveShow.SetActiveIL(true);
|
|
|
//材料
|
for (int i = 0; i < materials.Length; i++)
|
{
|
if (i >= materialItems.Count)
|
{
|
continue;
|
}
|
materialItems[i].SetActiveIL(true);
|
var itemID = materials[i][0];
|
var count = packModel.GetItemCountByID(PackType.Item, itemID);
|
var materialModel = new ItemCellModel(itemID, false, 1);
|
materialItems[i].Init(materialModel);
|
materialItems[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemID);
|
});
|
countTexts[i].SetActiveIL(true);
|
countTexts[i].text = UIHelper.AppendColor(count >= materials[i][1] ? TextColType.Green : TextColType.Red, count + "/" + materials[i][1]);
|
lockImages[i].SetActiveIL(false);
|
}
|
|
//显示下一进阶品质
|
fromText.text = Language.Get("ShenEquipText" + EquipEvolveModel.Instance.GetRedEquipQuality(equipID));
|
toText.text = Language.Get("ShenEquipText" + EquipEvolveModel.Instance.GetRedEquipQuality(ILEquipShenEvolveConfig.Get(equipID).EvolveID));
|
|
ShowPro();
|
}
|
|
void RefreshItemCount(PackType packType, int index, int itemID)
|
{
|
if (packType == PackType.Equip)
|
{
|
ShowEvolveItem();
|
scrollerEquip.m_Scorller.RefreshActiveCellViews();
|
}
|
}
|
|
#endregion
|
|
#region 属性区
|
void ShowPro()
|
{
|
ShowBasePro();
|
ShowLegendPro();
|
CreateEvolveProperty();
|
}
|
|
|
//基础
|
void ShowBasePro()
|
{
|
var nextEquipID = ILEquipShenEvolveConfig.Get(equipID).EvolveID;
|
var equipConfig = ItemConfig.Get(equipID);
|
var nextEquipConfig = ItemConfig.Get(nextEquipID);
|
Base1Txt_Current.text = StringUtility.Contact(PlayerPropertyConfig.Get(equipConfig.Effect1).Name, ":", PlayerPropertyConfig.GetValueDescription(equipConfig.Effect1, equipConfig.EffectValueA1));
|
Base1Txt_Next.text = PlayerPropertyConfig.GetValueDescription(nextEquipConfig.Effect1, nextEquipConfig.EffectValueA1);
|
BasePropertyLine_2.SetActiveIL(false);
|
if (equipConfig.Effect2 != 0)
|
{
|
BasePropertyLine_2.SetActiveIL(true);
|
Base2Txt_Current.text = StringUtility.Contact(PlayerPropertyConfig.Get(equipConfig.Effect2).Name, ":", PlayerPropertyConfig.GetValueDescription(equipConfig.Effect2, equipConfig.EffectValueA2));
|
Base2Txt_Next.text = PlayerPropertyConfig.GetValueDescription(nextEquipConfig.Effect2, nextEquipConfig.EffectValueA2);
|
}
|
|
}
|
|
void ShowLegendPro()
|
{
|
for (int i = 0; i < PropertyLines.Count; i++)
|
{
|
PropertyLines[i].SetActiveIL(false);
|
}
|
var position = new Int2(EquipEvolveModel.Instance.selectLevelType, EquipEvolveModel.Instance.selectPlaceType);
|
var equipGuid = equipModel.GetEquip(position);
|
|
var nextEquipID = ILEquipShenEvolveConfig.Get(equipID).EvolveID;
|
var config = EquipShenAttrConfig.Get(nextEquipID);
|
if (config == null)
|
{
|
return;
|
}
|
var curEquipLegends = ILItemCommon.GetLegendProperty(equipGuid);
|
int index = 0;
|
bool hasLegend = false;
|
for (int i = 0; i < config.LegendAttrID.Length; i++)
|
{
|
int curValue = 0;
|
var proValue = config.LegendAttrValue[i];
|
var proID = config.LegendAttrID[i];
|
curEquipLegends.TryGetValue(proID, out curValue);
|
if (curValue == proValue)
|
{
|
continue;
|
}
|
PropertyLines[index].SetActiveIL(true);
|
LegendCurrent[index].text = StringUtility.Contact(PlayerPropertyConfig.Get(proID).Name, ":", PlayerPropertyConfig.GetValueDescription(proID, curValue));
|
LegendNext[index].text = PlayerPropertyConfig.GetValueDescription(proID, proValue);
|
index++;
|
hasLegend = true;
|
}
|
|
LegendTitle.SetActiveIL(hasLegend);
|
}
|
|
|
void CreateEvolveProperty()
|
{
|
finalEquipID = EquipEvolveModel.Instance.GetFinalEvolveEquip(equipID);
|
var equipInfo = EquipShenAttrConfig.Get(finalEquipID);
|
if (equipInfo == null) return;
|
int count = equipInfo.ShenAttrID.Length + equipInfo.XianAttrID.Length + equipInfo.JiAttrID.Length;
|
scrollerProperty.Refresh();
|
for (int i = 0; i < count; i++)
|
{
|
scrollerProperty.AddCell(ScrollerDataType.Header, i);
|
}
|
scrollerProperty.Restart();
|
|
}
|
|
void OnRefreshProperty(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetILBehaviour<EvolvePropertyCell>();
|
if (_cell == null) return;
|
_cell.Display(finalEquipID, equipID, cell.index);
|
}
|
|
|
#endregion
|
|
#region 操作区
|
|
void OnEvolve()
|
{
|
var materials = ILEquipShenEvolveConfig.TryGetMaterial(equipID);
|
if (materials == null)
|
{
|
return;
|
}
|
for (int i = 0; i < materials.Length; i++)
|
{
|
var count = packModel.GetItemCountByID(PackType.Item, materials[i][0]);
|
if (count < materials[i][1])
|
{
|
//材料不足
|
SysNotifyMgr.Instance.ShowTip("NotEnoughMaterial");
|
return;
|
}
|
LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(4, materials[i][0], materials[i][1], 1,0);
|
}
|
//记录用于成功后的展示
|
EquipEvolveModel.Instance.resultFromEquipID = equipID;
|
EquipEvolveModel.Instance.resultToEquipID = ILEquipShenEvolveConfig.Get(equipID).EvolveID;
|
var position = new Int2(EquipEvolveModel.Instance.selectLevelType, EquipEvolveModel.Instance.selectPlaceType);
|
EquipEvolveModel.Instance.fromEquipLegends = ILItemCommon.GetLegendProperty(equipModel.GetEquip(position));
|
|
var pak = new IL_CA330_tagCMEquipEvolve();
|
pak.EquipIndex = (byte)EquipSet.ClientPlaceToServerPlace(new Int2(EquipEvolveModel.Instance.selectLevelType,
|
EquipEvolveModel.Instance.selectPlaceType));
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
#endregion
|
}
|