Files
2026-05-26 16:15:54 +08:00

72 lines
2.3 KiB
C#

using System.Collections;
using UnityEngine;
using UnityEngine.AddressableAssets;
public class SupplyDropModel : MonoBehaviour
{
public Animator animator;
public Transform Content;
GameObject fx_supplydrop_watersplash;
GameObject fx_supplydrop_wateridle;
GameObject fx_supplydrop_smoke;
GameObject fx_supplydrop_packageopen;
public void SetTrigger(string name)
{
animator.SetTrigger(name);
}
public void FxSmokeDelay(float supplyDropFxSmokeDelay, float supplyDropPackIdleDelay)
{
SmokeDelay(supplyDropFxSmokeDelay);
StartCoroutine(PackIdleDelay(supplyDropPackIdleDelay));
}
async void SmokeDelay(float supplyDropFxSmokeDelay)
{
fx_supplydrop_watersplash = await Addressables.InstantiateAsync("fx_supplydrop_watersplash", transform).Task;
fx_supplydrop_wateridle = await Addressables.InstantiateAsync("fx_supplydrop_wateridle", transform).Task;
await new WaitForSeconds(supplyDropFxSmokeDelay);
//冒烟
fx_supplydrop_smoke = await Addressables.InstantiateAsync("fx_supplydrop_smoke", transform).Task;
}
IEnumerator PackIdleDelay(float supplyDropPackIdleDelay)
{
yield return new WaitForSeconds(supplyDropPackIdleDelay);
SetTrigger("Idle");
}
public void SupplyDropOpen(float supplyDropOpenDelay)
{
SetTrigger("Open");
//关闭冒烟
if (fx_supplydrop_smoke != null)
{
Addressables.ReleaseInstance(fx_supplydrop_smoke);
}
DropOpenDelay(supplyDropOpenDelay);
}
async void DropOpenDelay(float supplyDropOpenDelay)
{
await new WaitForSeconds(supplyDropOpenDelay);
//开光特效
fx_supplydrop_packageopen = await Addressables.InstantiateAsync("fx_supplydrop_packageopen", transform).Task;
}
public void Hide()
{
//隐藏箱子
gameObject.SetActive(false);
if (fx_supplydrop_packageopen)
{
Addressables.ReleaseInstance(fx_supplydrop_packageopen);
}
if (fx_supplydrop_watersplash)
{
Addressables.ReleaseInstance(fx_supplydrop_watersplash);
}
if (fx_supplydrop_wateridle)
{
Addressables.ReleaseInstance(fx_supplydrop_wateridle);
}
}
}