Ejemplo n.º 1
0
    public static Bullet Spawn(Vector3 position, Vector2 direction, float timer, float speed)
    {
        tmpBullet = null;
        for (int i = 0; i < pool.Count; i++)
        {
            if (!pool[i].isActiveAndEnabled)
            {
                tmpBullet = pool[i];
                tmpBullet.gameObject.SetActive(true);
                break;
            }
        }

        if (tmpBullet == null)
        {
            tmpBullet = Instantiate(PrefabManager.Current.BulletPrefab);
            pool.Add(tmpBullet);
        }

        tmpBullet.transform.position = position;
        tmpBullet.Timer = timer;
        WrappingWorld.Register(tmpBullet);
        tmpBullet._rb.velocity = direction * speed;
        tmpBullet.hit          = false;
        return(tmpBullet);
    }
Ejemplo n.º 2
0
    public static FuelTree Spawn(string id, Vector3 position, int fuels)
    {
        tmpTree = null;
        for (int i = 0; i < pool.Count; i++)
        {
            if (!pool[i].isActiveAndEnabled)
            {
                tmpTree = pool[i];
                tmpTree.gameObject.SetActive(true);
                break;
            }
        }

        if (tmpTree == null)
        {
            tmpTree = Instantiate(PrefabManager.Current.FuelTreePrefab);
            pool.Add(tmpTree);
        }

        tmpTree.transform.position     = position;
        tmpTree.LoadedObjectDefinition = id;
        tmpTree.Fuels = fuels;
        WrappingWorld.Register(tmpTree);
        return(tmpTree);
    }