//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, April 22, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using DG.Tweening;
|
using System.Text;
|
|
namespace vnxbqy.UI
|
{
|
//渡劫界面
|
// 1. 计算有几道天雷
|
// 2. 过场云打开
|
// 3. 播放天雷动画 第几道 - 雷击动画 - 飘血动画(进度条变化)
|
public class RealmBreakWin : Window
|
{
|
[SerializeField] RawImage rawPlayer;
|
[SerializeField] UIEffect guochangyun;
|
|
[SerializeField] RectTransform tianleiWord;
|
[SerializeField] Image numImage;
|
[SerializeField] UIFrame leiJiFrame;
|
[SerializeField] Text hurtText;
|
[SerializeField] IntensifySmoothSlider expSlider;
|
[SerializeField] Text expText; //战力
|
|
int flashCount = 0;
|
int currentFlash = 0;
|
ulong hurtValue = 0;
|
ulong curFightPointValue = 0;
|
ulong maxFightPointValue = 0;
|
RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
leiJiFrame.SetActive(false);
|
hurtText.SetActive(false);
|
tianleiWord.SetActive(false);
|
//3-10道天雷,跨大境界就多一次
|
flashCount = Math.Min(PlayerDatas.Instance.baseData.realmLevel / 4 + 3, 9);
|
//每道天雷伤害为 战力的 flashCount+1分之一
|
hurtValue = PlayerDatas.Instance.baseData.FightPoint / (ulong)(flashCount + 1);
|
curFightPointValue = maxFightPointValue = PlayerDatas.Instance.baseData.FightPoint;
|
currentFlash = 1;
|
Display();
|
WholeAnimate();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
UI3DModelExhibition.Instance.StopShow();
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
//protected override void LateUpdate()
|
//{
|
|
//}
|
#endregion
|
|
void Display()
|
{
|
UI3DModelExhibition.Instance.ShowSitDownPlayer(rawPlayer, PlayerDatas.Instance.baseData.Job);
|
|
}
|
|
void WholeAnimate()
|
{
|
var squences = DOTween.Sequence();
|
|
if (currentFlash == 1)
|
{
|
guochangyun.Play();
|
guochangyun.target.GetAnimator().speed = 2f;
|
expText.text = StringUtility.Contact(Language.Get("MainInterfacePanel_HeadPortraitTip_ZL"), Language.Get("BlessedLand036", curFightPointValue, maxFightPointValue));
|
expSlider.value = 1;
|
squences.AppendInterval(0.5f);
|
}
|
|
//天道字
|
squences.AppendCallback(() =>
|
{
|
numImage.SetSprite("DujieNum" + currentFlash);
|
tianleiWord.transform.localScale = Vector3.one * 0.4f;
|
tianleiWord.SetActive(true);
|
});
|
squences.Append(tianleiWord.transform.DOScale(1, 0.2f));
|
squences.AppendInterval(0.2f);
|
//雷击播放一次
|
squences.AppendCallback(() =>
|
{
|
tianleiWord.SetActive(false);
|
leiJiFrame.SetLoopCount(1);
|
leiJiFrame.SetActive(true);
|
SoundPlayer.Instance.PlayUIAudio(859);
|
});
|
squences.AppendInterval(0.2f);
|
// 进度条变化
|
squences.AppendCallback(() =>
|
{
|
curFightPointValue = curFightPointValue - hurtValue;
|
expText.text = StringUtility.Contact(Language.Get("MainInterfacePanel_HeadPortraitTip_ZL"), Language.Get("BlessedLand036", curFightPointValue, maxFightPointValue));
|
expSlider.delay = 0;
|
expSlider.value = (float)curFightPointValue / maxFightPointValue;
|
});
|
|
//飘血动画
|
squences.AppendCallback(() =>
|
{
|
hurtText.SetActive(true);
|
hurtText.text = ConvertToArtFont("EnemyAttack", hurtValue + (ulong)UnityEngine.Random.Range(0, (int)hurtValue / (flashCount * 2)));
|
hurtText.transform.localPosition = new Vector3(0, -100, 0);
|
hurtText.transform.localScale = Vector3.one * 0.5f;
|
});
|
squences.Append(hurtText.transform.DOScale(2f, 0.1f));
|
squences.Join(hurtText.transform.DOLocalMoveY(60, 0.1f));
|
squences.Join(hurtText.DOFade(1, 0.1f));
|
squences.Append(hurtText.transform.DOPunchPosition(new Vector3(0,30,0), 0.3f, 10));
|
squences.AppendInterval(0.1f);
|
squences.Append(hurtText.transform.DOScale(0.5f, 0.2f));
|
squences.Join(hurtText.DOFade(0, 0.2f));
|
//继续下一次到天雷结束
|
squences.onComplete = () =>
|
{
|
currentFlash++;
|
if (currentFlash <= flashCount)
|
{
|
WholeAnimate();
|
}
|
else
|
{
|
Close();
|
WindowCenter.Instance.Open<RealmPromoteWin>();
|
}
|
};
|
}
|
|
string ConvertToArtFont(string _key, ulong _num)
|
{
|
var config = DamageNumConfig.Get(_key);
|
var stringBuild = new StringBuilder();
|
stringBuild.Append((char)config.minus);
|
|
var chars = _num.ToString();
|
for (var i = 0; i < chars.Length; i++)
|
{
|
var numChar = config.nums[(int)chars[i] - 48];
|
if (numChar > 0)
|
{
|
stringBuild.Append((char)numChar);
|
}
|
}
|
|
return stringBuild.ToString();
|
}
|
}
|
|
}
|
|
|
|
|