//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, November 01, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class DungeonFairyLandWin : Window
|
{
|
[SerializeField]
|
List<Text> targetTextList;
|
|
[SerializeField] Text m_FairyLandUpperTip;
|
|
DungeonModel m_Model;
|
DungeonModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<DungeonModel>());
|
}
|
}
|
BuffModel m_BuffModel;
|
BuffModel Buffmodel
|
{
|
get
|
{
|
return m_BuffModel ?? (m_BuffModel = ModelCenter.Instance.GetModel<BuffModel>());
|
}
|
}
|
DungeonLiquidModel m_DungeonLiquidModel;
|
DungeonLiquidModel dungeonLiquidModel
|
{
|
get
|
{
|
return m_DungeonLiquidModel ?? (m_DungeonLiquidModel = ModelCenter.Instance.GetModel<DungeonLiquidModel>());
|
}
|
}
|
|
TeamModel m_TeamModel;
|
TeamModel teamModel
|
{
|
get
|
{
|
return m_TeamModel ?? (m_TeamModel = ModelCenter.Instance.GetModel<TeamModel>());
|
}
|
}
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
|
}
|
|
|
|
protected override void OnPreOpen()
|
{
|
m_FairyLandUpperTip.SetActive(false);
|
|
StageChangeEvent();
|
MyTeamRefreshEvent();
|
DungeonEncourageEvent();
|
UpdateBuf();
|
model.dungeonFairyLandChangeEvent += StageChangeEvent;
|
model.dungeonInspireLvEvent += DungeonEncourageEvent;
|
BuffModel.Even_ObjAddBuf += AddBuff;
|
BuffModel.Even_ObjDelBuff += DeleteBuff;
|
teamModel.myTeamRefreshEvent += MyTeamRefreshEvent;
|
}
|
|
private void MyTeamRefreshEvent()
|
{
|
var _teamOnlineCnt = 0;
|
for (int i = 0; i < teamModel.myTeam.memberCount; i++)
|
{
|
Teammate teammate;
|
if (teamModel.myTeam.TryGetMember(i, out teammate))
|
{
|
if (teammate.online)
|
{
|
_teamOnlineCnt++;
|
}
|
}
|
}
|
targetTextList[5].text = StringUtility.Contact(Language.Get("FairyLand_Func5"),
|
_teamOnlineCnt == 0 ? "<color=#ff2828>" : "<color=#00ff00>", Mathf.Max(0, _teamOnlineCnt - 1) * 10, "%</color>");
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
DisplayBuff();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
model.dungeonFairyLandChangeEvent -= StageChangeEvent;
|
model.dungeonInspireLvEvent -= DungeonEncourageEvent;
|
BuffModel.Even_ObjAddBuf -= AddBuff;
|
BuffModel.Even_ObjDelBuff -= DeleteBuff;
|
teamModel.myTeamRefreshEvent -= MyTeamRefreshEvent;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
|
private void StageChangeEvent()
|
{
|
targetTextList[0].text = Language.Get("FairyLand_Func8", model.mission.wheel, model.mission.passAllCnt);
|
targetTextList[1].text = Language.Get("FairyLand_Func7", model.mission.npcTotal, model.mission.npcTotalNeed);
|
targetTextList[2].text = Language.Get("FairyLand_Func6", UIHelper.ReplaceLargeNum((ulong)model.mission.totalExp));
|
}
|
|
private void DungeonEncourageEvent()
|
{
|
var level = model.GetDungeonInspireLevel();
|
targetTextList[3].text = level == 0 ? StringUtility.Contact(Language.Get("FairyLand_Func3"), ":", Language.Get("FairyLand_Func4"))
|
: StringUtility.Contact(Language.Get("FairyLand_Func3"), ":<color=#00ff00>", level * model.GetDungeonInspireUpper(31080), "%</color>");
|
}
|
|
private void AddBuff()
|
{
|
UpdateBuf();
|
DisplayBuff();
|
}
|
|
private void DeleteBuff()
|
{
|
UpdateBuf();
|
DisplayBuff();
|
}
|
|
private void UpdateBuf()
|
{
|
int buffid = 0;
|
for (int i = 0; i < dungeonLiquidModel.liquidItems.Count; i++)
|
{
|
ItemConfig cfg = ItemConfig.Get(dungeonLiquidModel.liquidItems[i]);
|
if (Buffmodel._BuffDic.ContainsKey(cfg.AddSkill1))
|
{
|
buffid = cfg.AddSkill1;
|
break;
|
}
|
}
|
if (buffid != 0)
|
{
|
SkillConfig skillCfg = SkillConfig.Get(buffid);
|
if (skillCfg != null)
|
{
|
targetTextList[4].text = StringUtility.Contact(Language.Get("FairyLand_Func1"), ":<color=#00ff00>", skillCfg.EffectValue11 / 100, "%</color>",
|
"(", PlayerDatas.Instance.totalExpRate / 100, "%)");
|
return;
|
}
|
}
|
targetTextList[4].text = StringUtility.Contact(Language.Get("FairyLand_Func1"), ":", Language.Get("FairyLand_Func2"));
|
}
|
|
private void DisplayBuff()
|
{
|
var gainBuff = Buffmodel._BuffDic.ContainsKey(GeneralDefine.fairyLandBuffId);
|
var config = SkillConfig.Get(GeneralDefine.fairyLandBuffId);
|
if (config != null)
|
{
|
m_FairyLandUpperTip.text = UIHelper.ReplaceNewLine(Language.Get("XjmjAddHarm2",
|
GeneralDefine.fairyLandBuffCondition, config.EffectValue11 / 10000 + 1));
|
}
|
if (!gainBuff)
|
{
|
if (m_FairyLandUpperTip.gameObject.activeSelf)
|
{
|
m_FairyLandUpperTip.SetActive(false);
|
}
|
}
|
else
|
{
|
if (!m_FairyLandUpperTip.gameObject.activeSelf)
|
{
|
m_FairyLandUpperTip.SetActive(true);
|
}
|
}
|
}
|
|
|
}
|
|
}
|
|
|
|
|