//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, December 19, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
|
public class CrossServerSettlementWin : Window
|
{
|
[SerializeField] GameObject m_BackFailure;
|
[SerializeField] GameObject m_BackWin;
|
[SerializeField] Button m_DropOutBtn;
|
[SerializeField] Text m_DropOutBtnText;
|
|
[SerializeField] GameObject m_SessionObj;
|
[SerializeField] Text m_SessionTxt;
|
[SerializeField] GameObject m_SegmentObj;
|
[SerializeField] Text m_SegmentTxt1;
|
[SerializeField] Text m_SegmentTxt2;
|
|
[SerializeField] Text m_SorceText;
|
|
#region Built-in
|
CrossServerOneVsOneModel crossServerModel { get { return ModelCenter.Instance.GetModel<CrossServerOneVsOneModel>(); } }
|
DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
BuffModel m_BuffModel;
|
BuffModel Buffmodel { get { return m_BuffModel ?? (m_BuffModel = ModelCenter.Instance.GetModel<BuffModel>()); } }
|
float timer = 0f;
|
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_DropOutBtn.AddListener(ExitDungeon);
|
}
|
|
protected override void OnPreOpen()
|
{
|
PlayerDatas.Instance.hero.StopAll();
|
timer = 0f;
|
int WinnerID = crossServerModel.pkResultInfo.WinnerID;
|
int playerID = (int)PlayerDatas.Instance.baseData.PlayerID;
|
if (WinnerID == playerID)
|
{
|
m_BackFailure.SetActive(false);
|
m_BackWin.SetActive(true);
|
}
|
else
|
{
|
m_BackFailure.SetActive(true);
|
m_BackWin.SetActive(false);
|
}
|
|
SetNormal();
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
CrossServerOneVsOneRewardModel.SetPkType();
|
Buffmodel.PkType = CrossServerOneVsOneRewardModel.PkType;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
timer -= Time.deltaTime;
|
if (timer < 0f)
|
{
|
timer = 1f;
|
var endTime = model.GetCoolDownEndTime(DungeonCoolDownType.LeaveMap);
|
var seconds = (endTime - TimeUtility.ServerNow).TotalSeconds;
|
m_DropOutBtnText.text = Language.Get("DungeonVictoryWin_Btn_Exit_1", Mathf.Clamp((int)seconds, 0, int.MaxValue));
|
if (seconds <= 0)
|
{
|
ExitDungeon();
|
}
|
}
|
}
|
#endregion
|
private void ExitDungeon()
|
{
|
if (ClientCrossServerOneVsOne.isClientCrossServerOneVsOne)
|
{
|
ClientCrossServerOneVsOne.StopClientCrossServerOneVsOne();
|
}
|
else
|
{
|
model.ExitCurrentDungeon();
|
}
|
|
CloseClick();
|
PlayerDatas.Instance.hero.StopAll();
|
}
|
|
private void SetNormal()
|
{
|
|
if (crossServerModel.pkResultInfo.WinStreak > 1)
|
{
|
m_SessionObj.SetActive(true);
|
m_SessionTxt.text = crossServerModel.pkResultInfo.WinStreak.ToString();
|
}
|
else
|
{
|
m_SessionObj.SetActive(false);
|
}
|
|
var config1 = CrossServerArenaConfig.Get(CrossServerOneVsOneRewardModel.PkDanLvNow);
|
m_SegmentTxt1.text = config1.Name;
|
var config2 = CrossServerArenaConfig.Get(crossServerModel.pkResultInfo.DanLV);
|
m_SegmentTxt2.text = config2.Name;
|
|
if (crossServerModel.pkResultInfo.WinStreak > 1)
|
{
|
int virtualWinStreak = crossServerModel.pkResultInfo.WinStreak - 1;
|
Equation.Instance.Clear();
|
Equation.Instance.AddKeyValue("cWinCount", virtualWinStreak);
|
int score = Equation.Instance.Eval<int>(crossServerModel.winStreakScoreFormula);
|
|
m_SorceText.text = Language.Get("CrossServer_Z1", crossServerModel.pkResultInfo.AddScore, score);
|
}
|
else
|
{
|
m_SorceText.text = Language.Get("CrossServer_Z2", crossServerModel.pkResultInfo.AddScore);
|
}
|
}
|
|
|
}
|
|
}
|
|
|
|
|