Files
5.24BuYu/Assets/MyGame/aa/Game/FLZY/BOSS/QL/LeiLongEvent.cs
T
2026-08-03 17:00:34 +08:00

132 lines
3.4 KiB
C#

using DG.Tweening;
using Spine.Unity;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using Random = UnityEngine.Random;
public class LeiLongEvent : BJEventBase
{
public SkeletonGraphic skeletonGraphic;
public TextMeshProUGUI tMP_longzhu1;
public TextMeshProUGUI tMP_longzhu2;
public TextMeshProUGUI tMP_longzhu3;
public int longzhu1;
public int longzhu2;
public void Awake()
{
//skeletonGraphic.AnimationState.Complete += (trackEntry) =>
//{
// if (trackEntry.Animation.Name != "stand")
// {
// skeletonGraphic.AnimationState.SetAnimation(0, "stand1", false);
// }
//};
}
private void Start()
{
PlayThen("stand", "stand1");
transform.SetParent(null);
transform.position = Vector3.zero;
transform.position = Vector3.forward*-100;
}
/// <summary>
/// 播放完一个再接另一个(UI Spine)
/// </summary>
public void PlayThen(string first, string next)
{
var state = skeletonGraphic.AnimationState;
AudioManager.Instance.PlayerFX(62000+Random.Range(3,6));
state.SetAnimation(0, first, false);
state.AddAnimation(0, next, true, 0f);
}
public TextMeshProUGUI tmp_CoinNum;
public TMP_SpriteAsset tmp_goldSprite;
public TMP_SpriteAsset tmp_SilverSprite;
public override void Init(int goldCount,int posID,int paobei,int fishScore,int beishu,Action<int> action,Action action1=null)
{
JiaFen =()=>{
action?.Invoke(0);
} ;
maxScore = goldCount;
this.posID = posID;
paoBei = paobei;
// ⭐ 补回遗漏的 fishScore/beishu 赋值,
// 否则 OnScoreEnd 发送 baoJiangEnd 帧同步时 bJbeishu=0 导致 not-self 倍数显示错误
this.fishScore = fishScore;
bJbeishu = beishu;
action1?.Invoke();
}
public override void GoldEffect()
{
//开始加分
isAddScore = true;
AudioManager.Instance.PlayerFX(62001);
base.GoldEffect();
}
public override void EffEnd()
{
}
public void LongZhuMerge()
{
tMP_longzhu3.text = (longzhu1*longzhu2).ToString();
}
public void LongZhu2()
{
tMP_longzhu2.text = longzhu2.ToString();
}
public void LongZhu1()
{
tMP_longzhu1.text = longzhu1.ToString();
}
bool isAddScore=false;
float a = 3f;
float elapsed = 0f;
private void Update()
{
if (isAddScore) {
if (currScore < maxScore - paoBei)
{
elapsed += Time.deltaTime;
float t = elapsed / a;
currScore = (int)Mathf.Lerp(0, maxScore, t);
//currScore += Random.Range(paoBei, paoBei*2);
tMP_Score.text = currScore.ToString();
}
else
{
tMP_Score.text = maxScore.ToString();
isAddScore = false;
// 走基类统一收尾:加金币 → 删面板 → 销毁自身
OnScoreEnd();
}
}
}
public override void die()
{
StartCoroutine(i());
}
public IEnumerator i()
{
yield return new WaitForSeconds(1f);
transform.DOScale(Vector3.zero, 0.5f).OnComplete(() =>
{
Destroy(gameObject);
});
}
}