//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, June 11, 2019
|
//--------------------------------------------------------
|
|
using UnityEngine.UI;
|
using System.Collections.Generic;
|
using vnxbqy.UI;
|
using UnityEngine;
|
using LitJson;
|
|
|
public class TreasurePavilionTipWin : ILWindow
|
{
|
Text name;
|
Image gubaoImg;
|
Button m_Close;
|
List<Transform> starObjs = new List<Transform>();
|
Text pieceCnt;
|
Text scoreText;
|
RichText descText;
|
List<Text> baseAttrList = new List<Text>();
|
List<Text> starAttrList = new List<Text>();
|
Button showWayBtn;
|
Button activeBtn;
|
Button starUpBtn;
|
Button lvUpBtn;
|
TipGetWaysWidget getWaysTips;
|
RedpointBehaviour lvRedpoint;
|
RedpointBehaviour starRedpoint;
|
RedpointBehaviour activeRedpoint;
|
|
RedpointBehaviour getRedpoint;
|
Transform awardObj;
|
Button getAwardBtn;
|
ItemCell awardItem;
|
Text awardText;
|
//古宝共鸣相关
|
Transform Content1;
|
ScrollerController scroller;
|
ScrollerController scroller1;
|
TextEx txtTitle;
|
PackModel packModel { get { return ModelCenter.Instance.GetModelEx<PackModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
name = proxy.GetWidgtEx<Text>("Txt_Name");
|
gubaoImg = proxy.GetWidgtEx<Image>("Icon");
|
var canvas = gubaoImg.AddMissingComponent<Canvas>();
|
canvas.sortingLayerName = "UI"; //使图片在特效上层
|
m_Close = proxy.GetWidgtEx<Button>("Btn_Close");
|
for (int i = 0; i < 10; i++)
|
{
|
starObjs.Add(proxy.GetWidgtEx<Transform>("starBG" + i));
|
}
|
pieceCnt = proxy.GetWidgtEx<Text>("cnt");
|
scoreText = proxy.GetWidgtEx<Text>("score");
|
descText = proxy.GetWidgtEx<RichText>("Txt_Description");
|
for (int i = 0; i < 3; i++)
|
{
|
baseAttrList.Add(proxy.GetWidgtEx<Text>("Txt_BaseAttr" + i));
|
}
|
for (int i = 0; i < 4; i++)
|
{
|
starAttrList.Add(proxy.GetWidgtEx<Text>("Txt_StarAttr" + i));
|
}
|
showWayBtn = proxy.GetWidgtEx<Button>("GetItemBtn");
|
activeBtn = proxy.GetWidgtEx<Button>("Btn_Operate_3");
|
starUpBtn = proxy.GetWidgtEx<Button>("Btn_Operate_2");
|
lvUpBtn = proxy.GetWidgtEx<Button>("Btn_Operate_1");
|
getWaysTips = proxy.GetWidgtEx<TipGetWaysWidget>("GetWaysTips");
|
lvRedpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPointLV");
|
starRedpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPointStar");
|
activeRedpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPointActive");
|
|
getRedpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPointGet");
|
awardObj = proxy.GetWidgtEx<Transform>("Widget_Item");
|
getAwardBtn = proxy.GetWidgtEx<Button>("Btn_Operate_4");
|
awardItem = proxy.GetWidgtEx<ItemCell>("itemCell");
|
awardText = proxy.GetWidgtEx<Text>("Txt_GetTip");
|
|
//古宝共鸣相关
|
Content1 = proxy.GetWidgtEx<Transform>("Content1");
|
scroller = proxy.GetWidgtEx<ScrollerController>("scroller");
|
scroller1 = proxy.GetWidgtEx<ScrollerController>("scroller1");
|
txtTitle = proxy.GetWidgtEx<TextEx>("txtTitle");
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.SetListener(() =>
|
{
|
CloseWin<TreasurePavilionTipWin>();
|
});
|
|
showWayBtn.SetListener(() =>
|
{
|
if (getWaysTips.gameObject.activeSelf)
|
{
|
getWaysTips.SetActiveIL(false);
|
}
|
else
|
{
|
getWaysTips.Bind("TreasurePavilionTipWin");
|
var config = ILGubaoConfig.Get(TreasurePavilionModel.Instance.selectGubao);
|
getWaysTips.Display(ILItemCommon.GetGetWay(config.UnlockItemID));
|
}
|
});
|
|
activeBtn.SetListener(() =>
|
{
|
TreasurePavilionModel.Instance.ActiveGubao(TreasurePavilionModel.Instance.selectGubao);
|
CloseWin<TreasurePavilionTipWin>();
|
});
|
|
starUpBtn.SetListener(() =>
|
{
|
CloseWin<TreasurePavilionTipWin>();
|
CloseWin<TreasurePavilionWin>();
|
TreasurePavilionModel.Instance.upgradeFuncOrder = 0;
|
TreasurePavilionModel.Instance.upgradeGubao = TreasurePavilionModel.Instance.selectGubao;
|
WindowJumpMgr.Instance.ClearJumpData();
|
WindowCenter.Instance.OpenIL<TreasurePavilionUpgradeWin>();
|
});
|
|
lvUpBtn.SetListener(() =>
|
{
|
CloseWin<TreasurePavilionTipWin>();
|
CloseWin<TreasurePavilionWin>();
|
TreasurePavilionModel.Instance.upgradeFuncOrder = 1;
|
TreasurePavilionModel.Instance.upgradeGubao = TreasurePavilionModel.Instance.selectGubao;
|
WindowJumpMgr.Instance.ClearJumpData();
|
WindowCenter.Instance.OpenIL<TreasurePavilionUpgradeWin>();
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
scroller.OnRefreshCell += OnRefreshCell;
|
scroller1.OnRefreshCell += OnRefreshCell1;
|
getWaysTips.SetActiveIL(false);
|
var gubaoID = TreasurePavilionModel.Instance.selectGubao;
|
var gubaoInfo = TreasurePavilionModel.Instance.TryGetGubaoInfo(gubaoID);
|
var config = ILGubaoConfig.Get(gubaoID);
|
Debug.LogFormat("古宝ID:{0} 物品ID:{1}", gubaoID, config.UnlockItemID);
|
if (gubaoInfo.Count > 0 && gubaoInfo[1] > 0)
|
{
|
name.text = config.Name + "+" + gubaoInfo[1];
|
}
|
else
|
{
|
name.text = config.Name;
|
}
|
name.color = UIHelper.GetUIColor(config.GubaoQuality);
|
gubaoImg.SetSprite(config.Icon);
|
|
var maxStar = ILGubaoStarConfig.GetMaxStar(gubaoID);
|
for (int i = 0; i < starObjs.Count; i++)
|
{
|
if (i < maxStar)
|
{
|
starObjs[i].SetActiveIL(true);
|
if (gubaoInfo.Count > 0 && gubaoInfo[0] > i)
|
{
|
starObjs[i].Find("star").GetComponent<Image>().SetActiveIL(true);
|
}
|
else
|
{
|
starObjs[i].Find("star").GetComponent<Image>().SetActiveIL(false);
|
}
|
}
|
else
|
{
|
starObjs[i].SetActiveIL(false);
|
}
|
}
|
var hasCnt = TreasurePavilionModel.Instance.GetGubaoItemCount(gubaoID);//packModel.GetItemCountByID(PackType.Item, config.UnlockItemID);
|
pieceCnt.text = hasCnt.ToString();
|
var score = TreasurePavilionModel.Instance.GetGubaoScore(gubaoID);
|
scoreText.SetActiveIL(score != 0);
|
scoreText.text = Language.Get("DogzFunc106", score);
|
descText.text = config.Desc;
|
var showLV = gubaoInfo.Count == 0 ? 1 : gubaoInfo[1]; //未激活显示0级
|
var lvConfig = ILGubaoLVConfig.Get(ILGubaoLVConfig.GetGubaoQualityLVIndex(config.GubaoType, config.GubaoQuality, showLV));
|
for (int i = 0; i < baseAttrList.Count; i++)
|
{
|
if (i < lvConfig.LVAttrTypeList.Length)
|
{
|
baseAttrList[i].SetActiveIL(true);
|
baseAttrList[i].text = PlayerPropertyConfig.GetFullDescription(lvConfig.LVAttrTypeList[i], lvConfig.LVAttrValueList[i]);
|
}
|
else
|
{
|
baseAttrList[i].SetActiveIL(false);
|
}
|
}
|
|
var starEffectsInfo = TreasurePavilionModel.Instance.GetGubaoEffects(gubaoID);
|
|
for (int i = 0; i < starAttrList.Count; i++)
|
{
|
if (i < starEffectsInfo.Count)
|
{
|
starAttrList[i].SetActiveIL(true);
|
starAttrList[i].text = starEffectsInfo[i];
|
}
|
else
|
{
|
starAttrList[i].SetActiveIL(false);
|
}
|
}
|
|
activeBtn.SetActiveIL(gubaoInfo.Count == 0 && hasCnt >= config.UnlockItemCnt);
|
starUpBtn.SetActiveIL(gubaoInfo.Count != 0 && maxStar > 1);
|
lvUpBtn.SetActiveIL(gubaoInfo.Count != 0);
|
|
activeRedpoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.selectGubao) * 10;
|
starRedpoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.selectGubao) * 10 + 1;
|
lvRedpoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.selectGubao) * 10 + 2;
|
getRedpoint.redpointId = (MainRedPoint.cbgRedpoint * 10000 + TreasurePavilionModel.Instance.selectGubao) * 10 + 3;
|
|
|
var showStar = gubaoInfo.Count == 0 ? 1 : gubaoInfo[0];
|
var starConfig = ILGubaoStarConfig.Get(ILGubaoStarConfig.GetGubaoStarIndex(gubaoID, showStar));
|
|
int effID = starConfig.StarEffIDList[0];
|
if (effID != 0 && ILGubaoEffAttrConfig.Get(effID).EffItemAwardList.Length > 2)
|
{
|
awardObj.SetActiveIL(true);
|
var effConfig = ILGubaoEffAttrConfig.Get(effID);
|
var items = JsonMapper.ToObject<int[][]>(effConfig.EffItemAwardList);
|
int itemID = items[0][0];
|
awardItem.Init(new ItemCellModel(itemID, false, (ulong)items[0][1]));
|
|
awardItem.itemIcon.SetSprite("");
|
var count = 0;
|
if (TreasurePavilionModel.Instance.gubaoAwardDict.ContainsKey(gubaoID))
|
{
|
count = TreasurePavilionModel.Instance.gubaoAwardDict[gubaoID] / effConfig.EffCond;
|
}
|
awardText.text = Language.Get("gubaoGet", count);
|
|
getAwardBtn.SetActiveIL(count > 0);
|
getAwardBtn.SetListener(() =>
|
{
|
var pak = new IL_CA504_tagCMPlayerGetReward();
|
pak.RewardType = 58;
|
pak.DataEx = (uint)gubaoID;
|
pak.DataExStr = effID.ToString();
|
pak.DataExStrLen = (byte)effID.ToString().Length;
|
GameNetSystem.Instance.SendInfo(pak);
|
|
CloseWin<TreasurePavilionTipWin>();
|
});
|
|
|
}
|
else
|
{
|
getAwardBtn.SetActiveIL(false);
|
awardObj.SetActiveIL(false);
|
}
|
|
var dict = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict();
|
if (dict.ContainsKey(TreasurePavilionModel.Instance.selectGubao))
|
{
|
int resonanceID = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict()[TreasurePavilionModel.Instance.selectGubao];
|
Content1.SetActive(true);
|
|
scroller.Refresh();
|
var gubaoIDArr = GubaoResonanceConfig.Get(resonanceID).GubaoIDList;
|
for (int i = 0; i < gubaoIDArr.Length; i++)
|
{
|
scroller.AddCell(ScrollerDataType.Header, gubaoIDArr[i]);
|
}
|
scroller.Restart();
|
|
scroller1.Refresh();
|
var starDict = GubaoResonanceAttrConfig.GetResonanceStarDict();
|
var allIdDict = GubaoResonanceAttrConfig.GetDict();
|
var starList = starDict[resonanceID];
|
for (int j = 0; j < starList.Count; j++)
|
{
|
int star = starList[j];
|
var id = allIdDict[resonanceID][star];
|
scroller1.AddCell(ScrollerDataType.Header, id);
|
}
|
scroller1.Restart();
|
txtTitle.text = GubaoResonanceConfig.Get(resonanceID).ResonanceName;
|
}
|
else
|
{
|
Content1.SetActive(false);
|
}
|
|
|
}
|
|
protected override void OnPreClose()
|
{
|
scroller.OnRefreshCell -= OnRefreshCell;
|
scroller1.OnRefreshCell -= OnRefreshCell1;
|
}
|
|
void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell as TreasurePavilionTipCell;
|
_cell?.Display(_cell.index);
|
}
|
|
void OnRefreshCell1(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell as TreasurePavilionTipScrollerCell;
|
_cell?.Display(_cell.index);
|
}
|
#endregion
|
|
|
|
}
|