//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, November 01, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using TableConfig;
|
namespace Snxxz.UI
|
{
|
|
public class DungeonFairyLandWin : Window
|
{
|
[SerializeField]
|
List<Text> targetTextList;
|
|
DungeonModel m_Model;
|
DungeonModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<DungeonModel>());
|
}
|
}
|
PlayerBuffDatas m_BuffModel;
|
PlayerBuffDatas Buffmodel
|
{
|
get
|
{
|
return m_BuffModel ?? (m_BuffModel = ModelCenter.Instance.GetModel<PlayerBuffDatas>());
|
}
|
}
|
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()
|
{
|
StageChangeEvent();
|
MyTeamRefreshEvent();
|
DungeonEncourageEvent();
|
UpdateBuf();
|
model.dungeonFairyLandChangeEvent += StageChangeEvent;
|
model.dungeonInspireLvEvent += DungeonEncourageEvent;
|
PlayerBuffDatas.Even_ObjAddBuf += UpdateBuf;
|
PlayerBuffDatas.Even_ObjDelBuff += UpdateBuf;
|
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 OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
model.dungeonFairyLandChangeEvent -= StageChangeEvent;
|
model.dungeonInspireLvEvent -= DungeonEncourageEvent;
|
PlayerBuffDatas.Even_ObjAddBuf -= UpdateBuf;
|
PlayerBuffDatas.Even_ObjDelBuff -= UpdateBuf;
|
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);
|
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 UpdateBuf()
|
{
|
int buffid = 0;
|
for (int i = 0; i < dungeonLiquidModel.liquidItems.Count; i++)
|
{
|
ItemConfig cfg = Config.Instance.Get<ItemConfig>(dungeonLiquidModel.liquidItems[i]);
|
if (Buffmodel._BuffDic.ContainsKey(cfg.AddSkill1))
|
{
|
buffid = cfg.AddSkill1;
|
break;
|
}
|
}
|
if (buffid != 0)
|
{
|
SkillConfig skillCfg = Config.Instance.Get<SkillConfig>(buffid);
|
if (skillCfg != null)
|
{
|
targetTextList[4].text = StringUtility.Contact(Language.Get("FairyLand_Func1"), ":<color=#00ff00>", skillCfg.EffectValue11 / 100, "%</color>");
|
return;
|
}
|
}
|
targetTextList[4].text = StringUtility.Contact(Language.Get("FairyLand_Func1"), ":", Language.Get("FairyLand_Func2"));
|
}
|
}
|
|
}
|
|
|
|
|