Пример #1
0
    private void Awake()
    {
        Instance = this;

        for (int i = 0; i < startSpawn; i++)
        {
            Get();
        }
    }
Пример #2
0
    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);
    }
Пример #3
0
    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));
    }
Пример #4
0
 public void CreatePool(int amountToPool)
 {
     GenericObjectPooler.CreatePool(objectToSpawn, amountToPool);
 }
Пример #5
0
 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;
 }
Пример #7
0
 public override void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode)
 {
     base.OnLevelFinishedLoading(scene, mode);
     objPool = new GenericObjectPooler <Projectile>(prefab, size);
 }
Пример #8
0
 private void Start()
 {
     objPool = new GenericObjectPooler <Projectile>(prefab, size);
 }
Пример #9
0
 //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);
 }