예제 #1
0
        public new void SystemUpdate()
        {
            var poolManager      = PoolManager.Instance();
            var cooldownAccessor = TAccessor <CooldownModule> .Instance();

            foreach (var module in cooldownAccessor.GetAllModules())
            {
                var entity = module.gameObject;

                if (module != null)
                {
                    if (module.ResetCooldown <= 0)
                    {
                        Debug.Log("Pan !");
                        module.ResetCooldown = module.Cooldown;
                        PoolableObject bullet = poolManager.GetPooledObject(objectType.bullet);

                        // Initialize and set active all instancied bullet in the bullet pool
                        if (bullet != null)
                        {
                            bullet.Init(entity.transform.position);
                            _objects.Add(bullet);
                        }
                    }
                    else
                    {
                        module.ResetCooldown -= Time.deltaTime;
                    }
                }
            }
        }
        public void SystemUpdate()
        {
            var poolManager        = PoolManager.Instance();
            var playerShotAccessor = TAccessor <PlayerShotModule> .Instance();

            foreach (var module in playerShotAccessor.GetAllModules())
            {
                var entity     = module.gameObject;
                var currentMod = playerShotAccessor.TryGetModule(entity);

                if (currentMod != null)
                {
                    if (Input.GetKeyDown(currentMod.Key))
                    {
                        PoolableObject bullet = poolManager.GetPooledObject(objectType.bullet);

                        // Initialize and set active all instancied bullet in the bullet pool
                        if (bullet != null)
                        {
                            bullet.Init(entity.transform.position);
                            _objects.Add(bullet);
                        }
                    }
                }
            }
        }
예제 #3
0
    private GameObject AddObjectToPool()
    {
        PoolableObject newObject = Instantiate(prefab, transform);

        pooledObjects.Push(newObject.gameObject);

        newObject.gameObject.SetActive(false);

        newObject.Init(this);

        return(newObject.gameObject);
    }
        public void SystemUpdate()
        {
            var poolManager   = PoolManager.Instance();
            var spawnAccessor = TAccessor <SpawnModule> .Instance();

            foreach (var module in spawnAccessor.GetAllModules())
            {
                if (_timeRemaining > 0)
                {
                    _timeRemaining -= Time.deltaTime;
                }
                else
                {
                    _timeRemaining = 20;
                    PoolableObject ennemy = poolManager.GetPooledObject(objectType.ennemy);

                    if (ennemy != null)
                    {
                        ennemy.Init(new Vector3(Random.Range(-5.0f, 5.0f), 0, Random.Range(-5.0f, 5.0f)));
                        _objects.Add(ennemy);
                    }
                }
            }
        }