//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, January 28, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using vnxbqy.UI;
|
|
public class CrossServerGodBattleFieldWin : ILWindow
|
{
|
Button itemsBtn;
|
Button rankButton;
|
Text cybName;
|
Text zjbName;
|
Text jfbName;
|
ItemCell superAward;
|
Text startTime;
|
Button seeother;
|
Transform daosys;
|
Transform fosys;
|
Transform daoin;
|
Transform foin;
|
Button achievementBtn;
|
Button enterFB;
|
Button buyTimes;
|
Text useTimes;
|
Transform startTimeObj;
|
Transform outSeason;
|
ScrollerController itemScroller;
|
Transform timeState;
|
Button storeBtn;
|
Button backBtn;
|
Button btnTeam;
|
|
bool isWaitPack = false;
|
DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
RoleModel roleModel { get { return ModelCenter.Instance.GetModel<RoleModel>(); } }
|
RankModel rankModel { get { return ModelCenter.Instance.GetModel<RankModel>(); } }
|
CrossServerGodBattleFieldAssortModel crossServerGodBattleFieldAssortModel { get { return ModelCenter.Instance.GetModel<CrossServerGodBattleFieldAssortModel>(); } }
|
#region Built-in
|
protected override void BindController()
|
{
|
itemsBtn = proxy.GetWidgtEx<Button>("ItemsButton");
|
rankButton = proxy.GetWidgtEx<Button>("RankButton");
|
cybName = proxy.GetWidgtEx<Text>("cyb");
|
zjbName = proxy.GetWidgtEx<Text>("zjb");
|
jfbName = proxy.GetWidgtEx<Text>("jfb");
|
superAward = proxy.GetWidgtEx<ItemCell>("itemcell");
|
startTime = proxy.GetWidgtEx<Text>("starttime");
|
seeother = proxy.GetWidgtEx<Button>("seeother");
|
daosys = proxy.GetWidgtEx<Transform>("daosys");
|
fosys = proxy.GetWidgtEx<Transform>("fosys");
|
daoin = proxy.GetWidgtEx<Transform>("daoin");
|
foin = proxy.GetWidgtEx<Transform>("foin");
|
achievementBtn = proxy.GetWidgtEx<Button>("achievement");
|
enterFB = proxy.GetWidgtEx<Button>("ENTERBTN");
|
buyTimes = proxy.GetWidgtEx<Button>("Btn_BuyTimes");
|
useTimes = proxy.GetWidgtEx<Text>("Txt_Count");
|
itemScroller = proxy.GetWidgtEx<ScrollerController>("scroller");
|
startTimeObj = proxy.GetWidgtEx<Transform>("startObj");
|
outSeason = proxy.GetWidgtEx<Transform>("outSeason");
|
timeState = proxy.GetWidgtEx<Transform>("timeState");
|
storeBtn = proxy.GetWidgtEx<Button>("storewin");
|
backBtn = proxy.GetWidgtEx<Button>("backBtn");
|
btnTeam = proxy.GetWidgtEx<Button>("btnTeam");
|
|
|
}
|
|
protected override void AddListeners()
|
{
|
|
itemsBtn.SetListener(() =>
|
{
|
ShowItemsDetailWin.titleMark = "CrossBattleField43";
|
ShowItemsDetailWin.itemsData = ILCrossServerModel.Instance.itemsShow;
|
WindowCenter.Instance.OpenIL<ShowItemsDetailWin>();
|
});
|
|
rankButton.SetListener(() =>
|
{
|
WindowCenter.Instance.OpenIL<CrossServerBattleFieldRankWin>();
|
});
|
|
seeother.SetListener(() =>
|
{
|
//if (CrossServerOneVsOnePKSeason.Instance.InPkSeason(TimeUtility.ServerNow))
|
// WindowCenter.Instance.OpenIL<CrossServerBattleFieldOpenTimeWin>();
|
//else
|
// SysNotifyMgr.Instance.ShowTip("TreasureOneVsOneSeasonNotStart");
|
WindowCenter.Instance.OpenIL<CrossServerBattleFieldOpenTimeWin>();
|
});
|
|
achievementBtn.SetListener(() =>
|
{
|
WindowCenter.Instance.OpenIL<CrossServerBattleFieldAchievementWin>();
|
});
|
|
enterFB.SetListener(EnterFB);
|
|
buyTimes.SetListener(() =>
|
{
|
WindowCenter.Instance.OpenEx<HazyRegionBuyTimesWin>(false, (int)DailyQuestType.default4);
|
});
|
|
storeBtn.SetListener(() =>
|
{
|
//WindowCenter.Instance.Open<StoreWin>(false, 3);
|
WindowJumpMgr.Instance.WindowJumpToEx("StoreWin", functionOrder:3);
|
});
|
|
|
backBtn.SetListener(() =>
|
{
|
ILCrossServerModel.Instance.selectIndex = ILCrossServerModel.Instance.GetCurBattleFieldIndex();
|
});
|
|
btnTeam.SetListener(() =>
|
{
|
if (TimeUtility.OpenDay < GeneralDefine.crossServerBattleFieldOpenDay)
|
{
|
return;
|
}
|
|
crossServerGodBattleFieldAssortModel.isDisplayRedPoint = false;
|
crossServerGodBattleFieldAssortModel.UpdateRedPoint();
|
|
if (!crossServerGodBattleFieldAssortModel.isSendB924Pack)
|
{
|
isWaitPack = true;
|
if (crossServerGodBattleFieldAssortModel.IsOpenAction())
|
{
|
SysNotifyMgr.Instance.ShowTip("GodBattleFieldAssort03");
|
return;
|
}
|
crossServerGodBattleFieldAssortModel.TrySendQueryPlayerFuncTeam();
|
}
|
else
|
{
|
bool isHaveTeam = crossServerGodBattleFieldAssortModel.TryGetPlayerTeamInfo(out bool isCaptain, out uint teamID, out AssortTeamInfo teamInfo);
|
if (isHaveTeam)
|
{
|
WindowCenter.Instance.Open<CrossServerGodBattleFieldAssortWin>();
|
}
|
else
|
{
|
if (crossServerGodBattleFieldAssortModel.IsOpenAction())
|
{
|
SysNotifyMgr.Instance.ShowTip("GodBattleFieldAssort03");
|
return;
|
}
|
WindowCenter.Instance.Open<CrossServerGodBattleFieldAssortNoTeamWin>();
|
}
|
}
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
isWaitPack = false;
|
if (TimeUtility.OpenDay < GeneralDefine.crossServerBattleFieldOpenDay)
|
{
|
WindowCenter.Instance.Close<CrossServerWin>();
|
return;
|
}
|
crossServerGodBattleFieldAssortModel.TrySendQueryPlayerFuncTeam();
|
if (roleModel.openUIMark / ILCrossServerModel.openUIMark == 1)
|
{
|
ILCrossServerModel.Instance.selectJumpIndex = roleModel.openUIMark % ILCrossServerModel.openUIMark;
|
roleModel.openUIMark = 0;
|
}
|
ILCrossServerModel.Instance.selectIndex = ILCrossServerModel.Instance.GetCurBattleFieldIndex();
|
if (ILCrossServerModel.Instance.selectJumpIndex != 0 && (ILCrossServerModel.Instance.selectJumpIndex - 1) > ILCrossServerModel.Instance.selectIndex)
|
{
|
//只能跳转未开启场次
|
ILCrossServerModel.Instance.selectIndex = ILCrossServerModel.Instance.selectJumpIndex - 1;
|
ILCrossServerModel.Instance.selectJumpIndex = 0;
|
}
|
rankModel.onRankRefresh += UpdatePlayerBillboardEvent;
|
ILCrossServerModel.Instance.onSelectUpdate += OnSelectUpdate;
|
dailyQuestModel.dailyQuestProgressUpdateEvent += DailyQuestProgressUpdateEvent;
|
itemScroller.OnRefreshCell += OnRefreshCell;
|
ILCrossServerModel.Instance.UpdateBuyInfoEvent += ShowActionInfoByIndex;
|
crossServerGodBattleFieldAssortModel.UpdateQueryPlayerFuncTeamRetInfoEvent += OnUpdateQueryPlayerFuncTeamRetInfoEvent;
|
crossServerGodBattleFieldAssortModel.UpdateTeamInfoEvent += OnUpdateFuncTeamRefreshInfoEvent;
|
|
rankModel.QueryCrossRank(151, ILCrossServerModel.Instance.zoneID, 0, 100, cd: 100);
|
rankModel.QueryCrossRank(152, ILCrossServerModel.Instance.zoneID, 0, 100, cd: 100);
|
rankModel.QueryCrossRank(153, ILCrossServerModel.Instance.zoneID, 0, 100, cd: 100);
|
|
cybName.text = ILCrossServerModel.Instance.GetFirstRankName(151);
|
zjbName.text = ILCrossServerModel.Instance.GetFirstRankName(152);
|
jfbName.text = ILCrossServerModel.Instance.GetFirstRankName(153);
|
|
int itemID = ILCrossServerModel.Instance.itemsShow[0].id;
|
int itemCount = ILCrossServerModel.Instance.itemsShow[0].count;
|
var model = new ItemCellModel(itemID, false, (ulong)itemCount);
|
superAward.Init(model);
|
superAward.button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemID);
|
});
|
|
|
ShowTimes();
|
CreateItemScroller();
|
}
|
|
protected override void OnPreClose()
|
{
|
rankModel.onRankRefresh -= UpdatePlayerBillboardEvent;
|
ILCrossServerModel.Instance.onSelectUpdate -= OnSelectUpdate;
|
dailyQuestModel.dailyQuestProgressUpdateEvent -= DailyQuestProgressUpdateEvent;
|
itemScroller.OnRefreshCell -= OnRefreshCell;
|
ILCrossServerModel.Instance.UpdateBuyInfoEvent -= ShowActionInfoByIndex;
|
crossServerGodBattleFieldAssortModel.UpdateQueryPlayerFuncTeamRetInfoEvent -= OnUpdateQueryPlayerFuncTeamRetInfoEvent;
|
crossServerGodBattleFieldAssortModel.UpdateTeamInfoEvent -= OnUpdateFuncTeamRefreshInfoEvent;
|
}
|
|
void OnUpdateFuncTeamRefreshInfoEvent()
|
{
|
if (isWaitPack)
|
{
|
isWaitPack = false;
|
WindowCenter.Instance.Open<CrossServerGodBattleFieldAssortWin>();
|
}
|
|
}
|
|
void OnUpdateQueryPlayerFuncTeamRetInfoEvent()
|
{
|
if (isWaitPack)
|
{
|
isWaitPack = false;
|
WindowCenter.Instance.Open<CrossServerGodBattleFieldAssortNoTeamWin>();
|
}
|
}
|
|
protected override void OnAfterOpen()
|
{
|
ShowActionInfoByIndex();
|
}
|
#endregion
|
|
void DailyQuestProgressUpdateEvent(int id)
|
{
|
ShowTimes();
|
}
|
|
void ShowTimes()
|
{
|
var config = DailyQuestConfig.Get((int)DailyQuestType.default4);
|
var dailyQuestOpenTime = DailyQuestOpenTimeConfig.Get(config.RelatedID);
|
|
var totalTimes = dailyQuestModel.GetDailyQuestTotalTimes((int)DailyQuestType.default4);
|
var completedTimes = dailyQuestModel.GetDailyQuestCompletedTimes((int)DailyQuestType.default4);
|
useTimes.text = StringUtility.Contact(totalTimes - completedTimes, "/", dailyQuestOpenTime.DayTimes);
|
useTimes.color = UIHelper.GetUIColor(completedTimes >= totalTimes ? TextColType.Red : TextColType.White);
|
}
|
|
void UpdatePlayerBillboardEvent(int type)
|
{
|
cybName.text = ILCrossServerModel.Instance.GetFirstRankName(151);
|
zjbName.text = ILCrossServerModel.Instance.GetFirstRankName(152);
|
jfbName.text = ILCrossServerModel.Instance.GetFirstRankName(153);
|
}
|
|
void ShowActionInfoByIndex()
|
{
|
//if (CrossServerOneVsOnePKSeason.Instance.InPkSeason(TimeUtility.ServerNow))
|
{
|
startTimeObj.SetActiveIL(true);
|
outSeason.SetActiveIL(false);
|
enterFB.SetColorful(null, true);
|
|
if (ILCrossServerModel.Instance.selectIndex != ILCrossServerModel.Instance.GetCurBattleFieldIndex())
|
{
|
backBtn.SetActiveIL(true);
|
enterFB.SetActiveIL(false);
|
}
|
else
|
{
|
backBtn.SetActiveIL(false);
|
enterFB.SetActiveIL(true);
|
enterFB.SetColorful(null, true);
|
}
|
}
|
//else
|
//{
|
// startTimeObj.SetActiveIL(false);
|
// outSeason.SetActiveIL(true);
|
// enterFB.SetActiveIL(true);
|
// enterFB.SetColorful(null, false);
|
// backBtn.SetActiveIL(false);
|
//}
|
|
//-1 代表今日已无场次,则显示第二天的第一场
|
int index = Math.Max(ILCrossServerModel.Instance.selectIndex, 0);
|
var int3Config = ILCrossServerModel.Instance.crossBattleFieldOpenTimes[index];
|
startTime.text = (ILCrossServerModel.Instance.selectIndex == -1 ? Language.Get("CrossBattleField11") : string.Empty)
|
+ int3Config.x + ":" + int3Config.y.ToString("D2");
|
|
timeState.SetActiveIL(ILCrossServerModel.Instance.GetActionState(index) == 1);
|
|
if (int3Config.z == 0 || ILCrossServerModel.Instance.selectIndex == -1)
|
{
|
daosys.SetActiveIL(true);
|
fosys.SetActiveIL(true);
|
daoin.SetActiveIL(false);
|
foin.SetActiveIL(false);
|
}
|
else
|
{
|
daosys.SetActiveIL(false);
|
fosys.SetActiveIL(false);
|
daoin.SetActiveIL(true);
|
foin.SetActiveIL(true);
|
|
var daoCell = daoin.GetILBehaviour<CrossServerBattleFieldFactionCell>();
|
daoCell.Display(1, int3Config);
|
|
var foCell = foin.GetILBehaviour<CrossServerBattleFieldFactionCell>();
|
foCell.Display(2, int3Config);
|
}
|
}
|
|
void OnSelectUpdate()
|
{
|
ShowActionInfoByIndex();
|
}
|
|
void EnterFB()
|
{
|
int error;
|
if (ILCrossServerModel.Instance.CanEnter(out error))
|
{
|
EnterGSZC();
|
return;
|
}
|
ILCrossServerModel.Instance.ProcessEnterError(error);
|
}
|
|
void EnterGSZC()
|
{
|
var state = ILCrossServerModel.Instance.GetActionState(ILCrossServerModel.Instance.selectIndex);
|
if (state != 1)
|
{
|
SysNotifyMgr.Instance.ShowTip("ActionUnOpen");
|
return;
|
}
|
|
//在召集队伍内可以不消耗次数
|
if (!ILCrossServerModel.Instance.IsInFactionCall())
|
{
|
var totalTimes = dailyQuestModel.GetDailyQuestTotalTimes((int)DailyQuestType.default4);
|
var completedTimes = dailyQuestModel.GetDailyQuestCompletedTimes((int)DailyQuestType.default4);
|
if (totalTimes <= completedTimes)
|
{
|
WindowCenter.Instance.Open<HazyRegionBuyTimesWin>(false, (int)DailyQuestType.default4);
|
return;
|
}
|
}
|
|
ILCrossServerModel.Instance.RequestEnter(ILCrossServerModel.Instance.gszcMapID);
|
return;
|
}
|
|
void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
var item = cell.GetComponentEx<ItemCell>();
|
var config = DailyQuestConfig.Get((int)DailyQuestType.default4);
|
|
var itemId = config.RewardID[cell.index];
|
var model = new ItemCellModel(itemId, false, 1);
|
item.Init(model);
|
item.button.SetListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
|
void CreateItemScroller()
|
{
|
var config = DailyQuestConfig.Get((int)DailyQuestType.default4);
|
itemScroller.Refresh();
|
for (int i = 0; i < config.RewardID.Length; i++)
|
{
|
itemScroller.AddCell(ScrollerDataType.Header, i);
|
}
|
itemScroller.Restart();
|
|
itemScroller.m_Scorller.RefreshActiveCellViews();
|
}
|
}
|