private void Awake() { Instance = this; for (int i = 0; i < startSpawn; i++) { Get(); } }
protected virtual IHealth Spawn(Vector3 pos) { var obj = GenericObjectPooler.RequestObject(objectToSpawn, false); obj.transform.localScale = targetScale; obj.transform.position = pos; obj.gameObject.SetActive(true); IHealth health = obj.gameObject.GetComponent <IHealth>(); health.FillToMaxHealth(); Debug.DrawLine(pos, pos + Vector3.up * 10, Color.red, 1f); return(health); }
public override void CreateTrail(ShootInfo shootInfo) { Vector3 start = weaponFirepos.GetWeaponFirePos(); Vector3 end = shootInfo.end; start = NagaUtils.GetPointAlongDirection(start, end - start, Random.value * startposRandomness); TrailRenderer trail = GenericObjectPooler.RequestObject(trailRenderer).gameObject.GetComponent <TrailRenderer>(); trail.gameObject.transform.position = start; trail.gameObject.SetActive(true); trail.Clear(); Timing.RunCoroutine(_TweenTrail(trail, end)); }
public void CreatePool(int amountToPool) { GenericObjectPooler.CreatePool(objectToSpawn, amountToPool); }
void Awake() { current = this; }
void Awake() //So we may not even want to use a singleton here? Singleton means only one pooler. //But one of the reasons to use this script is to let a bunch of enemies all use it for one bullet type, and then another instance of this class for another object type { instance = this; }
public override void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode) { base.OnLevelFinishedLoading(scene, mode); objPool = new GenericObjectPooler <Projectile>(prefab, size); }
private void Start() { objPool = new GenericObjectPooler <Projectile>(prefab, size); }
//Since this can be reused very easily and just generally be used for any kind of trail, might refactor this //into a parent/base class private void Start() { GenericObjectPooler.CreatePool(trailRenderer, trailsToPool); }