Example #1
0
    // Start is called before the first frame update
    new void Start()
    {
        base.Start();
        missilePool = new GameObject("MissilePool")
                      .AddComponent <ObjectPool>()
                      .setDynamic(false)
                      .setStartingSize(25)
                      .setPrefab(projectile);

        queue = ScriptableObject.CreateInstance <FireCommandQueue>();


        cooledDown = gameObject.AddComponent <CooledDown>()
                     .SetAction(() => {
            FireCommand command = queue.Dequeue();
            Shoot(command.direction);
            shouldCooldownInvoke();
        })
                     .SetCooldown(cooldown);
    }
Example #2
0
    // Start is called before the first frame update
    public void Start()
    {
        if (isPooled)
        {
            spawnablePool = new GameObject("ObjectPool")
                            .AddComponent <ObjectPool>()
                            .setDynamic(isPoolDynamic)
                            .setStartingSize(poolStartingSize)
                            .setPrefab(spawnable);
        }

        if (cooldown > 0)
        {
            cooledDown = gameObject.AddComponent <CooledDown>()
                         .SetAction(Generate)
                         .SetCooldown(cooldown);

            cooledDown.shouldInvoke = shouldSpawn;
        }
        else
        {
            Debug.Log("No cooldown set. This results in instantiations on every update.");
        }
    }