Files
5.24BuYu/Assets/MyGame/aa/Game/FLZY/BOSS/RYGZ/RYGZDieEvent.cs
T
2026-08-22 17:23:07 +08:00

89 lines
2.5 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
public class RYGZDieEvent : BJRedPacketEvent
{
public PlayableDirector playable;
public List<GameObject> bJ_BeiShu;
public override void Init(long goldCount, int posID, long paobei, long fishScore, int beishu, Action<int> action, Action action1 = null)
{
base.Init(goldCount, posID, paobei, fishScore, beishu, action, action1);
bJ_BeiShu[Convert.ToInt32(obj)].SetActive(true);
}
public void PlayEnd(PlayableDirector playableDirector)
{
if (isScoreEnd) return;
OnScoreEnd();
}
bool isFirst = true;
public void SetScore()
{
int target = isFirst ? paoBei * fishScore / 2 : paoBei * fishScore;
isFirst = false;
layeredPool = new LayeredPool(paoBei * fishScore / 2, 1);
BigPrize(10, 15);
StartCoroutine(ScrollTo(target, () => { }));
}
/// <summary>最终阶段:滚动到 maxScore 并结束</summary>
public void chengfen()
{
StartCoroutine(ScrollTo(maxScore, () => StartAddScore()));
}
/// <summary>从 currScore 滚动到 target,同时爆破金币效果,完成回调 onComplete</summary>
private IEnumerator ScrollTo(int target, Action onComplete)
{
int from = currScore;
float duration = 0.5f;
float elapsed = 0f;
float coinInterval = 0.12f;
float nextCoinTime = 0f;
if (target == currScore)
{
yield return new WaitForSeconds(2f);
}
else {
while (elapsed < duration)
{
elapsed += Time.deltaTime;
float t = elapsed / duration;
currScore = (int)Mathf.Lerp(from, target, t);
if (tMP_Score != null)
tMP_Score.text = currScore.ToString();
// 每隔 coinInterval 爆一波金币
if (elapsed >= nextCoinTime)
{
nextCoinTime += coinInterval;
}
yield return null;
}
}
currScore = target;
if (tMP_Score != null)
tMP_Score.text = target.ToString();
//// 最后补一波金币
//layeredPool = new LayeredPool(paoBei * fishScore / 2, 1);
//BigPrize(5, 10);
//yield return new WaitForSeconds(0.3f); // 等最后一批金币飞到
onComplete?.Invoke();
}
}