public Projectile GetProjectile(SpaceShipBase.Type type)
        {
            GameObject result = null;

            if (type == SpaceShipBase.Type.Player)
            {
                result = _playerProjectilePool.GetPooledObject();
            }
            else if (type == SpaceShipBase.Type.Enemy)
            {
                result = _enemyProjectilePool.GetPooledObject();
            }

            if (result != null)
            {
                Projectile projectile = result.GetComponent <Projectile>();

                if (projectile == null)
                {
                    Debug.LogError("Projectile component could not be found"
                                   + "from the object fetched from the pool");
                }

                return(projectile);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public Projectile GetProjectile(SpaceShipBase.Type type)
        {
            // The result object
            GameObject result = null;

            // Tries to get a projectile from the correct pool
            if (type == SpaceShipBase.Type.Player)
            {
                result = playerProjectilePool.GetPoolObject();
            }
            else
            {
                result = enemyProjectilePool.GetPoolObject();
            }

            // If the result is not null, its Projectile component is returned
            if (result != null)
            {
                Projectile projectile = result.GetComponent <Projectile>();

                // If there's no Projectile component, prints an error message
                if (projectile == null)
                {
                    Debug.LogError("Projectile component could not be found" +
                                   " from the object fetched from the pool");
                }

                return(projectile);
            }

            // Returns null if there's no result
            return(null);
        }
Beispiel #3
0
        public Projectile GetProjectile(SpaceShipBase.Type type)
        {
            GameObject result = null;

            // Try to get pooled object from the correct pool based on the type
            // of the spaceship.
            if (type == SpaceShipBase.Type.Player)
            {
                result = _playerProjectilePool.GetPooledObject();
            }
            else
            {
                result = _enemyProjectilePool.GetPooledObject();
            }

            // If the pooled object was found, get the Projectile component
            // from it and return that. Otherwise just return null.
            if (result != null)
            {
                Projectile projectile = result.GetComponent <Projectile>();
                if (projectile == null)
                {
                    Debug.LogError("Projectile component could not be found " +
                                   "from the object fetched from the pool.");
                }
                return(projectile);
            }
            return(null);
        }
Beispiel #4
0
 public bool ReturnProjectile(SpaceShipBase.Type type, Projectile projectile)
 {
     if (type == SpaceShipBase.Type.Player)
     {
         return(playerProjectilePool.ReturnObject(projectile.gameObject));
     }
     else
     {
         return(enemyProjectilePool.ReturnObject(projectile.gameObject));
     }
 }
        public bool ReturnProjectile(SpaceShipBase.Type type, Projectile projectile)
        {
            if (type == SpaceShipBase.Type.Player)
            {
                return(_playerProjectilePool.ReturnToPool(projectile.gameObject));
            }
            else if (type == SpaceShipBase.Type.Enemy)
            {
                return(_enemyProjectilePool.ReturnToPool(projectile.gameObject));
            }

            return(false);
        }
        public Projectile GetProjectile(SpaceShipBase.Type type)
        {
            GameObject result = null;

            if (type == SpaceShipBase.Type.Player)
            {
                result = _PlayerProjectilePool.GetPoolObject();
            }
            else
            {
                result = _HostileProjectilePool.GetPoolObject();
            }
            if (result != null)
            {
                return(result.GetComponent <Projectile>());
            }

            return(null);
        }