コード例 #1
0
    public GameObject SpawnBulletFromPool(bool TipoBala, Vector3 posicion, Quaternion rotacion)
    {
        GameObject ObjetoaSpawnear;
        string     bala;

        if (TipoBala)
        {
            bala            = "BalasMalas";
            ObjetoaSpawnear = poolDiccionario[bala].Dequeue();
        }
        else
        {
            bala            = "BalasBuenas";
            ObjetoaSpawnear = poolDiccionario[bala].Dequeue();
        }


        ObjetoaSpawnear.SetActive(true);
        ObjetoaSpawnear.transform.position = posicion;
        ObjetoaSpawnear.transform.rotation = rotacion;

        Bullet mibull = ObjetoaSpawnear.GetComponent <Bullet>();

        mibull.initializeBullet();

        poolDiccionario[bala].Enqueue(ObjetoaSpawnear);

        return(ObjetoaSpawnear);
    }
コード例 #2
0
    public GameObject SpawnParticle(bool enemiga, Vector3 posicion, Quaternion rotacion)
    {
        GameObject ObjetoaSpawnear;
        string     particula;

        if (enemiga)
        {
            particula       = "PartiBads";
            ObjetoaSpawnear = poolDiccionario[particula].Dequeue();
        }
        else
        {
            particula       = "PartiCools";
            ObjetoaSpawnear = poolDiccionario[particula].Dequeue();
        }


        ObjetoaSpawnear.SetActive(true);
        ObjetoaSpawnear.transform.position = posicion;
        ObjetoaSpawnear.transform.rotation = rotacion;

        ObjetoaSpawnear.GetComponent <ParticleSystem>().Play();

        poolDiccionario[particula].Enqueue(ObjetoaSpawnear);

        return(ObjetoaSpawnear);
    }
コード例 #3
0
    public GameObject SpawnFromPool(string tag, Vector3 posicion, Quaternion rotacion)
    {
        //Pa que no existan errores por pasar tag invalido
        if (!poolDiccionario.ContainsKey(tag))
        {
            Debug.LogWarning("El Pool con tag " + tag + " no existe");
            return(null);
        }
        //=========================================================\\

        //GameObject ObjetoaSpawnear = poolDiccionario[tag].Dequeue();
        int  _i             = 0;
        bool HayDesactivada = false;

        for (_i = 0; _i < poolDiccionario[tag].Count; _i++)
        {
            if (!poolDiccionario[tag][_i].activeSelf)
            {
                HayDesactivada = true;
                break;
            }
        }

        GameObject ObjetoaSpawnear;

        if (HayDesactivada)
        {
            ObjetoaSpawnear = poolDiccionario[tag][_i];
            //Activamos al chico
            ObjetoaSpawnear.SetActive(true);
            ObjetoaSpawnear.transform.position = posicion;
            ObjetoaSpawnear.transform.rotation = rotacion;
        }
        else
        {
            //Creamos a un nuevo chico
            ObjetoaSpawnear = Instantiate(poolDiccionario[tag][_i - 1]);
            ObjetoaSpawnear.SetActive(true);
            ObjetoaSpawnear.transform.position = posicion;
            ObjetoaSpawnear.transform.rotation = rotacion;
            poolDiccionario[tag].Add(ObjetoaSpawnear);
        }

        if (tag == "bulletparticles" || tag == "grenadeparticles")
        {
            StartCoroutine(DesactivarObjeto(ObjetoaSpawnear, 1));
        }
        return(ObjetoaSpawnear);
    }
コード例 #4
0
    public GameObject SpawnBoom(Vector3 posicion)
    {
        GameObject ObjetoaSpawnear;

        ObjetoaSpawnear = poolDiccionario["PartiBoom"].Dequeue();


        ObjetoaSpawnear.SetActive(true);
        ObjetoaSpawnear.transform.position = posicion;
        ObjetoaSpawnear.transform.rotation = Quaternion.identity;

        ParticleSystem[] booms = ObjetoaSpawnear.GetComponentsInChildren <ParticleSystem>();
        booms[0].Play(); booms[1].Play();

        poolDiccionario["PartiBoom"].Enqueue(ObjetoaSpawnear);

        return(ObjetoaSpawnear);
    }