//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, January 28, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using vnxbqy.UI;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
public class CrossServerBattleFieldResultWin : ILWindow
|
{
|
Button exit;
|
Text fightTime;
|
Button seeOther;
|
ScrollerController scroller;
|
Image factionIcon;
|
Transform defeatObj;
|
Transform winObj;
|
Text factionState;
|
List<ItemCell> itemCells = new List<ItemCell>();
|
ItemCell godAward;
|
Text quitTime;
|
Text seeFactionResult;
|
Text names;
|
Text myScore;
|
|
|
const int outTime = 50; //退出倒计时
|
float starTime;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
exit = proxy.GetWidgtEx<Button>("Btn_Quit");
|
fightTime = proxy.GetWidgtEx<Text>("Txt_TotalTime");
|
seeOther = proxy.GetWidgtEx<Button>("seeOther");
|
scroller = proxy.GetWidgtEx<ScrollerController>("Scroller");
|
factionIcon = proxy.GetWidgtEx<Image>("factionIcon");
|
defeatObj = proxy.GetWidgtEx<Transform>("Container_Defeat");
|
winObj = proxy.GetWidgtEx<Transform>("Container_Win");
|
factionState = proxy.GetWidgtEx<Text>("stateTitle");
|
for (int i = 0; i < 6; i++)
|
{
|
itemCells.Add(proxy.GetWidgtEx<ItemCell>(i.ToString()));
|
}
|
|
godAward = proxy.GetWidgtEx<ItemCell>("bigAward");
|
quitTime = proxy.GetWidgtEx<Text>("quitText");
|
seeFactionResult = proxy.GetWidgtEx<Text>("seeTextEx");
|
names = proxy.GetWidgtEx<Text>("names");
|
myScore = proxy.GetWidgtEx<Text>("myScore");
|
}
|
|
protected override void AddListeners()
|
{
|
exit.SetListener(()=> {
|
ILCrossServerModel.Instance.RequestExit();
|
});
|
|
seeOther.SetListener(() => {
|
ILCrossServerModel.Instance.seeFaction = ILCrossServerModel.Instance.seeFaction == 1 ? 2 : 1;
|
DisplayByFaction(ILCrossServerModel.Instance.seeFaction);
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
starTime = Time.time;
|
ILCrossServerModel.Instance.seeFaction = ILCrossServerModel.Instance.dungeonResult.faction;
|
GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
|
scroller.OnRefreshCell += OnRefreshCell;
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
fightTime.text = TimeUtility.SecondsToMS(ILCrossServerModel.Instance.dungeonResult.costTime);
|
|
var bigItemID = ILCrossServerModel.Instance.superItemInfo[0];
|
var bigModel = new ItemCellModel(bigItemID, false, (ulong)ILCrossServerModel.Instance.superItemInfo[1]);
|
godAward.Init(bigModel);
|
godAward.button.SetListener(() =>
|
{
|
ItemTipUtility.Show(bigItemID);
|
});
|
|
names.text = string.Format("{0},{1},{2}", ILCrossServerModel.Instance.dungeonResult.finalSuperItemPlayerName,
|
ILCrossServerModel.Instance.dungeonResult.factionInfoList[0].superItemPlayerName,
|
ILCrossServerModel.Instance.dungeonResult.factionInfoList[1].superItemPlayerName
|
);
|
|
myScore.text = Language.Get("CrossBattleField88") + ILCrossServerModel.Instance.dungeonResult.score;
|
DisplayByFaction(ILCrossServerModel.Instance.seeFaction);
|
}
|
|
protected override void OnPreClose()
|
{
|
GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
|
scroller.OnRefreshCell -= OnRefreshCell;
|
}
|
#endregion
|
|
void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var _cell = cell.GetILBehaviour<CrossServerBattleFieldResultCell>();
|
_cell?.Display(cell.index);
|
}
|
|
void OnSecondEvent()
|
{
|
var endTime = Math.Max(outTime - (int)(Time.time - starTime), 0);
|
if (endTime == 0)
|
{
|
ILCrossServerModel.Instance.RequestExit();
|
WindowCenter.Instance.CloseIL<CrossServerBattleFieldResultWin>();
|
return;
|
}
|
quitTime.text = Language.Get("CrossBattleField84", endTime);
|
}
|
|
void DisplayByFaction(int faction)
|
{
|
seeFactionResult.text = Language.Get(faction == ILCrossServerModel.Instance.dungeonResult.faction ? "CrossBattleField82" : "CrossBattleField82_0");
|
CreateScroller(faction);
|
factionIcon.SetSprite("GSZCIcon" + faction);
|
defeatObj.SetActiveIL(ILCrossServerModel.Instance.dungeonResult.winnerFaction != faction);
|
winObj.SetActiveIL(ILCrossServerModel.Instance.dungeonResult.winnerFaction == faction);
|
factionState.text = Language.Get(ILCrossServerModel.Instance.dungeonResult.winnerFaction == faction ? "CrossBattleField85" : "CrossBattleField86");
|
|
var commonAwards = ILCrossServerModel.Instance.dungeonResult.winnerFaction == faction ? ILCrossServerModel.Instance.winFactionAwards : ILCrossServerModel.Instance.defeatFactionAwards;
|
|
for (int i = 0; i < itemCells.Count; i++)
|
{
|
if (i < commonAwards.Length)
|
{
|
itemCells[i].SetActiveIL(true);
|
var itemID = commonAwards[i][0];
|
var model = new ItemCellModel(itemID, false, (ulong)commonAwards[i][1]);
|
itemCells[i].Init(model);
|
itemCells[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemID);
|
});
|
}
|
else
|
{
|
itemCells[i].SetActiveIL(false);
|
}
|
}
|
}
|
|
void CreateScroller(int faction)
|
{
|
scroller.Refresh();
|
for (int i = 0; i < ILCrossServerModel.Instance.dungeonResult.factionInfoList[faction - 1].rankPlayerList.Length; i++)
|
{
|
scroller.AddCell(ScrollerDataType.Header, i);
|
}
|
scroller.Restart();
|
scroller.m_Scorller.RefreshActiveCellViews();
|
if (faction == ILCrossServerModel.Instance.dungeonResult.faction)
|
{
|
scroller.JumpIndex(ILCrossServerModel.Instance.dungeonResult.rank - 1);
|
}
|
}
|
}
|