using vnxbqy.UI;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
//异兽入侵
|
public class BeastInvasionWin : OneLevelWin
|
{
|
TextEx txtNPC;
|
TextEx txtTime;
|
TextEx txtCount;
|
ImageEx imgTime;
|
RawImage rawNPC;
|
ButtonEx btnGo;
|
ButtonEx btnReward;
|
ButtonEx btnRank;
|
List<ItemCell> itemCellList;
|
int npcID;
|
BeastInvasionModel beastInvasionModel { get { return ModelCenter.Instance.GetModel<BeastInvasionModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
RankModel rankModel { get { return ModelCenter.Instance.GetModel<RankModel>(); } }
|
|
protected override void BindController()
|
{
|
base.BindController();
|
txtNPC = GetWidgt<TextEx>("txtNPC");
|
txtTime = GetWidgt<TextEx>("txtTime");
|
txtCount = GetWidgt<TextEx>("txtCount");
|
rawNPC = GetWidgt<RawImage>("rawNPC");
|
btnGo = GetWidgt<ButtonEx>("btnGo");
|
btnReward = GetWidgt<ButtonEx>("btnReward");
|
btnRank = GetWidgt<ButtonEx>("btnRank");
|
imgTime = GetWidgt<ImageEx>("imgTime");
|
itemCellList = new List<ItemCell>();
|
for (int i = 0; i < beastInvasionModel.itemCellCount; i++)
|
{
|
itemCellList.Add(GetWidgt<ItemCell>("itemcell" + i));
|
}
|
}
|
|
protected override void AddListeners()
|
{
|
base.AddListeners();
|
btnReward.SetListener(() => { WindowCenter.Instance.Open<BeastInvasionRewardWin>(); });
|
btnRank.SetListener(() =>
|
{
|
rankModel.QueryRankByPage(beastInvasionModel.rankType, 0, 100, 0, true);
|
Clock.AlarmAfter(1.2f, () => { rankModel.QueryRankByPage(beastInvasionModel.rankType, 0, 20, 1, true); });
|
});
|
btnGo.SetListener(() =>
|
{
|
//今日次数不足
|
if (dungeonModel.GetEnterTimes(beastInvasionModel.dataMapID) >= dungeonModel.GetMaxTimesShow(beastInvasionModel.dataMapID))
|
{
|
SysNotifyMgr.Instance.ShowTip("XBLimitCnt");
|
return;
|
}
|
|
//不在开放时间
|
if (!beastInvasionModel.isTimeOk())
|
{
|
SysNotifyMgr.Instance.ShowTip("FBIsNotOpen");
|
return;
|
}
|
|
//其他副本开放条件
|
int error = 0;
|
dungeonModel.TestChallange(new Dungeon(beastInvasionModel.dataMapID, beastInvasionModel.lineID), out error);
|
var dungeonConfig = DungeonConfig.Get(beastInvasionModel.dungeonID);
|
switch (error)
|
{
|
case 1:
|
SysNotifyMgr.Instance.ShowTip("DungeoninCoolTime");
|
break;
|
case 2:
|
SysNotifyMgr.Instance.ShowTip("DemonJar_Text2");
|
break;
|
case 4:
|
SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_268121", dungeonConfig.MapID);
|
break;
|
case 5:
|
SysNotifyMgr.Instance.ShowTip("GeRen_chenxin_157069", dungeonConfig.MapID);
|
break;
|
}
|
|
TurnFightModel.Instance.StartTurnFight(beastInvasionModel.dataMapID, beastInvasionModel.lineID, 0, npcID);
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
base.OnPreOpen();
|
rankModel.onMyRankRefresh += OnMyRefreshRank;
|
GlobalTimeEvent.Instance.secondEvent += OnRefreshSecond;
|
dungeonModel.dungeonRecordChangeEvent += OndungeonRecordChangeEvent;
|
npcID = beastInvasionModel.GetTodayNPCID();
|
var npcConfig = NPCConfig.Get(npcID);
|
txtNPC.text = npcConfig.charName;
|
UI3DModelExhibition.Instance.ShowNPC(npcID, npcConfig.UIModeLOffset, npcConfig.UIModelRotation + new Vector3(0, -45, 0), rawNPC);
|
ChangeCountText();
|
ChangeTime();
|
for (int i = 0; i < beastInvasionModel.itemCellCount; i++)
|
{
|
int[] dropArr = beastInvasionModel.dropArr;
|
if (i <= dropArr.Length - 1)
|
{
|
int itemID = dropArr[i];
|
itemCellList[i].SetActive(true);
|
itemCellList[i].Init(new ItemCellModel(itemID, false, 0));
|
itemCellList[i].countText.SetActive(false);
|
itemCellList[i].button.SetListener(() => { ItemTipUtility.Show(itemID); });
|
}
|
else
|
{
|
itemCellList[i].SetActive(false);
|
}
|
}
|
}
|
|
protected override void OnAfterOpen()
|
{
|
base.OnAfterOpen();
|
}
|
|
protected override void OnAfterClose()
|
{
|
base.OnAfterClose();
|
}
|
|
protected override void OnPreClose()
|
{
|
base.OnPreClose();
|
rankModel.onMyRankRefresh -= OnMyRefreshRank;
|
GlobalTimeEvent.Instance.secondEvent -= OnRefreshSecond;
|
dungeonModel.dungeonRecordChangeEvent -= OndungeonRecordChangeEvent;
|
}
|
|
void OndungeonRecordChangeEvent(int dungeonId)
|
{
|
if (dungeonId != beastInvasionModel.dataMapID)
|
return;
|
ChangeCountText();
|
}
|
|
void ChangeCountText()
|
{
|
int totalCount = dungeonModel.GetMaxTimesShow(beastInvasionModel.dataMapID);
|
int enterCount = dungeonModel.GetEnterTimes(beastInvasionModel.dataMapID);
|
int remainCount = totalCount - enterCount;
|
txtCount.colorType = remainCount > 0 ? TextColType.Green : TextColType.Red;
|
txtCount.text = Language.Get("BlessedLand036", remainCount, totalCount);
|
}
|
|
void OnRefreshSecond()
|
{
|
ChangeTime();
|
}
|
|
void ChangeTime()
|
{
|
imgTime.SetActive(beastInvasionModel.dayReKind > 0);
|
txtTime.text = beastInvasionModel.isTimeOk() ? Language.Get("BeastInvasion03", beastInvasionModel.GetRemainTime()) : Language.Get("BeastInvasion05");
|
}
|
|
void OnMyRefreshRank(int type)
|
{
|
if (type != beastInvasionModel.rankType)
|
return;
|
if (WindowCenter.Instance.IsOpen<BeastInvasionRankWin>())
|
return;
|
WindowCenter.Instance.Open<BeastInvasionRankWin>();
|
}
|
}
|