using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using UnityEngine.UI;
|
|
class SpiritEquipBagWin : ILWindow
|
{
|
|
EquipPlaceCell dragonSpiritEqu;
|
EquipPlaceCell killWorldEqu;
|
EquipPlaceCell winEqu;
|
EquipPlaceCell eatGodEqu;
|
RawImage role;
|
ScrollerController gridLineCrtl;
|
Text powerText;
|
PackModel packModel;
|
|
RoleEquipType[] equTypes = new RoleEquipType[]
|
{
|
RoleEquipType.Guard,
|
RoleEquipType.Wing,
|
RoleEquipType.PeerlessWeapon1,
|
RoleEquipType.PeerlessWeapon2,
|
};
|
|
protected override void BindController()
|
{
|
base.BindController();
|
this.dragonSpiritEqu = this.transform.FindComponentEx<EquipPlaceCell>("Equ_DragonSpirit");
|
this.killWorldEqu = this.transform.FindComponentEx<EquipPlaceCell>("Equip_KillWorld");
|
this.winEqu = this.transform.FindComponentEx<EquipPlaceCell>("Equip_Wing");
|
this.eatGodEqu = this.transform.FindComponentEx<EquipPlaceCell>("Equip_EatGod");
|
this.role = this.transform.FindComponentEx<RawImage>("RoleBG");
|
this.gridLineCrtl = this.transform.FindComponentEx<ScrollerController>("Resolution/GridLineCtrl");
|
this.gridLineCrtl.OnRefreshCell += OnRefreshGridCell;
|
this.gridLineCrtl.vertical = true;
|
this.gridLineCrtl.lockType = EnhanceLockType.KeepVertical;
|
this.powerText = this.transform.FindComponentEx<Text>("Container_Power/Text_Power");
|
this.packModel = ModelCenter.Instance.GetModelEx<PackModel>();
|
}
|
|
|
protected override void OnAfterOpen()
|
{
|
base.OnAfterOpen();
|
RefreshUI();
|
SpiritEquipModel.Instance.refreshShowItemEvent += RefreshUI;
|
}
|
|
protected override void OnPreClose()
|
{
|
base.OnPreClose();
|
SpiritEquipModel.Instance.refreshShowItemEvent -= RefreshUI;
|
}
|
|
void RefreshUI()
|
{
|
this.RefreshEquCells();
|
this.OnCreateGridLineCell(this.gridLineCrtl);
|
UI3DModelExhibition.Instance.ShowPlayer(this.role, PlayerDatas.Instance.baseData.Job);
|
var totalScore = 0;
|
for (int i = 0; i < this.equTypes.Length; i++)
|
{
|
var place = new Int2(0, (int)equTypes[i]);
|
var index = EquipSet.ClientPlaceToServerPlace(place);
|
var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
|
if (itemModel != null)
|
{
|
var config = SpiritWeaponConfig.Get(itemModel.itemId);
|
if (config != null)
|
totalScore = totalScore + EquipFightPower.Instance.GetSpiritWeaponPower(itemModel.itemId);
|
else
|
DebugEx.LogErrorFormat("灵器属性表 未配置 ID:{0}", itemModel.itemId);
|
}
|
}
|
this.powerText.text = UIHelper.ReplaceLargeArtNum(totalScore);
|
}
|
|
void RefreshEquCells()
|
{
|
this.winEqu.Display(RoleEquipType.Wing);
|
this.dragonSpiritEqu.Display(RoleEquipType.Guard);
|
this.eatGodEqu.Display(RoleEquipType.PeerlessWeapon1);
|
this.killWorldEqu.Display(RoleEquipType.PeerlessWeapon2);
|
}
|
|
void OnCreateGridLineCell(ScrollerController gridCtrl)
|
{
|
if (gridCtrl.GetNumberOfCells(gridCtrl.m_Scorller) > 0)
|
gridCtrl.m_Scorller.RefreshActiveCellViews();
|
else
|
{
|
gridCtrl.Refresh();
|
for (int i = 0; i <= 19; i++)
|
{
|
gridCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
gridCtrl.Restart();
|
}
|
}
|
|
void OnRefreshGridCell(ScrollerDataType type, CellView cell)
|
{
|
var gridlineIndex = cell.index;
|
for (int i = 0; i < cell.transform.childCount; i++)
|
{
|
var gridCell = cell.transform.GetChild(i).GetComponentEx<GridCell>();
|
if (gridCell == null)
|
gridCell = cell.transform.GetChild(i).gameObject.AddComponentEx<GridCell>();
|
var cellCount = cell.transform.childCount * gridlineIndex + i;
|
gridCell.itemCell.SetActiveIL(false);
|
gridCell.gridLock.SetActive(false);
|
gridCell.cdImag.fillAmount = 0;
|
gridCell.cdImag.SetActiveIL(false);
|
var itemModel = SpiritEquipModel.Instance.showItemTable.Get(cellCount);
|
if (itemModel != null)
|
{
|
gridCell.itemCell.SetActiveIL(true);
|
gridCell.itemCell.Init(itemModel, true);
|
gridCell.itemCellBtn.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemModel.guid, true);
|
});
|
gridCell.SetModel(itemModel);
|
}
|
}
|
}
|
|
}
|