//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, October 10, 2017
|
//--------------------------------------------------------
|
|
using LitJson;
|
using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class RealmWin : Window
|
{
|
|
[SerializeField] Button m_Close;
|
[SerializeField] Image realmImg;
|
[SerializeField] Image nextRealmImg;
|
[SerializeField] Text lvText;
|
[SerializeField] Text nextLvText;
|
[SerializeField] List<Text> attrList;
|
[SerializeField] List<Text> nextAttrList;
|
[SerializeField] List<Text> stateList;
|
[SerializeField] List<Image> stateImgList;
|
[SerializeField] List<Image> stateBGImgList;
|
[SerializeField] List<Text> taskList;
|
[SerializeField] List<Slider> taskProcessList;
|
[SerializeField] List<Text> taskProcessTextList;
|
[SerializeField] List<ItemCell> taskRewardList;
|
[SerializeField] List<Button> getBtnList;
|
[SerializeField] Slider expProcess;
|
[SerializeField] Text expProcessText;
|
[SerializeField] Button m_Upgrade;
|
|
|
|
RealmModel model
|
{
|
get
|
{
|
return ModelCenter.Instance.GetModel<RealmModel>();
|
}
|
}
|
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
CutTreeModel cutTreeModel { get { return ModelCenter.Instance.GetModel<CutTreeModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.AddListener(CloseClick);
|
|
}
|
|
protected override void OnPreOpen()
|
{
|
Display();
|
PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
|
model.OnRealmInfo += OnRealmInfo;
|
}
|
|
|
|
protected override void OnActived()
|
{
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
|
model.OnRealmInfo -= OnRealmInfo;
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
#endregion
|
|
void PlayerDataRefreshEvent(PlayerDataType type)
|
{
|
if (type == PlayerDataType.LV || type == PlayerDataType.TotalExp || type == PlayerDataType.ExpPoint || type == PlayerDataType.RealmLevel)
|
{
|
Display();
|
}
|
}
|
|
void GetAward(int type)
|
{
|
var pack = new CA504_tagCMPlayerGetReward();
|
pack.RewardType = 68;
|
pack.DataEx = (uint)type;
|
GameNetSystem.Instance.SendInfo(pack);
|
}
|
|
void Display()
|
{
|
var config = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel);
|
realmImg.SetSprite(config.Img);
|
var nextConfig = RealmConfig.Get(PlayerDatas.Instance.baseData.realmLevel + 1);
|
if (nextConfig == null) nextConfig = config;
|
nextRealmImg.SetSprite(nextConfig.Img);
|
lvText.text = Language.Get("LoadIconLV", PlayerDatas.Instance.baseData.LV);
|
nextLvText.text = Language.Get("LoadIconLV", PlayerDatas.Instance.baseData.LV + 1);
|
for (int i = 0;i < attrList.Count;i++)
|
{
|
if (i < config.AddAttrType.Length)
|
{
|
attrList[i].text = PlayerPropertyConfig.GetFullDescription(config.AddAttrType[i], config.AddAttrNum[i]);
|
nextAttrList[i].text = PlayerPropertyConfig.GetFullDescription(nextConfig.AddAttrType[i], nextConfig.AddAttrNum[i]);
|
}
|
else
|
{
|
attrList[i].text = "";
|
nextAttrList[i].text = "";
|
}
|
}
|
|
int finishCnt = 0;
|
int notFinishType = -1; //按顺序前面未完成的类型
|
//下一个境界需要的条件,同时只需要3个不同的条件
|
int index = 0;
|
if (config.NeedLV != 0)
|
{
|
int state = 0;//0未完成,1已完成,2已领取
|
if (model.GetAwardState(0))
|
{
|
finishCnt++;
|
state = 2;
|
}
|
else if (PlayerDatas.Instance.baseData.LV >= config.NeedLV)
|
{
|
state = 1;
|
}
|
else if (notFinishType == -1)
|
{
|
notFinishType = 0;
|
}
|
stateList[index].text = Language.Get("Realm_State" + state);
|
stateImgList[index].SetActive(state == 2);
|
stateBGImgList[index].SetSprite("Realm_State" + state);
|
taskList[index].text = Language.Get("WorldMap_LV", config.NeedLV);
|
taskProcessList[index].value = PlayerDatas.Instance.baseData.LV / (float)config.NeedLV;
|
taskProcessTextList[index].text = PlayerDatas.Instance.baseData.LV + "/" + config.NeedLV;
|
int itemID = config.LVAwardItem[0];
|
taskRewardList[index].Init(new ItemCellModel(itemID, false, (ulong)config.LVAwardItem[1]));
|
taskRewardList[index].button.AddListener(() => {
|
ItemTipUtility.Show(itemID);
|
});
|
|
getBtnList[index].AddListener(() =>
|
{
|
if (state == 2) return;
|
if (state == 0)
|
{
|
ShowGuide(0);
|
return;
|
}
|
GetAward(0);
|
});
|
|
index++;
|
}
|
|
if (config.NeedPassMap.Length != 0)
|
{
|
int state = 0;//0未完成,1已完成,2已领取
|
|
int passLine = 0;
|
DungeonRecord dungeonRecord;
|
if (dungeonModel.TryGetRecord(config.NeedPassMap[0], out dungeonRecord))
|
{
|
passLine = dungeonRecord.passLineID;
|
}
|
|
if (model.GetAwardState(1))
|
{
|
finishCnt++;
|
state = 2;
|
}
|
else if (passLine >= config.NeedPassMap[1])
|
{
|
state = 1;
|
}
|
else if (notFinishType == -1)
|
{
|
notFinishType = 1;
|
}
|
stateList[index].text = Language.Get("Realm_State" + state);
|
stateImgList[index].SetActive(state == 2);
|
stateBGImgList[index].SetSprite("Realm_State" + state);
|
var advenConfig = AdventureConfig.Get(config.NeedPassMap[1]);
|
taskList[index].text = Language.Get("RuneTower11", advenConfig.Name);
|
taskProcessList[index].value = passLine / (float)config.NeedPassMap[1];
|
taskProcessTextList[index].text = passLine + "/" + config.NeedPassMap[1];
|
int itemID = config.PassMapAwardItem[0];
|
taskRewardList[index].Init(new ItemCellModel(itemID, false, (ulong)config.PassMapAwardItem[1]));
|
taskRewardList[index].button.AddListener(() => {
|
ItemTipUtility.Show(itemID);
|
});
|
|
getBtnList[index].AddListener(() =>
|
{
|
if (state == 2) return;
|
if (state == 0)
|
{
|
ShowGuide(1);
|
return;
|
}
|
GetAward(1);
|
});
|
index++;
|
}
|
|
|
if (config.NeedTreeLV != 0)
|
{
|
int state = 0;//0未完成,1已完成,2已领取
|
if (model.GetAwardState(2))
|
{
|
finishCnt++;
|
state = 2;
|
}
|
else if (cutTreeModel.GetTreeLV() >= config.NeedTreeLV)
|
{
|
state = 1;
|
}
|
else if (notFinishType == -1)
|
{
|
notFinishType = 2;
|
}
|
stateList[index].text = Language.Get("Realm_State" + state);
|
stateImgList[index].SetActive(state == 2);
|
stateBGImgList[index].SetSprite("Realm_State" + state);
|
taskList[index].text = Language.Get("CutTree21", config.NeedTreeLV);
|
taskProcessList[index].value = cutTreeModel.GetTreeLV() / (float)config.NeedTreeLV;
|
taskProcessTextList[index].text = cutTreeModel.GetTreeLV() + "/" + config.NeedTreeLV;
|
int itemID = config.TreeLVAwardItem[0];
|
taskRewardList[index].Init(new ItemCellModel(itemID, false, (ulong)config.TreeLVAwardItem[1]));
|
taskRewardList[index].button.AddListener(() => {
|
ItemTipUtility.Show(itemID);
|
});
|
|
getBtnList[index].AddListener(() =>
|
{
|
if (state == 2) return;
|
if (state == 0)
|
{
|
ShowGuide(2);
|
return;
|
}
|
GetAward(2);
|
});
|
index++;
|
}
|
|
if (config.NeedCutTreeCnt != 0 && index <= 2)
|
{
|
|
int state = 0;//0未完成,1已完成,2已领取
|
if (model.GetAwardState(3))
|
{
|
finishCnt++;
|
state = 2;
|
}
|
else if (model.m_RealmLVUpCutTreeCnt >= config.NeedCutTreeCnt)
|
{
|
state = 1;
|
}
|
else if (notFinishType == -1)
|
{
|
notFinishType = 3;
|
}
|
stateList[index].text = Language.Get("Realm_State" + state);
|
stateImgList[index].SetActive(state == 2);
|
stateBGImgList[index].SetSprite("Realm_State" + state);
|
taskList[index].text = Language.Get("CutTree18", config.NeedCutTreeCnt);
|
taskProcessList[index].value = model.m_RealmLVUpCutTreeCnt / (float)config.NeedCutTreeCnt;
|
taskProcessTextList[index].text = model.m_RealmLVUpCutTreeCnt + "/" + config.NeedCutTreeCnt;
|
int itemID = config.CutTreeAwardItem[0];
|
taskRewardList[index].Init(new ItemCellModel(itemID, false, (ulong)config.CutTreeAwardItem[1]));
|
taskRewardList[index].button.AddListener(() => {
|
ItemTipUtility.Show(itemID);
|
});
|
|
getBtnList[index].AddListener(() =>
|
{
|
if (state == 2) return;
|
if (state == 0)
|
{
|
ShowGuide(3);
|
return;
|
}
|
GetAward(3);
|
});
|
|
}
|
|
ulong maxValue = (ulong)PlayerLVConfig.GetExpByPlayerLv(PlayerDatas.Instance.baseData.LV);
|
ulong nowVlaue = (ulong)PlayerDatas.Instance.baseData.TotalExp + (ulong)PlayerDatas.Instance.baseData.ExpPoint * 100000000;
|
|
expProcess.value = nowVlaue/ (float)maxValue;
|
expProcessText.text = string.Format("{0}/{1}", UIHelper.ReplaceLargeNum(nowVlaue), UIHelper.ReplaceLargeNum(maxValue));
|
|
m_Upgrade.AddListener(() => {
|
if (finishCnt < 3)
|
{
|
ShowGuide(notFinishType);
|
return;
|
}
|
|
model.SendLevelUpRealm();
|
});
|
}
|
|
|
//0-等级;1-副本关卡;2-仙树等级;3-砍树次数
|
void ShowGuide(int type)
|
{
|
CloseClick();
|
|
if (type == -1)
|
type = 0;
|
//触发引导
|
if (cutTreeModel.realmWinClickGuide.ContainsKey(type) && !NewBieCenter.Instance.inGuiding)
|
{
|
NewBieCenter.Instance.ResetGuide(cutTreeModel.realmWinClickGuide[type]);
|
NewBieCenter.Instance.StartNewBieGuideEx(cutTreeModel.realmWinClickGuide[type]);
|
}
|
}
|
|
void OnRealmInfo()
|
{
|
Display();
|
}
|
}
|
|
}
|
|
|
|
|