Initial Commit
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
using UnityEngine;
|
||||
|
||||
#pragma warning disable 649
|
||||
|
||||
namespace Zenject.SpaceFighter
|
||||
{
|
||||
public class Explosion : MonoBehaviour, IPoolable<IMemoryPool>
|
||||
{
|
||||
[SerializeField]
|
||||
float _lifeTime;
|
||||
|
||||
[SerializeField]
|
||||
ParticleSystem _particleSystem;
|
||||
|
||||
float _startTime;
|
||||
|
||||
IMemoryPool _pool;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Time.realtimeSinceStartup - _startTime > _lifeTime)
|
||||
{
|
||||
_pool.Despawn(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDespawned()
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSpawned(IMemoryPool pool)
|
||||
{
|
||||
_particleSystem.Clear();
|
||||
_particleSystem.Play();
|
||||
|
||||
_startTime = Time.realtimeSinceStartup;
|
||||
_pool = pool;
|
||||
}
|
||||
|
||||
public class Factory : PlaceholderFactory<Explosion>
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user