Ejemplo n.º 1
0
        private void Spawn()
        {
            var poolableGamObj = PoolSystem.FetchAvailable <CubePoolable>("Cube", out CubePoolable poolable);

            if (poolable != null)
            {
                var pos = poolableGamObj.transform.position;
                pos.x += Random.Range(-spawnRange.x, spawnRange.x);
                pos.y += Random.Range(-spawnRange.y, spawnRange.y);
                pos.z += Random.Range(-spawnRange.z, spawnRange.z);
                poolableGamObj.transform.position = pos;
                poolable.Aquire();
            }
        }
Ejemplo n.º 2
0
        private void Shoot()
        {
            if (PoolSystem.FetchAvailable("Bullet", out Bullet bullet))
            {
                bullet.transform.position = emissionSpot.position;
                bullet.Fire(emissionSpot.forward * shootForce, range);

                _lastTimeShot = Time.time;
                _bulletsInClip--;
                _state = WeaponState.Shooting;
            }
            else
            {
                Debug.Log("no more bullets available in pool");
            }
        }