//--------------------------------------------------------
|
// [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 CrossServerQualifying8Win : ILWindow
|
{
|
Transform raceTable;
|
Text waitTxt;
|
Text timeTip; //显示自己当前进场信息和小窗推送配合
|
Button raceBtn;
|
ButtonEx enterGame;
|
Button giftBtn;
|
Button guessBtn;
|
Text time1;
|
Text time11;
|
Text time2;
|
Text time22;
|
Text time3;
|
List<Transform> players8 = new List<Transform>();
|
List<Transform> players4 = new List<Transform>();
|
ImageEx winA;
|
ImageEx winB;
|
Text nameA;
|
Text nameB;
|
Text fightPowerA;
|
Text fightPowerB;
|
Image arrow;
|
Text nextTime;
|
|
|
#region Built-in
|
protected override void BindController()
|
{
|
waitTxt = proxy.GetWidgtEx<Text>("waitTxt");
|
raceTable = proxy.GetWidgtEx<Transform>("8qiang");
|
timeTip = proxy.GetWidgtEx<Text>("TIPTime");
|
raceBtn = proxy.GetWidgtEx<Button>("battleTableBtn");
|
enterGame = proxy.GetWidgtEx<ButtonEx>("enterGame");
|
giftBtn = proxy.GetWidgtEx<Button>("giftBtn");
|
guessBtn = proxy.GetWidgtEx<Button>("guessBtn");
|
time1 = proxy.GetWidgtEx<Text>("time1");
|
time11 = proxy.GetWidgtEx<Text>("time11");
|
time2 = proxy.GetWidgtEx<Text>("time2");
|
time22 = proxy.GetWidgtEx<Text>("time22");
|
time3 = proxy.GetWidgtEx<Text>("time3");
|
|
for (int i = 0; i < 8; i++)
|
{
|
players8.Add(proxy.GetWidgtEx<Transform>("player" + i));
|
}
|
|
for (int i = 0; i < 4; i++)
|
{
|
players4.Add(proxy.GetWidgtEx<Transform>("player2_" + i));
|
}
|
|
winA = proxy.GetWidgtEx<ImageEx>("trophyA");
|
winB = proxy.GetWidgtEx<ImageEx>("trophyB");
|
nameA = proxy.GetWidgtEx<Text>("nameA");
|
nameB = proxy.GetWidgtEx<Text>("nameB");
|
fightPowerA = proxy.GetWidgtEx<Text>("fightPowerA");
|
fightPowerB = proxy.GetWidgtEx<Text>("fightPowerB");
|
arrow = proxy.GetWidgtEx<Image>("arrow");
|
nextTime = proxy.GetWidgtEx<Text>("nextTime");
|
}
|
|
protected override void AddListeners()
|
{
|
enterGame.SetListener(EnterGame);
|
guessBtn.SetListener(() => {
|
arrow.SetActiveIL(false);
|
WindowCenter.Instance.OpenIL<CrossServerQualifyingGuess4Win>();
|
});
|
|
raceBtn.SetListener(()=> {
|
if (CrossServerQualifyingModel.Instance.GetOpenTimeIndex() == -1)
|
return;
|
WindowCenter.Instance.OpenIL<CrossServerQualifyingRaceWin>();
|
});
|
|
giftBtn.SetListener(() => {
|
WindowCenter.Instance.OpenIL<CrossServerQualifyingRankWin>();
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
GlobalTimeEvent.Instance.minuteEvent += OnMinuteEvent;
|
CrossServerQualifyingModel.Instance.UpdateCrossChampionshipPKZoneGroupInfoEvent += UpdateRace;
|
|
var battleID = CrossServerQualifyingModel.Instance.GetBattleID();
|
if (battleID == -1)
|
{
|
arrow.SetActiveIL(false);
|
var index = CrossServerQualifyingModel.Instance.GetNextOpenTimeIndex();
|
if (index > -1)
|
{
|
nextTime.text = Language.Get("CrossServerQualifying64") + CrossServerQualifyingModel.Instance.openTimes[index].ToString("dd-MM-yyyy");
|
}
|
else
|
{
|
nextTime.text = "";
|
}
|
}
|
else
|
{
|
nextTime.text = "";
|
arrow.SetActiveIL(ILChampionshipTimeConfig.Get(battleID).StateValue == 40);
|
}
|
}
|
protected override void OnAfterOpen()
|
{
|
if (CrossServerQualifyingModel.Instance.battleInfo.ContainsKey(8))
|
{
|
raceTable.SetActiveIL(true);
|
waitTxt.SetActiveIL(false);
|
|
OnMinuteEvent();
|
DisplayTime();
|
DisplayRace();
|
|
}
|
else
|
{
|
enterGame.SetActiveIL(false);
|
timeTip.text = string.Empty;
|
DisplayTime();
|
raceTable.SetActiveIL(false);
|
waitTxt.SetActiveIL(true);
|
}
|
}
|
|
protected override void OnPreClose()
|
{
|
GlobalTimeEvent.Instance.minuteEvent -= OnMinuteEvent;
|
CrossServerQualifyingModel.Instance.UpdateCrossChampionshipPKZoneGroupInfoEvent -= UpdateRace;
|
}
|
#endregion
|
void DisplayTime()
|
{
|
time1.text = CrossServerQualifyingModel.Instance.GetStartBattleTime(ILChampionshipTimeConfig.GetBattleID(82));
|
time11.text = CrossServerQualifyingModel.Instance.GetStartBattleTime(ILChampionshipTimeConfig.GetBattleID(82));
|
time2.text = CrossServerQualifyingModel.Instance.GetStartBattleTime(ILChampionshipTimeConfig.GetBattleID(42));
|
time22.text = CrossServerQualifyingModel.Instance.GetStartBattleTime(ILChampionshipTimeConfig.GetBattleID(42));
|
var timeStr = CrossServerQualifyingModel.Instance.GetStartBattleTime(ILChampionshipTimeConfig.GetBattleID(22));
|
if (timeStr.Length > 0)
|
{
|
time3.text = timeStr.Split(' ')[1];
|
}
|
else
|
{
|
time3.text = string.Empty;
|
}
|
}
|
|
//决赛的两个人
|
void DisplayFinals()
|
{
|
if (CrossServerQualifyingModel.Instance.battleInfo.ContainsKey(2))
|
{
|
var battle = CrossServerQualifyingModel.Instance.battleInfo[2];
|
if (battle.Count > 0)
|
{
|
var playerIDs = battle[battle.Keys.ToList()[0]];
|
var playerAID = playerIDs.PlayerIDA;
|
var playerBID = playerIDs.PlayerIDB;
|
if (playerIDs.WinPlayerID == 0)
|
{
|
winA.SetActiveIL(false);
|
winB.SetActiveIL(false);
|
}
|
else if (playerIDs.WinPlayerID == playerIDs.PlayerIDA)
|
{
|
winA.SetActiveIL(true);
|
winA.gray = false;
|
winB.SetActiveIL(true);
|
winB.gray = true;
|
}
|
else
|
{
|
winA.SetActiveIL(true);
|
winA.gray = true;
|
winB.SetActiveIL(true);
|
winB.gray = false;
|
}
|
if (playerAID == 0)
|
{
|
nameA.text = Language.Get("UnDetermind");
|
fightPowerA.text = "0";
|
}
|
else
|
{
|
nameA.text = CrossServerQualifyingModel.Instance.fightersInfo[playerAID].PlayerName;
|
fightPowerA.text = CrossServerQualifyingModel.Instance.fightersInfo[playerAID].FightPower.ToString();
|
}
|
|
if (playerBID == 0)
|
{
|
nameB.text = Language.Get("UnDetermind");
|
fightPowerB.text = "0";
|
}
|
else
|
{
|
nameB.text = CrossServerQualifyingModel.Instance.fightersInfo[playerBID].PlayerName;
|
fightPowerB.text = CrossServerQualifyingModel.Instance.fightersInfo[playerBID].FightPower.ToString();
|
}
|
}
|
}
|
else
|
{
|
winA.SetActiveIL(false);
|
winB.SetActiveIL(false);
|
nameA.text = Language.Get("UnDetermind");
|
fightPowerA.text = "0";
|
nameB.text = Language.Get("UnDetermind");
|
fightPowerB.text = "0";
|
}
|
}
|
|
void DisplayRace()
|
{
|
DisplayFinals();
|
|
//8强
|
var battles = CrossServerQualifyingModel.Instance.battleInfo[8];
|
var keys = battles.Keys.ToList();
|
keys.Sort();
|
List<Int2> player8List = new List<Int2>();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
var battleNum = keys[i];
|
player8List.Add(new Int2 ((int)battles[battleNum].PlayerIDA, (int)battles[battleNum].WinPlayerID));
|
player8List.Add(new Int2((int)battles[battleNum].PlayerIDB, (int)battles[battleNum].WinPlayerID));
|
}
|
for (int i = 0; i < players8.Count; i++)
|
{
|
var playerID = i >= player8List.Count ? new Int2(0, 0) : player8List[i];
|
var _cell = players8[i].GetILBehaviour<CSQShootOutPlayerCell>();
|
_cell.Display((uint)playerID.x, (uint)playerID.y);
|
}
|
|
//4强
|
if (CrossServerQualifyingModel.Instance.battleInfo.ContainsKey(4))
|
{
|
battles = CrossServerQualifyingModel.Instance.battleInfo[4];
|
keys = battles.Keys.ToList();
|
keys.Sort();
|
List<Int2> player4List = new List<Int2>();
|
for (int i = 0; i < keys.Count; i++)
|
{
|
var battleNum = keys[i];
|
player4List.Add(new Int2((int)battles[battleNum].PlayerIDA, (int)battles[battleNum].WinPlayerID));
|
player4List.Add(new Int2((int)battles[battleNum].PlayerIDB, (int)battles[battleNum].WinPlayerID));
|
}
|
for (int i = 0; i < players4.Count; i++)
|
{
|
var playerID = i >= player4List.Count ? new Int2(0, 0) : player4List[i];
|
var _cell = players4[i].GetILBehaviour<CSQShootOutPlayerCell>();
|
_cell.Display((uint)playerID.x, (uint)playerID.y);
|
}
|
}
|
else
|
{
|
for (int i = 0; i < players4.Count; i++)
|
{
|
var _cell = players4[i].GetILBehaviour<CSQShootOutPlayerCell>();
|
_cell.Display(0, 0);
|
}
|
}
|
}
|
|
|
void EnterGame()
|
{
|
if (CrossServerQualifyingModel.Instance.nowGroupMark <= 8)
|
{
|
var battleID = CrossServerQualifyingModel.Instance.GetBattleID();
|
Debug.LogFormat("8强排位赛 流程ID {0}", battleID);
|
var config = ILChampionshipTimeConfig.Get(battleID);
|
if (config.StateValue % 10 == 2)
|
{
|
//进场时间
|
CrossServerQualifyingModel.Instance.EnterCrossServerQualifying();
|
}
|
else
|
{
|
//非比赛时间
|
SysNotifyMgr.Instance.ShowTip("CrossServerQualifying3");
|
}
|
}
|
else
|
{
|
//非比赛时间
|
SysNotifyMgr.Instance.ShowTip("CrossServerQualifying3");
|
}
|
}
|
|
void OnMinuteEvent()
|
{
|
enterGame.SetActiveIL(false);
|
timeTip.text = string.Empty;
|
|
var groupMark = CrossServerQualifyingModel.Instance.nowGroupMark;
|
if (groupMark <= 8 && groupMark != 0)
|
{
|
//如果玩家界面一直开着就需要刷新
|
if (CrossServerQualifyingModel.Instance.HaveMyBattle(groupMark))
|
{
|
enterGame.SetActiveIL(true);
|
var battleID = ILChampionshipTimeConfig.GetBattleID((int)groupMark * 10 + 2);
|
if (battleID != 0)
|
{
|
timeTip.text = Language.Get("CrossServerQualifying20", CrossServerQualifyingModel.Instance.GetStartBattleTime(battleID));
|
}
|
}
|
}
|
|
}
|
|
void UpdateRace()
|
{
|
if (!raceTable.gameObject.activeSelf)
|
{
|
OnAfterOpen();
|
}
|
else
|
{
|
DisplayRace();
|
}
|
}
|
}
|