52 lines
No EOL
1.3 KiB
C#
52 lines
No EOL
1.3 KiB
C#
using Patterns_And_Principles.Patterns.Object_Pool_Pattern.BasicPool.Script.Interface;
|
||
using UnityEngine;
|
||
|
||
namespace Patterns_And_Principles.Patterns.Object_Pool_Pattern.BasicPool.Script
|
||
{
|
||
public class SimpleBullet : MonoBehaviour, IPoolable
|
||
{
|
||
private float _speed = 10f;
|
||
|
||
public void OnSpawn()
|
||
{
|
||
/*
|
||
* OnSpawn'da Neler Yapılır?
|
||
|
||
Genelde:
|
||
|
||
velocity verilir
|
||
|
||
timer resetlenir
|
||
|
||
particle resetlenir
|
||
|
||
trail temizlenir
|
||
|
||
state resetlenir
|
||
*/
|
||
}
|
||
|
||
public void OnDespawn()
|
||
{
|
||
/*
|
||
* OnDespawn'da Neler Yapılır?
|
||
|
||
Genelde:
|
||
|
||
velocity sıfırlanır
|
||
|
||
particle durdurulur
|
||
|
||
state temizlenir
|
||
*/
|
||
}
|
||
void Update()
|
||
{
|
||
transform.Translate(Vector3.right * _speed * Time.deltaTime);
|
||
}
|
||
void OnCollisionEnter(Collision collision)
|
||
{
|
||
FindObjectOfType<BulletPoolExample>().ReturnBullet(this);
|
||
}
|
||
}
|
||
} |