using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using vnxbqy.UI;
|
|
|
class SpiritEquipBreachWin : ILWindow
|
{
|
|
PackModel packModel;
|
|
Transform equGridContainer;
|
Transform breachMatContainer;
|
Transform prefabs;
|
ItemCell nowItemCell;
|
ItemCell nextItemCell;
|
Text nowText;
|
Text nextText;
|
Transform maxTip;
|
Transform emptyTip;
|
Transform equAttrContainer;
|
Transform breachBg;
|
Transform otherBg;
|
Transform attrBg;
|
Transform breachEquContianer;
|
Button breachButton;
|
RawImage equShow;
|
RectTransform equShowRT;
|
Button FosterButton;
|
|
RoleEquipType[] equTypes = new RoleEquipType[]
|
{
|
RoleEquipType.Guard,
|
RoleEquipType.Wing,
|
RoleEquipType.PeerlessWeapon1,
|
RoleEquipType.PeerlessWeapon2,
|
};
|
|
int[] euqPlaceNameIDs = new int[] { 14, 13, 16, 17 };
|
|
bool bIsCanBreach = false;
|
RoleEquipType curEquType;
|
int lessMatID;
|
|
List<MatGridBehaviour> matGridBehaviours = new List<MatGridBehaviour>();
|
List<EquGridBehaviour> equGridBehaviours = new List<EquGridBehaviour>();
|
List<Text> attrTexts = new List<Text>();
|
|
protected override void BindController()
|
{
|
base.BindController();
|
this.packModel = ModelCenter.Instance.GetModelEx<PackModel>();
|
this.equGridContainer = this.transform.Find("Container_EquGrid");
|
this.breachMatContainer = this.transform.Find("Container_BreachEqu/Container_BreachMat");
|
this.prefabs = this.transform.Find("Prefabs");
|
this.nowItemCell = this.transform.FindComponentEx<ItemCell>("Container_BreachEqu/ItemCell_Now");
|
this.nextItemCell = this.transform.FindComponentEx<ItemCell>("Container_BreachEqu/ItemCell_Next");
|
this.nowText = this.transform.FindComponentEx<Text>("Container_BreachEqu/Text_Now");
|
this.nextText = this.transform.FindComponentEx<Text>("Container_BreachEqu/Text_Next");
|
this.maxTip = this.transform.Find("Text_MaxTip");
|
this.emptyTip = this.transform.Find("Text_EmptyTip");
|
this.equAttrContainer = this.transform.Find("Container_EquShow/Container_EquAttr");
|
this.breachBg = this.transform.Find("Cotainer_Bg/Img_Bg_1");
|
this.otherBg = this.transform.Find("Cotainer_Bg/Img_Bg_2");
|
this.attrBg = this.transform.Find("Cotainer_Bg/Img_Bg_8");
|
this.breachEquContianer = this.transform.Find("Container_BreachEqu");
|
this.breachButton = this.transform.FindComponentEx<Button>("Btn_Breach");
|
this.equShow = this.transform.FindComponentEx<RawImage>("Container_EquShow/EquShow");
|
this.equShowRT = this.transform.FindComponentEx<RectTransform>("Container_EquShow/EquShow");
|
this.FosterButton = this.transform.FindComponentEx<ButtonEx>("Container_EquShow/FosterBtn");
|
}
|
|
protected override void AddListeners()
|
{
|
base.AddListeners();
|
this.breachButton.SetListener(() =>
|
{
|
OnBreachButtonDown();
|
});
|
|
this.FosterButton.SetListener(() =>
|
{
|
OnFosterButtonDown();
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
base.OnPreOpen();
|
RefreshUI();
|
SpiritEquipModel.Instance.IsEquipBreachOpen = true;
|
}
|
|
protected override void OnAfterOpen()
|
{
|
base.OnAfterOpen();
|
SpiritEquipModel.Instance.refreshShowItemEvent += this.RefreshUI;
|
}
|
|
protected override void OnPreClose()
|
{
|
base.OnPreClose();
|
SpiritEquipModel.Instance.refreshShowItemEvent -= this.RefreshUI;
|
SpiritEquipModel.Instance.IsEquipBreachOpen = false;
|
}
|
void OnFosterButtonDown()
|
{
|
if (FosterModel.Instance.CheckLingQiOpen((int)curEquType,true))
|
{
|
WindowJumpMgr.Instance.WindowJumpToEx("FosterWin");
|
}
|
}
|
void OnBreachButtonDown()
|
{
|
if (this.bIsCanBreach)
|
{
|
SpiritEquipModel.Instance.SendBreachInfo(this.curEquType);
|
this.bIsCanBreach = false;
|
}
|
else
|
{
|
var info = new ItemTipUtility.ItemViewInfo();
|
info.itemId = this.lessMatID;
|
info.unfoldGetWay = true;
|
ItemTipUtility.Show(info);
|
SysNotifyMgr.Instance.ShowTip("SpiritOrgan1");
|
}
|
}
|
|
void RefreshUI()
|
{
|
if (this.equGridContainer.childCount == 0)
|
{
|
var equGridPrefab = this.prefabs.Find("EquGrid");
|
for (int i = 0; i < this.equTypes.Length; i++)
|
{
|
var equType = this.equTypes[i];
|
var equGrid = GameObject.Instantiate(equGridPrefab, this.equGridContainer);
|
equGrid.SetActiveIL(true);
|
equGrid.transform.Find("RedPoint").GetComponent<RedpointBehaviour>().redpointId = 1910200 + (int)equType;
|
equGrid.localScale = Vector3.one;
|
var behaviour = new EquGridBehaviour();
|
behaviour.BindController(equGrid, () =>
|
{
|
for (int j = 0; j < equGridBehaviours.Count; j++)
|
{
|
var bh = equGridBehaviours[j];
|
bh.equGridBtn.interactable = true;
|
}
|
behaviour.equGridBtn.interactable = false;
|
this.curEquType = equType;
|
this.ShowCurPlaceEqu();
|
//显示培养红点
|
SpiritEquipModel.Instance.ShowFosterRedPoint((int)equType);
|
}, 1910200 + (int)equType);
|
var place = new Int2(0, (int)equType);
|
var index = EquipSet.ClientPlaceToServerPlace(place);
|
var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
|
var name = GeneralDefine.equipPlaceNameDict[this.euqPlaceNameIDs[i]];
|
behaviour.Init(itemModel, Language.Get("SpiritEquipText_2", name));
|
this.equGridBehaviours.Add(behaviour);
|
|
}
|
this.equGridBehaviours[0].equGridBtn.interactable = false;
|
this.curEquType = this.equTypes[0];
|
}
|
else
|
{
|
for (int i = 0; i < this.equTypes.Length; i++)
|
{
|
var equType = this.equTypes[i];
|
var place = new Int2(0, (int)equType);
|
var index = EquipSet.ClientPlaceToServerPlace(place);
|
var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
|
var name = GeneralDefine.equipPlaceNameDict[this.euqPlaceNameIDs[i]];
|
this.equGridBehaviours[i].Init(itemModel, Language.Get("SpiritEquipText_2", name));
|
}
|
}
|
this.ShowCurPlaceEqu();
|
}
|
|
void ShowCurPlaceEqu()
|
{
|
this.bIsCanBreach = false;
|
var place = new Int2(0, (int)this.curEquType);
|
var index = EquipSet.ClientPlaceToServerPlace(place);
|
var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
|
if (itemModel == null)
|
{
|
this.breachButton.SetActiveIL(false);
|
//装备未穿戴
|
this.equShow.SetActiveIL(false);
|
this.breachEquContianer.SetActiveIL(false);
|
this.equAttrContainer.SetActiveIL(false);
|
this.attrBg.SetActiveIL(false);
|
this.otherBg.SetActiveIL(true);
|
this.breachBg.SetActiveIL(false);
|
this.maxTip.SetActiveIL(false);
|
this.emptyTip.SetActiveIL(true);
|
this.FosterButton.SetActiveIL(false);
|
}
|
else
|
{
|
this.FosterButton.SetActiveIL(true);
|
//显示培养红点
|
SpiritEquipModel.Instance.ShowFosterRedPoint((int) curEquType);
|
|
this.equShow.SetActiveIL(true);
|
var config = SpiritWeaponConfig.Get(itemModel.itemId);
|
var nowId = itemModel.itemId;
|
var nextId = config.NextItemID;
|
var bIsMaxLevle = (nextId == 0);
|
SpiritEquipModel.Instance.curEquType = this.curEquType;
|
//展示模型
|
if (this.curEquType == RoleEquipType.Wing)
|
UI3DModelExhibition.Instance.ShowWing(config.NPCID, this.equShow);
|
else if (this.curEquType == RoleEquipType.Guard)
|
UI3DModelExhibition.Instance.ShowNPC(config.NPCID, Vector3.zero, this.equShow, false, false);
|
else
|
UI3DModelExhibition.Instance.ShowEquipment(ItemConfig.Get(nowId).ChangeOrd, config.Rotation, config.scale, this.equShow);
|
this.equShowRT.anchoredPosition3D = config.RawImgPos;
|
|
//设置装备条目属性
|
SpiritWeaponConfig nextItemConfig = null;
|
var attrCount = config.AttrIDList.Length;
|
var beforeAttrValueTable = new Dictionary<int, int>();
|
for (int i = 0; i < config.AttrIDList.Length; i++)
|
beforeAttrValueTable[config.AttrIDList[i]] = config.AttrValueList[i];
|
|
var beforeAttrs = SpiritEquipModel.Instance.GetBaseProperty(nowId).baseProperties;
|
var baseAttrCount = beforeAttrs.Count;
|
|
List<Int2> afterBaseAttrs = null;
|
if (bIsMaxLevle == false)
|
{
|
afterBaseAttrs = SpiritEquipModel.Instance.GetBaseProperty(nextId).baseProperties;
|
baseAttrCount = afterBaseAttrs.Count;
|
nextItemConfig = SpiritWeaponConfig.Get(nextId);
|
attrCount = nextItemConfig.AttrIDList.Length;
|
}
|
|
var totalAttrCount = attrCount + baseAttrCount;
|
var attrLerpCount = totalAttrCount - this.attrTexts.Count;
|
var attrPrefab = this.prefabs.Find("AttrGrid");
|
for (int i = 0; i < attrLerpCount; i++)
|
{
|
var attrGrid = GameObject.Instantiate(attrPrefab, this.equAttrContainer);
|
attrGrid.SetActiveIL(true);
|
attrGrid.localScale = Vector3.one;
|
var attrText = attrGrid.FindComponentEx<Text>("Text_Info");
|
attrTexts.Add(attrText);
|
}
|
|
for (int i = 0; i < attrTexts.Count; i++)
|
{
|
var attrText = attrTexts[i];
|
if (i >= totalAttrCount)
|
attrText.transform.parent.SetActiveIL(false);
|
else
|
{
|
attrText.transform.parent.SetActiveIL(true);
|
PlayerPropertyConfig attrConfig;
|
var nowAttrValue = 0;
|
var afterAttrValue = 0;
|
if (i >= baseAttrCount)
|
{
|
var id = i - baseAttrCount;
|
if (nextItemConfig != null)
|
{
|
afterAttrValue = nextItemConfig.AttrValueList[id];
|
attrConfig = PlayerPropertyConfig.Get(nextItemConfig.AttrIDList[id]);
|
beforeAttrValueTable.TryGetValue(nextItemConfig.AttrIDList[id], out nowAttrValue);
|
}
|
else
|
{
|
attrConfig = PlayerPropertyConfig.Get(config.AttrIDList[id]);
|
nowAttrValue = config.AttrValueList[id];
|
}
|
}
|
else
|
{
|
if (afterBaseAttrs != null)
|
afterAttrValue = afterBaseAttrs[i].y;
|
if (i < beforeAttrs.Count)
|
{
|
attrConfig = PlayerPropertyConfig.Get(beforeAttrs[i].x);
|
nowAttrValue = beforeAttrs[i].y;
|
}
|
else
|
{
|
attrConfig = PlayerPropertyConfig.Get(afterBaseAttrs[i].x);
|
}
|
}
|
|
var attrName = "";
|
var attrCurValue = "";
|
var attrAddValue = "";
|
|
attrName = attrConfig.Name;
|
attrCurValue = PlayerPropertyConfig.GetValueDescription(attrConfig.ID, nowAttrValue, false);
|
if (afterAttrValue != 0 && afterAttrValue - nowAttrValue > 0)
|
attrAddValue = "+" + PlayerPropertyConfig.GetValueDescription(attrConfig.ID, afterAttrValue - nowAttrValue, false);
|
|
attrText.text = Language.Get("SpiritEquipText_1", attrName, attrCurValue, attrAddValue);
|
}
|
}
|
|
if (bIsMaxLevle)
|
{
|
this.breachButton.SetActiveIL(false);
|
//装备满级
|
this.breachEquContianer.SetActiveIL(false);
|
this.equAttrContainer.SetActiveIL(true);
|
this.attrBg.SetActiveIL(true);
|
this.otherBg.SetActiveIL(true);
|
this.breachBg.SetActiveIL(false);
|
this.maxTip.SetActiveIL(true);
|
this.emptyTip.SetActiveIL(false);
|
}
|
else
|
{
|
this.breachButton.SetActiveIL(true);
|
this.bIsCanBreach = true;
|
|
//SpiritEquipModel.Instance.breachBtnRedPoint.state = SpiritEquipModel.Instance.redPoints[(int)this.curEquType].state;
|
if(SpiritEquipModel.Instance.redBreachDic[(int)this.curEquType])
|
{
|
SpiritEquipModel.Instance.breachBtnRedPoint.state = RedPointState.Simple;
|
}
|
else
|
{
|
SpiritEquipModel.Instance.breachBtnRedPoint.state = RedPointState.None;
|
}
|
|
//装备可升级
|
this.breachEquContianer.SetActiveIL(true);
|
this.equAttrContainer.SetActiveIL(true);
|
this.attrBg.SetActiveIL(true);
|
this.otherBg.SetActiveIL(false);
|
this.breachBg.SetActiveIL(true);
|
this.maxTip.SetActiveIL(false);
|
this.emptyTip.SetActiveIL(false);
|
|
//显示升级前后
|
this.nowItemCell.Init(new ItemCellModel(nowId));
|
this.nextItemCell.Init(new ItemCellModel(nextId));
|
this.nowText.text = ItemConfig.Get(nowId).ItemName;
|
this.nextText.text = ItemConfig.Get(nextId).ItemName;
|
this.nowItemCell.button.SetListener(() =>
|
{
|
ItemTipUtility.Show(nowId);
|
});
|
this.nextItemCell.button.SetListener(() =>
|
{
|
ItemTipUtility.Show(nextId);
|
});
|
|
//显示升级材料
|
var bHasDecideLessMat = false;
|
var lerpCount = config.UpCostItem.Length - this.matGridBehaviours.Count;
|
var matGridPrefab = this.prefabs.Find("MatGrid");
|
for (int i = 0; i < lerpCount; i++)
|
{
|
var matGrid = UnityEngine.Object.Instantiate(matGridPrefab, this.breachMatContainer);
|
matGrid.SetActiveIL(true);
|
matGrid.localScale = Vector3.one;
|
var matGridBehaviour = new MatGridBehaviour();
|
matGridBehaviour.BindController(matGrid);
|
matGridBehaviours.Add(matGridBehaviour);
|
}
|
for (int i = 0; i < matGridBehaviours.Count; i++)
|
{
|
var bh = matGridBehaviours[i];
|
if (i >= config.UpCostItem.Length)
|
bh.Init();
|
else
|
{
|
var remainCount = this.packModel.GetItemCountByID(PackType.Item, config.UpCostItem[i].x);
|
bh.Init(config.UpCostItem[i], remainCount);
|
if (remainCount < config.UpCostItem[i].y)
|
{
|
this.bIsCanBreach = false;
|
if (bHasDecideLessMat == false)
|
{
|
bHasDecideLessMat = true;
|
this.lessMatID = config.UpCostItem[i].x;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|