备份CatanBuilding瘦身独立工程
This commit is contained in:
71
Assets/Scripts/SupplyDrop/SupplyDropModel.cs
Normal file
71
Assets/Scripts/SupplyDrop/SupplyDropModel.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user