//--------------------------------------------------------
|
// [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 CrossServerBattleFieldFBMissionWin : ILWindow
|
{
|
Text title;
|
List<Button> buffs1 = new List<Button>();
|
IntensifySmoothSlider slider1;
|
Text sliderText1;
|
List<Button> buffs2 = new List<Button>();
|
IntensifySmoothSlider slider2;
|
Text sliderText2;
|
Button awardBtn;
|
Text killNum;
|
Transform killOBJ;
|
Text tipTitle;
|
RichText hurtValue;
|
RichText hurtValue2;
|
Transform tipInfo;
|
List<Transform> scorelayouts = new List<Transform>();
|
BuffBGMScripts _buffBGM;
|
IntensifySmoothSlider godSlider;
|
ButtonEx switchBtn;
|
Image showStateImage;
|
Image hideStateImge;
|
ButtonEx callBtn;
|
Text callText;
|
Transform panel;
|
|
|
int showIndex = 0; //积分显示第几个
|
List<List<int>> scoreShowList = new List<List<int>>();
|
List<CrossServerScoreShowBehaviour> scoreList = new List<CrossServerScoreShowBehaviour>();
|
float lastShowTime;
|
|
bool isHidePanel = false;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
title = proxy.GetWidgtEx<Text>("title");
|
buffs1.Add(proxy.GetWidgtEx<Button>("buffBtn1_0"));
|
buffs1.Add(proxy.GetWidgtEx<Button>("buffBtn1_1"));
|
slider1 = proxy.GetWidgtEx<IntensifySmoothSlider>("slider1");
|
sliderText1 = proxy.GetWidgtEx<Text>("sliderText1");
|
buffs2.Add(proxy.GetWidgtEx<Button>("buffBtn2_0"));
|
buffs2.Add(proxy.GetWidgtEx<Button>("buffBtn2_1"));
|
slider2 = proxy.GetWidgtEx<IntensifySmoothSlider>("slider2");
|
sliderText2 = proxy.GetWidgtEx<Text>("sliderText2");
|
awardBtn = proxy.GetWidgtEx<Button>("awardBtn");
|
godSlider = proxy.GetWidgtEx<IntensifySmoothSlider>("godSlider");
|
killNum = proxy.GetWidgtEx<Text>("killNum");
|
tipTitle = proxy.GetWidgtEx<Text>("tipTitle");
|
hurtValue = proxy.GetWidgtEx<RichText>("hurtValue");
|
hurtValue2 = proxy.GetWidgtEx<RichText>("hurtValue2");
|
tipInfo = proxy.GetWidgtEx<Transform>("tipInfo");
|
for (int i = 0; i < 6; i++)
|
{
|
scorelayouts.Add(proxy.GetWidgtEx<Transform>("scorelayout" + i));
|
}
|
|
_buffBGM = proxy.GetWidgtEx<BuffBGMScripts>("BuffBGM");
|
|
killOBJ = proxy.GetWidgtEx<Transform>("KillOBJ");
|
switchBtn = proxy.GetWidgtEx<ButtonEx>("Btn_Switch");
|
showStateImage = proxy.GetWidgtEx<Image>("showStateImage");
|
hideStateImge = proxy.GetWidgtEx<Image>("hideStateImge");
|
callBtn = proxy.GetWidgtEx<ButtonEx>("call");
|
callText = proxy.GetWidgtEx<Text>("callTextEx");
|
panel = proxy.GetWidgtEx<Transform>("pannel");
|
|
callBtn.SetListener(() => {
|
int index = ILCrossServerModel.Instance.GetCurBattleFieldIndex();
|
var int3Config = ILCrossServerModel.Instance.crossBattleFieldOpenTimes[index];
|
var state = ILCrossServerModel.Instance.GetActionState(index);
|
if (state != 1)
|
{
|
return;
|
}
|
CrossServerBattleFieldBuyWin.hour = int3Config.x;
|
CrossServerBattleFieldBuyWin.minute = int3Config.y;
|
|
WindowCenter.Instance.OpenIL<CrossServerBattleFieldBuyWin>();
|
|
});
|
|
switchBtn.SetListener(() =>
|
{
|
isHidePanel = !isHidePanel;
|
ShowPanel();
|
});
|
}
|
|
protected override void AddListeners()
|
{
|
buffs1[0].SetListener(()=> {
|
if (ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo == null ||
|
ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo.Count < 2)
|
return;
|
|
ShowBuffInfo(ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo[0],
|
ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo[1] - ILTimeUtility.CSAllSeconds
|
);
|
});
|
|
buffs2[0].SetListener(() => {
|
if (ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo == null ||
|
ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo.Count < 2)
|
return;
|
|
ShowBuffInfo(ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo[0],
|
ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo[1] - ILTimeUtility.CSAllSeconds
|
);
|
});
|
|
buffs1[1].SetListener(()=> {
|
//测试积分飘动
|
scoreShowList.Clear();
|
for (int i = 0; i < 2; i++)
|
{
|
scoreShowList.Add(new List<int>() { UnityEngine.Random.Range(0, 10000), i});
|
}
|
});
|
|
awardBtn.SetListener(()=> {
|
WindowCenter.Instance.OpenIL<CrossServerBattleFieldGodAwardWin>();
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
ILCrossServerModel.Instance.FactionInfEvent += FactionInfEvent;
|
ILCrossServerModel.Instance.PlayerInfoEvent += PlayerInfoEvent;
|
ILCrossServerModel.Instance.WorldInfoEvent += WorldInfoEvent;
|
lastShowTime = Time.time;
|
Display();
|
}
|
|
protected override void OnPreClose()
|
{
|
ILCrossServerModel.Instance.FactionInfEvent -= FactionInfEvent;
|
ILCrossServerModel.Instance.PlayerInfoEvent -= PlayerInfoEvent;
|
ILCrossServerModel.Instance.WorldInfoEvent -= WorldInfoEvent;
|
}
|
|
|
protected override void OnAfterOpen()
|
{
|
scoreList.Clear();
|
for (int i = 0; i < scorelayouts.Count; i++)
|
{
|
var cell = scorelayouts[i].GetILBehaviour<CrossServerScoreShowBehaviour>();
|
cell.Init();
|
scoreList.Add(cell);
|
}
|
}
|
|
|
protected override void LateUpdate()
|
{
|
if (scoreShowList.Count == 0 || scoreList.Count == 0) return;
|
|
if (Time.time - lastShowTime < 0.2) return;
|
|
scoreList[showIndex].Display(scoreShowList[0][0], scoreShowList[0][1]);
|
showIndex++;
|
if (showIndex == scoreList.Count)
|
showIndex = 0;
|
scoreShowList.RemoveAt(0);
|
lastShowTime = Time.time;
|
|
}
|
|
#endregion
|
|
void ShowBuffInfo(int skillID, int seconds)
|
{
|
var skillconfig = SkillConfig.Get(skillID);
|
_buffBGM.SetActiveIL(true);
|
_buffBGM.b_BuffIcon.SetSprite(skillconfig.IconName);
|
_buffBGM.b_BuffName.text = skillconfig.SkillName;
|
_buffBGM.b_BuffContent.text = skillconfig.BuffDescription;
|
_buffBGM.b_BuffTime.SetActive(true);
|
_buffBGM.b_BuffTime.text = TimeUtility.SecondsToDHMSCHS(seconds);
|
_buffBGM.BiBuffText.SetActive(false);
|
_buffBGM._OnOff = false;
|
}
|
|
void FactionInfEvent()
|
{
|
if (ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo != null)
|
{
|
if (ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo == null ||
|
ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo.Count < 2 ||
|
ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo[1] <= ILTimeUtility.CSAllSeconds)
|
{
|
//目前只有1个buff存在的情况
|
buffs1[0].SetActiveIL(false);
|
if (ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo.Count == 2)
|
ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo.Clear();
|
}
|
else
|
{
|
buffs1[0].SetActiveIL(true);
|
buffs1[0].GetComponentEx<Image>().SetSprite(SkillConfig.Get(ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo[0]).IconName);
|
}
|
}
|
if (ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo != null)
|
{
|
if (ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo == null ||
|
ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo.Count < 2 ||
|
ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo[1] <= ILTimeUtility.CSAllSeconds)
|
{
|
//目前只有1个buff存在的情况
|
buffs2[0].SetActiveIL(false);
|
}
|
else
|
{
|
buffs2[0].SetActiveIL(true);
|
buffs1[0].GetComponentEx<Image>().SetSprite(SkillConfig.Get(ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo[0]).IconName);
|
}
|
}
|
slider1.value = (float)Math.Round((float)ILCrossServerModel.Instance.factionInfo_1.score / ILCrossServerModel.Instance.CrossBattlefieldWinScore, 2, MidpointRounding.AwayFromZero);
|
sliderText1.text = UIHelper.ReplaceLargeNum(ILCrossServerModel.Instance.factionInfo_1.score);
|
|
slider2.value = (float)Math.Round((float)ILCrossServerModel.Instance.factionInfo_2.score / ILCrossServerModel.Instance.CrossBattlefieldWinScore, 2, MidpointRounding.AwayFromZero);
|
sliderText2.text = UIHelper.ReplaceLargeNum(ILCrossServerModel.Instance.factionInfo_2.score);
|
|
if (ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldBossID)
|
{
|
hurtValue.text = Language.Get("CrossBattleField69_1", ILCrossServerModel.Instance.factionInfo_1.hurtBossValue);
|
hurtValue2.text = Language.Get("CrossBattleField69_2", ILCrossServerModel.Instance.factionInfo_2.hurtBossValue);
|
}
|
|
ILCrossServerModel.FactionInfo factionInfo;
|
if (PlayerDatas.Instance.baseData.faction == 1)
|
{
|
factionInfo = ILCrossServerModel.Instance.factionInfo_1;
|
}
|
else
|
{
|
factionInfo = ILCrossServerModel.Instance.factionInfo_2;
|
}
|
godSlider.value = (float)Math.Round((float)factionInfo.superItemProgress / ILCrossServerModel.Instance.contributionMaxValue, 2, MidpointRounding.AwayFromZero);
|
|
bool isCall = factionInfo.sysCallBuyIDList != null ? factionInfo.sysCallBuyIDList.Contains((int)PlayerDatas.Instance.baseData.PlayerID) : false;
|
callBtn.interactable = !isCall;
|
callText.text = isCall ? Language.Get("CrossBattleField62") : Language.Get("CrossBattleField36");
|
callBtn.SetColorful(null, !isCall);
|
}
|
|
void Display()
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var mapConfig = MapConfig.Get(mapId);
|
title.text = mapConfig.Name;// + Language.Get("CrossBattleField66", PlayerDatas.Instance.baseData.FBID + 1);
|
isHidePanel = false;
|
ShowPanel();
|
FactionInfEvent();
|
PlayerInfoEvent();
|
WorldInfoEvent();
|
}
|
|
void ShowPanel()
|
{
|
panel.SetActiveIL(!isHidePanel);
|
showStateImage.SetActiveIL(!isHidePanel);
|
hideStateImge.SetActiveIL(isHidePanel);
|
}
|
|
|
int lastValue = 0;// 上一次的贡献值
|
void PlayerInfoEvent()
|
{
|
var continueKillCount = ILCrossServerModel.Instance.playerInfo.continueKillCount;
|
if (continueKillCount == 0)
|
{
|
killOBJ.SetActiveIL(false);
|
}
|
else
|
{
|
killOBJ.SetActiveIL(true);
|
killNum.text = ILCrossServerModel.Instance.playerInfo.continueKillCount.ToString();
|
}
|
|
if (ILCrossServerModel.Instance.playerInfo.addScore.Count > 0)
|
{
|
scoreShowList.Add(new List<int>() { ILCrossServerModel.Instance.playerInfo.addScore[0],
|
ILCrossServerModel.Instance.playerInfo.addScore[1] });
|
ILCrossServerModel.Instance.playerInfo.addScore.Clear();
|
}
|
|
if (lastValue != 0 && (ILCrossServerModel.Instance.playerInfo.superItemContribution - lastValue) > 0)
|
{
|
scoreShowList.Add(new List<int>() { ILCrossServerModel.Instance.playerInfo.superItemContribution - lastValue, 100 });
|
}
|
lastValue = ILCrossServerModel.Instance.playerInfo.superItemContribution;
|
}
|
|
void WorldInfoEvent()
|
{
|
if (ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldBossID)
|
{
|
tipTitle.text = Language.Get("CrossBattleField70");
|
hurtValue.SetActiveIL(true);
|
tipInfo.SetActiveIL(false);
|
hurtValue.text = Language.Get("CrossBattleField69_1", ILCrossServerModel.Instance.factionInfo_1.hurtBossValue);
|
hurtValue2.text = Language.Get("CrossBattleField69_2", ILCrossServerModel.Instance.factionInfo_2.hurtBossValue);
|
}
|
else
|
{
|
tipTitle.text = Language.Get("CrossBattleField71");
|
hurtValue.SetActiveIL(false);
|
tipInfo.SetActiveIL(true);
|
}
|
}
|
}
|