Beispiel #1
0
    public bool TryLaunch(Transform launchParam)
    {
        if (_elapsedSinceLastShot > cooldownSeconds)
        {
            if (usePool && _pool != null)
            {
                var projectileFromPool = _pool.Spawn <Projectile>(projectile, CachedTransform.position, CachedTransform.rotation, null);

                if (projectileFromPool == null)
                {
                    Debug.Break();
                }

                projectileFromPool.Setup(launchParam);
            }
            else
            {
                var newProjectile = Instantiate <Projectile>(projectile, CachedTransform.position, CachedTransform.rotation, null);
                newProjectile.Setup(launchParam);
            }

            _elapsedSinceLastShot = 0f;
            return(true);
        }

        return(false);
    }