92 lines
2.7 KiB
C#
92 lines
2.7 KiB
C#
using Assets.MyGame.Scripts.Net.APIResponses.Enum;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DieEffect_TSY : BJBase
|
|
{
|
|
public int radius;
|
|
public int count;
|
|
public int paoBei;
|
|
public float time = 0.5f;
|
|
|
|
[Header("爆奖特效")]
|
|
public GameObject baoJiangEffectPrefab; // 爆奖特效预制体(转盘特效)
|
|
public Transform parentTransform; // 父对象(在Inspector中指定)
|
|
public Vector3 offsetPosition = new Vector3(0, 2, 0); // 世界坐标偏移量
|
|
|
|
[Header("爆奖类型")]
|
|
public TSBJ effectType = TSBJ.转盘; // 死亡动画的爆奖类型,默认转盘
|
|
|
|
private void Start()
|
|
{
|
|
paoBei = (int)CreateFishManager.Instance.currGameType.currSitData.consumeGoldNum;
|
|
}
|
|
|
|
public override void SetCoinCount()
|
|
{
|
|
StartCoroutine(enumerator());
|
|
}
|
|
|
|
public virtual IEnumerator enumerator()
|
|
{
|
|
yield return new WaitForSeconds(time);
|
|
|
|
// 在销毁前创建爆奖特效
|
|
CreateBaoJiangEffect();
|
|
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
|
|
|
|
private void CreateBaoJiangEffect()
|
|
{
|
|
if (baoJiangEffectPrefab == null)
|
|
{
|
|
Debug.LogWarning("爆奖特效预制体未设置!");
|
|
return;
|
|
}
|
|
|
|
// 确定父对象
|
|
Transform parent = parentTransform != null ? parentTransform : UIManager.Instance.uiRoot;
|
|
|
|
// 获取源对象的世界坐标
|
|
Vector3 sourcePosition = CreateFishManager.Instance.currGameType.currSitData.transform.position;
|
|
|
|
// 计算生成位置(世界坐标 + 偏移量)
|
|
Vector3 spawnPosition = sourcePosition + offsetPosition;
|
|
|
|
// 实例化爆奖特效,设置父对象
|
|
GameObject effectObj = Instantiate(baoJiangEffectPrefab, parent);
|
|
|
|
// 设置位置(世界坐标)
|
|
effectObj.transform.position = spawnPosition;
|
|
|
|
// 重置缩放(避免父对象缩放影响)
|
|
effectObj.transform.localScale = Vector3.one;
|
|
|
|
// 获取BaoJiangTSSmallFish组件
|
|
BaoJiangTSSmallFish baoJiang = effectObj.GetComponent<BaoJiangTSSmallFish>();
|
|
baoJiang.JiaFen = JiaFen;
|
|
|
|
if (baoJiang != null)
|
|
{
|
|
// 计算总奖金
|
|
long totalReward = coinCount; // 可以根据需要修改
|
|
|
|
// 根据枚举类型调用不同的方法
|
|
if (effectType == TSBJ.转盘)
|
|
{
|
|
// 调用转盘特效(不带图片)
|
|
baoJiang.ZP(totalReward, true, null, true);
|
|
}
|
|
else
|
|
{
|
|
// 调用爆奖特效
|
|
baoJiang.BJ(totalReward, effectType, true, true);
|
|
}
|
|
}
|
|
}
|
|
}
|