//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, June 11, 2019
|
//--------------------------------------------------------
|
|
using LitJson;
|
using vnxbqy.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
public class ShentongWin : ILWindow
|
{
|
ScrollerController scroller;
|
Transform activePanel;
|
Transform upgradePanel;
|
ImageEx gubaoIcon;
|
IntensifySmoothSlider slider;
|
Text sliderTxt;
|
Text gubaoName;
|
ImageEx gubaolab;
|
Text unlockTextEx;
|
Button activeButton;
|
TextEx fightPower;
|
List<Transform> lineObjs = new List<Transform>();
|
List<Transform> starObjs = new List<Transform>();
|
List<Text> attrObjs = new List<Text>();
|
Transform skillObj;
|
Image skillIcon;
|
RichText skillDesc;
|
Text skillName;
|
Transform oper;
|
Button upgradeButton;
|
List<ItemCell> items = new List<ItemCell>();
|
Transform outSkillObj;
|
ClickScreenOtherSpace outSkillObjClick;
|
List<Button> outSkills = new List<Button>();
|
Text maxLV;
|
ToggleButton isHideSkill;
|
Transform ruleObj;
|
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
RoleParticularModel rolePModel { get { return ModelCenter.Instance.GetModelEx<RoleParticularModel>(); } }
|
|
|
#region Built-in
|
protected override void BindController()
|
{
|
scroller = proxy.GetWidgtEx<ScrollerController>("scroller");
|
activePanel = proxy.GetWidgtEx<Transform>("activePanel");
|
upgradePanel = proxy.GetWidgtEx<Transform>("upgradePanel");
|
gubaoIcon = proxy.GetWidgtEx<ImageEx>("gubaoIcon");
|
slider = proxy.GetWidgtEx<IntensifySmoothSlider>("ExpSlider");
|
sliderTxt = proxy.GetWidgtEx<Text>("ExpNum");
|
gubaoName = proxy.GetWidgtEx<Text>("gbname");
|
gubaolab = proxy.GetWidgtEx<ImageEx>("gubaolab");
|
unlockTextEx = proxy.GetWidgtEx<Text>("unlockTextEx");
|
activeButton = proxy.GetWidgtEx<Button>("activeButton");
|
fightPower = proxy.GetWidgtEx<TextEx>("fightPower");
|
for (int i = 0; i < 3; i++)
|
{
|
lineObjs.Add(proxy.GetWidgtEx<Transform>("lines" + i));
|
starObjs.Add(proxy.GetWidgtEx<Transform>("stars" + i));
|
}
|
|
for (int i = 0; i < 3; i++)
|
{
|
attrObjs.Add(proxy.GetWidgtEx<Text>("attr" + i));
|
}
|
|
skillObj = proxy.GetWidgtEx<Transform>("skillObj");
|
skillIcon = proxy.GetWidgtEx<Image>("skillIcon");
|
skillDesc = proxy.GetWidgtEx<RichText>("skillDesc");
|
skillName = proxy.GetWidgtEx<Text>("skillName");
|
oper = proxy.GetWidgtEx<Transform>("oper");
|
upgradeButton = proxy.GetWidgtEx<Button>("upgradeButton");
|
|
for (int i = 0; i < 3; i++)
|
{
|
items.Add(proxy.GetWidgtEx<ItemCell>("itemcell" + i));
|
}
|
outSkillObj = proxy.GetWidgtEx<Transform>("outskills");
|
outSkillObjClick = proxy.GetWidgtEx<ClickScreenOtherSpace>("outskills");
|
for (int i = 0; i < 3; i++)
|
{
|
outSkills.Add(proxy.GetWidgtEx<Button>("outskill" + i));
|
}
|
maxLV = proxy.GetWidgtEx<Text>("maxlv");
|
isHideSkill = proxy.GetWidgtEx<ToggleButton>("Toggle_Inevitable");
|
ruleObj = proxy.GetWidgtEx<Transform>("Btn_Rule");
|
}
|
|
protected override void AddListeners()
|
{
|
for (int i = 0; i < outSkills.Count; i++)
|
{
|
if (i < ShentongModel.Instance.shentongSetSkillIDs.Count)
|
{
|
int index = i;
|
outSkills[i].SetListener(()=> {
|
|
if (ShentongModel.Instance.shentongIDToSkillID.Count < ShentongModel.Instance.skillSetLimitLV[index])
|
{
|
SysNotifyMgr.Instance.ShowTip("shentongActive", ShentongModel.Instance.skillSetLimitLV[index]);
|
return;
|
}
|
var skillID = ShentongModel.Instance.shentongIDToSkillID[ShentongModel.Instance.selectShentong];
|
for (int j = 0; j < ShentongModel.Instance.shentongSetSkillIDs.Count; j++)
|
{
|
if (ShentongModel.Instance.shentongSetSkillIDs[index] == skillID)
|
{
|
ShentongModel.Instance.shentongIDSortBySkillID[index] = 0;
|
ShentongModel.Instance.shentongSetSkillIDs[index] = 0;
|
}
|
}
|
ShentongModel.Instance.shentongIDSortBySkillID[index] = ShentongModel.Instance.selectShentong;
|
ShentongModel.Instance.shentongSetSkillIDs[index] = skillID;
|
|
ShentongModel.Instance.SetShentongSkill();
|
});
|
}
|
}
|
|
isHideSkill.AddListener(()=> {
|
isHideSkill.isOn = !isHideSkill.isOn;
|
ShentongModel.Instance.isShowShentongSkill = !isHideSkill.isOn;
|
PlayerPrefs.SetInt("hidestskill" + PlayerDatas.Instance.baseData.PlayerID, isHideSkill.isOn ? 1 : 0);
|
});
|
|
outSkillObjClick.AddListener(()=> {
|
ShentongModel.Instance.selectShentongSkillID = 0;
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
ShentongModel.Instance.SortShentong();
|
ShentongModel.Instance.selectShentong = ShentongModel.Instance.shentongIDList[0];
|
ShentongModel.Instance.selectShentongSkillID = 0;
|
|
}
|
|
protected override void OnPreClose()
|
{
|
ShentongModel.Instance.UpdateShentongEvent -= UpdateShentongEvent;
|
ShentongModel.Instance.UpdateShentongSkillEvent -= UpdateShentongSkillEvent;
|
scroller.OnRefreshCell -= OnRefreshCell;
|
ShentongModel.Instance.SelectEvent -= OnSelectEvent;
|
ShentongModel.Instance.SelectShentongSkillIDEvent -= OnSelectShentongSkillIDEvent;
|
}
|
|
|
protected override void OnAfterOpen()
|
{
|
ShentongModel.Instance.UpdateShentongEvent += UpdateShentongEvent;
|
ShentongModel.Instance.UpdateShentongSkillEvent += UpdateShentongSkillEvent;
|
ShentongModel.Instance.SelectEvent += OnSelectEvent;
|
ShentongModel.Instance.SelectShentongSkillIDEvent += OnSelectShentongSkillIDEvent;
|
scroller.OnRefreshCell += OnRefreshCell;
|
Display();
|
CreateScroller();
|
}
|
#endregion
|
|
|
void OnSelectEvent()
|
{
|
scroller.m_Scorller.RefreshActiveCellViews();
|
Display();
|
}
|
|
void OnSelectShentongSkillIDEvent()
|
{
|
scroller.m_Scorller.RefreshActiveCellViews();
|
Display();
|
}
|
|
void UpdateShentongEvent()
|
{
|
DisplayShentong();
|
scroller.m_Scorller.RefreshActiveCellViews();
|
}
|
|
void UpdateShentongSkillEvent()
|
{
|
//scroller.m_Scorller.RefreshActiveCellViews();
|
ShentongModel.Instance.selectShentongSkillID = 0;
|
}
|
|
void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetILBehaviour<ShentongLabCell>();
|
_cell?.Display(cell.index);
|
}
|
|
|
void Display()
|
{
|
outSkillObj.SetActiveIL(ShentongModel.Instance.selectShentongSkillID != 0);
|
for (int i = 0; i < outSkills.Count; i++)
|
{
|
if (i < ShentongModel.Instance.shentongSetSkillIDs.Count)
|
{
|
outSkills[i].SetActiveIL(true);
|
outSkills[i].SetColorful(null, ShentongModel.Instance.shentongIDToSkillID.Count >= ShentongModel.Instance.skillSetLimitLV[i]);
|
var skillIcon = outSkills[i].transform.Find("ShentongSkill/Img_Icon").GetComponent<ImageEx>();
|
if (ShentongModel.Instance.shentongSetSkillIDs[i] != 0)
|
{
|
skillIcon.SetActiveIL(true);
|
skillIcon.SetSprite(SkillConfig.Get(ShentongModel.Instance.shentongSetSkillIDs[i]).IconName);
|
}
|
else
|
{
|
skillIcon.SetActiveIL(false);
|
}
|
}
|
else
|
{
|
outSkills[i].SetActiveIL(false);
|
}
|
}
|
|
isHideSkill.isOn = PlayerPrefs.GetInt("hidestskill" + PlayerDatas.Instance.baseData.PlayerID) == 1;
|
|
DisplayShentong();
|
}
|
|
void DisplayShentong()
|
{
|
var gubaoID = ILShentongConfig.Get(ShentongModel.Instance.selectShentong).NeedGubaoID;
|
bool isActive = TreasurePavilionModel.Instance.TryGetGubaoInfo(gubaoID).Count > 0;
|
activePanel.SetActiveIL(!isActive);
|
upgradePanel.SetActiveIL(isActive);
|
if (isActive)
|
{
|
fightPower.text = UIHelper.ReplaceLargeArtNum(rolePModel.GetFuncFightPower(30));
|
DisplayShentongProcess();
|
}
|
else
|
{
|
|
var config = ILGubaoConfig.Get(gubaoID);
|
gubaoIcon.SetSprite(config.Icon);
|
var cnt = TreasurePavilionModel.Instance.GetGubaoItemCount(gubaoID);
|
slider.value = Math.Min(1, (float)cnt / config.UnlockItemCnt);
|
sliderTxt.text = cnt + "/" + config.UnlockItemCnt;
|
gubaoName.text = config.Name;
|
gubaolab.SetSprite(TreasurePavilionModel.Instance.gubaoDiIconDict[config.GubaoQuality]);
|
unlockTextEx.text = Language.Get("Shentong1", config.Name);
|
int gubaoType = config.GubaoType;
|
activeButton.SetListener(()=> {
|
TreasurePavilionModel.Instance.selectIndex = TreasurePavilionModel.Instance.gubaoTypeList.IndexOf(gubaoType);
|
WindowJumpMgr.Instance.WindowJumpToEx("TreasurePavilionWin");
|
});
|
}
|
|
ruleObj.SetActiveIL(LanguageConfig.Has("ShentongSkill_" + ShentongModel.Instance.selectShentong));
|
}
|
|
void CreateScroller()
|
{
|
scroller.Refresh();
|
for (int i = 0; i < ShentongModel.Instance.shentongIDList.Count; i++)
|
{
|
scroller.AddCell(ScrollerDataType.Header, ShentongModel.Instance.shentongIDList[i]);
|
}
|
scroller.Restart();
|
}
|
|
void DisplayShentongProcess()
|
{
|
for (int i = 0; i < lineObjs.Count; i++)
|
{
|
if (ShentongModel.Instance.selectShentong % 3 == i)
|
{
|
lineObjs[i].SetActiveIL(true);
|
starObjs[i].SetActiveIL(true);
|
ShowLines(lineObjs[i]);
|
ShowStars(starObjs[i]);
|
}
|
else
|
{
|
lineObjs[i].SetActiveIL(false);
|
starObjs[i].SetActiveIL(false);
|
}
|
}
|
|
ShowAttr();
|
|
if (ShentongModel.Instance.shentongIDToSkillID.ContainsKey(ShentongModel.Instance.selectShentong))
|
{
|
skillObj.SetActiveIL(true);
|
var skillConfig = SkillConfig.Get(ShentongModel.Instance.shentongIDToSkillID[ShentongModel.Instance.selectShentong]);
|
skillIcon.SetSprite(skillConfig.IconName);
|
skillDesc.text = skillConfig.Description;
|
skillName.text = skillConfig.SkillName;
|
}
|
else
|
{
|
skillObj.SetActiveIL(false);
|
}
|
var id = ShentongModel.Instance.GetNextShentongIndex();
|
oper.SetActiveIL(id != -1);
|
maxLV.SetActiveIL(id == -1);
|
|
upgradeButton.SetListener(UpgradeShentong);
|
|
if (id != -1)
|
{
|
var needItems = ILShentongLVConfig.GetUseItems(id);
|
for (int i = 0; i < items.Count; i++)
|
{
|
if (i < needItems.Count)
|
{
|
items[i].SetActiveIL(true);
|
var itemID = needItems[i].x;
|
items[i].Init(new ItemCellModel(itemID, false, (ulong)needItems[i].y));
|
items[i].button.SetListener(()=> {
|
ItemTipUtility.Show(itemID);
|
});
|
var countTxt = items[i].transform.Find("Text").GetComponent<Text>();
|
var count = packModel.GetItemCountByID(PackType.Item, itemID);
|
countTxt.text = UIHelper.AppendColor(count >= needItems[i].y? TextColType.Green: TextColType.Red, count.ToString()) + "/" +needItems[i].y;
|
}
|
else
|
{
|
items[i].SetActiveIL(false);
|
}
|
}
|
}
|
}
|
|
void ShowAttr()
|
{
|
ShentongModel.Instance.CalcAttr();
|
var keyList = ShentongModel.Instance.shentongAttrDict.Keys.ToList();
|
keyList.Sort();
|
for (int i = 0; i < attrObjs.Count; i++)
|
{
|
if (i < keyList.Count)
|
{
|
var showStr = PlayerPropertyConfig.GetFullDescription(keyList[i], ShentongModel.Instance.shentongAttrDict[keyList[i]]);
|
var id = ShentongModel.Instance.GetNextShentongIndex();
|
if (id != -1)
|
{
|
var config = ILShentongLVConfig.Get(id);
|
var index = config.LVAttrTypeList.ToList().IndexOf(keyList[i]);
|
if (index != -1)
|
showStr = showStr + UIHelper.AppendColor(TextColType.Green, "+ " + PlayerPropertyConfig.GetValueDescription(keyList[i], config.LVAttrValueList[index]));
|
}
|
attrObjs[i].text = showStr;
|
}
|
else
|
{
|
attrObjs[i].text = string.Empty;
|
|
var id = ShentongModel.Instance.GetNextShentongIndex();
|
if (id != -1 && keyList.Count == i)
|
{
|
var config = ILShentongLVConfig.Get(id);
|
for (int j = 0; j < config.LVAttrTypeList.Length; j++)
|
{
|
if (keyList.IndexOf(config.LVAttrTypeList[j]) == -1)
|
{
|
attrObjs[i].text = PlayerPropertyConfig.GetFullDescription(config.LVAttrTypeList[j], 0) +
|
UIHelper.AppendColor(TextColType.Green, "+ " + PlayerPropertyConfig.GetValueDescription(config.LVAttrTypeList[j], config.LVAttrValueList[j]));
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
void ShowLines(Transform lines)
|
{
|
var lv = ShentongModel.Instance.shentongDict.ContainsKey(ShentongModel.Instance.selectShentong) ? ShentongModel.Instance.shentongDict[ShentongModel.Instance.selectShentong].LV : 0;
|
if (lv == 10) lv = 0;
|
for (int i = 0; i < 9; i++)
|
{
|
var lineImg = lines.Find("line (" + i + ")").GetComponent<ImageEx>();
|
lineImg.gray = i >= lv - 1;
|
}
|
}
|
|
void ShowStars(Transform stars)
|
{
|
var lv = ShentongModel.Instance.shentongDict.ContainsKey(ShentongModel.Instance.selectShentong) ? ShentongModel.Instance.shentongDict[ShentongModel.Instance.selectShentong].LV : 0;
|
var classLV = ShentongModel.Instance.shentongDict.ContainsKey(ShentongModel.Instance.selectShentong) ? ShentongModel.Instance.shentongDict[ShentongModel.Instance.selectShentong].ClassLV : 1;
|
var nextid = ShentongModel.Instance.GetNextShentongIndex();
|
if (nextid != -1 && lv == 10)
|
{
|
classLV += 1;
|
lv = 0;
|
}
|
|
for (int i = 0; i < 10; i++)
|
{
|
var starImg = stars.Find("star (" + i + ")").GetComponent<ImageEx>();
|
starImg.gray = i > lv;
|
var id = ILShentongLVConfig.GetShentongLVID(ShentongModel.Instance.selectShentong, classLV, i + 1);
|
starImg.SetSprite("shentongAttr" + ILShentongLVConfig.Get(id).LVAttrTypeList[0]);
|
|
var alphaObj = stars.Find("star (" + i + ")").GetComponent<UIAlphaTween>();
|
if (i == lv)
|
{
|
alphaObj.to = 0;
|
alphaObj.Play();
|
}
|
else
|
{
|
alphaObj.SetStartState();
|
alphaObj.to = 1;
|
}
|
|
}
|
|
var config = ILShentongLVConfig.Get(ILShentongLVConfig.GetShentongLVID(ShentongModel.Instance.selectShentong, classLV, 10));
|
var skillIcon = stars.Find("SkillWidget/Img_Icon").GetComponent<ImageEx>();
|
var skillConfig = SkillConfig.Get(config.LVSkillID);
|
skillIcon.SetSprite(skillConfig.IconName);
|
|
var skillName = stars.Find("SkillWidget/Txt_SkillName").GetComponent<Text>();
|
skillName.text = skillConfig.SkillName;
|
|
var skillBtn = stars.Find("SkillWidget").GetComponent<Button>();
|
skillBtn.AddListener(()=> {
|
SkillDetails.ShowSkillDetails(config.LVSkillID, SkillDetails.SkillSourceType.PlayerSkill, skillConfig.FightPower);
|
});
|
}
|
|
|
void UpgradeShentong()
|
{
|
var id = ShentongModel.Instance.GetNextShentongIndex();
|
if (id == -1)
|
return;
|
|
var needItems = ILShentongLVConfig.GetUseItems(id);
|
|
for (int i = 0; i < needItems.Count; i++)
|
{
|
if (packModel.GetItemCountByID(PackType.Item, needItems[i].x) < needItems[i].y)
|
{
|
SysNotifyMgr.Instance.ShowTip("NotEnoughMaterial");
|
return;
|
}
|
LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(12, needItems[i].x, needItems[i].y, 1,0);
|
}
|
|
var pack = new IL_CB219_tagCMShentongLVUp();
|
pack.ShentongID = (byte)ShentongModel.Instance.selectShentong;
|
GameNetSystem.Instance.SendInfo(pack);
|
}
|
}
|