using UnityEngine;
|
using UnityEngine.UI;
|
using System.Collections.Generic;
|
using Cysharp.Threading.Tasks;
|
|
public class HeroCallResultCell : MonoBehaviour
|
{
|
[SerializeField] UIHeroController heroModel;
|
[SerializeField] Image newMarkImg;
|
[SerializeField] UIEffectPlayer starEffect;
|
[SerializeField] UIEffectPlayer lightEffect;
|
[SerializeField] UIEffectPlayer boomEffect;
|
[SerializeField] UIEffectPlayer tableEffect;
|
|
|
/// <summary>
|
/// 抽奖结果的小人展示
|
/// </summary>
|
/// <param name="heroID"></param>
|
/// <param name="index">第几抽,0代表单抽</param>
|
/// <param name="isForceSkip">强制跳过动画</param>
|
public void Display(int heroID, int index, bool isForceSkip=false)
|
{
|
DisplayAsync(heroID, index, isForceSkip).Forget();
|
}
|
|
async UniTask DisplayAsync(int heroID, int index, bool isForceSkip=false)
|
{
|
this.transform.localScale = Vector3.zero;
|
int delaytime = LocalSave.GetBool(HeroUIManager.skipKey, false) ? 50 * index : 100 * index;
|
|
await UniTask.Delay(delaytime);
|
this.transform.localScale = Vector3.one;
|
//先显示台子,再显示小人
|
heroModel.SetActive(false);
|
newMarkImg.SetActive(false);
|
var heroConfig = HeroConfig.Get(heroID);
|
var quality = heroConfig.Quality;
|
|
//是否跳过动画
|
if (isForceSkip || LocalSave.GetBool(HeroUIManager.skipKey, false))
|
{
|
//红色特殊
|
if (!isForceSkip)
|
{
|
boomEffect.playDelayTime = 0;
|
boomEffect.PlayByArrIndex(quality > 4 ? 0 : 1);
|
}
|
DisplayNewMark(heroID);
|
DisplayHero(heroConfig);
|
tableEffect.Stop();
|
tableEffect.isPlaySpineLoop = true;
|
tableEffect.PlayByArrIndex(quality);
|
return;
|
}
|
|
|
starEffect.PlayByArrIndex(index);
|
//紫色开始有播放
|
if (quality <= 1)
|
{
|
lightEffect.Stop();
|
}
|
else
|
{
|
lightEffect.PlayByArrIndex(quality - 2);
|
}
|
boomEffect.playDelayTime = lightEffect.playDelayTime;
|
//红色特殊
|
boomEffect.PlayByArrIndex(quality > 4 ? 0 : 1);
|
|
//先播放灰色台子上升,再播放小人
|
tableEffect.onComplete = () =>
|
{
|
DisplayNewMark(heroID);
|
DisplayHero(heroConfig);
|
tableEffect.isPlaySpineLoop = true;
|
tableEffect.PlayByArrIndex(quality);
|
};
|
tableEffect.Stop();
|
tableEffect.isPlaySpineLoop = false;
|
tableEffect.PlayByArrIndex(0);
|
|
|
}
|
|
public void DisplayNewMark(int heroID)
|
{
|
newMarkImg.SetActive(HeroUIManager.Instance.IsNewHero(heroID));
|
}
|
|
public void DisplayHero(HeroConfig heroConfig)
|
{
|
heroModel.SetActive(true);
|
heroModel.Create(heroConfig.SkinIDList[0], 0.7f);
|
}
|
}
|