Пример #1
0
    public void Spawncoins(Vector3 startposition)
    {
        GameObject coin1 = coinpool.Getobjectpooled();

        coin1.transform.position = startposition;
        coin1.SetActive(true);

        GameObject coin2 = coinpool.Getobjectpooled();

        coin2.transform.position = new Vector3(startposition.x - distbetweenc, startposition.y, startposition.z);
        coin2.SetActive(true);


        GameObject coin3 = coinpool.Getobjectpooled();

        coin3.transform.position = new Vector3(startposition.x + distbetweenc, startposition.y, startposition.z);
        coin3.SetActive(true);
    }
Пример #2
0
    public void Spawncoins(Vector3 startposition)  // legenerálja az érméket
    {
        GameObject coin1 = coinpool.Getobjectpooled();

        coin1.transform.position = startposition;
        coin1.SetActive(true);

        GameObject coin2 = coinpool.Getobjectpooled();

        coin2.transform.position = new Vector3(startposition.x - distbetweenc, startposition.y, startposition.z); //  ball  kerül
        coin2.SetActive(true);


        GameObject coin3 = coinpool.Getobjectpooled();

        coin3.transform.position = new Vector3(startposition.x + distbetweenc, startposition.y, startposition.z); // jobbra kerül
        coin3.SetActive(true);
    }
Пример #3
0
    void Update()
    {
        if (transform.position.x < platgenpoint.position.x)
        {
            platdist = Random.Range(platdistmin, platdistmax);

            platselector = Random.Range(0, platformObjecPools.Length);

            heightchange = transform.position.y + Random.Range(maxheigtchange, -maxheigtchange);

            if (heightchange > maxheight)
            {
                heightchange = maxheight - Random.Range(0f, maxheigtchange);
            }
            else if (heightchange < minheight)
            {
                heightchange = minheight + Random.Range(0f, maxheigtchange);
            }



            transform.position = new Vector3(transform.position.x + (platwidths[platselector] / 2) + platdist, transform.position.y, transform.position.z);
            GameObject newplatform = platformObjecPools[platselector].Getobjectpooled();

            newplatform.transform.position = transform.position;
            newplatform.transform.rotation = transform.rotation;
            newplatform.SetActive(true);

            if (Random.Range(0f, 100f) < cointhreshold)
            {
                thecoingen.Spawncoins(new Vector3(transform.position.x, transform.position.y + 1.5f, transform.position.z));
            }


            if (Random.Range(0f, 100f) < spikethreshold)
            {
                GameObject newspike = spikepool.Getobjectpooled();


                float spikeXposition = Random.Range(-platwidths[platselector] / 2f + 1f, platwidths[platselector] / 2f - 1f);

                Vector3 spikeposition = new Vector3(spikeXposition, 0.5f, 0f);

                newspike.transform.position = transform.position + spikeposition;
                newspike.transform.rotation = transform.rotation;
                newspike.SetActive(true);
            }


            if (Random.Range(0f, 100f) < powerupthreshold)
            {
                GameObject newpowerup = poweruppool.Getobjectpooled();

                newpowerup.transform.position = transform.position + new Vector3(platdist / 2f, Random.Range(1f, poweruphight), 0f);

                newpowerup.SetActive(true);
            }

            if (Random.Range(0f, 100f) < enemythreshold)
            {
                GameObject newenemy = enemypool.Getobjectpooled();

                newenemy.transform.position = transform.position + new Vector3(platdist / 2f, Random.Range(1f, enemyhight), 0f);

                newenemy.SetActive(true);
            }



            transform.position = new Vector3(transform.position.x + (platwidths[platselector] / 2), heightchange, transform.position.z);
        }
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        // emlkeztető, véletlen r, 10-20 féle platform egybe az ellenséggel, fix távlságok, r case, azon belül lesznek az if-ek, ,y is változik

        if (transform.position.x < platgenpoint.position.x)                                      // ha a generátor pot előrébb van mint a camerapont
        {
            platdist = Random.Range(platdistmin, platdistmax);                                   //random a pont kettő közt

            platselector = Random.Range(0, platformObjecPools.Length);                           // a szám maximum a lista nagysága leget

            heightchange = transform.position.y + Random.Range(maxheigtchange, -maxheigtchange); //meghatározza a platform helyét

            if (heightchange > maxheight)                                                        // a kamerán belülre kényszBizeríti a platformot, ha kiesne belőle
            {
                heightchange = maxheight - Random.Range(0f, maxheigtchange);
            }
            else if (heightchange < minheight)
            {
                heightchange = minheight + Random.Range(0f, maxheigtchange);
            }



            // transform.position = new Vector3(transform.position.x + (platwidths[platselector] /2 )+ platdist, transform.position.y, transform.position.z); //  mozduljon arréb a pont
            transform.position = new Vector3(transform.position.x + (platwidths[platselector]) + platdist, heightchange, transform.position.z);    //  mozduljon arréb a pont

            //  Instantiate(platform, transform.position, transform.rotation);  // új platformot hozzunk létre, megismétli az előzt

            GameObject newplatform = platformObjecPools[platselector].Getobjectpooled();

            newplatform.transform.position = transform.position;
            newplatform.transform.rotation = transform.rotation;
            newplatform.SetActive(true);

            if (Random.Range(0f, 100f) < cointhreshold)                                                                      // randomizálja hogy melyik platformon less érma
            {
                thecoingen.Spawncoins(new Vector3(transform.position.x, transform.position.y + 1.5f, transform.position.z)); // egy egységgel a platform fölé rakja az érméket
            }


            if (Random.Range(0f, 100f) < spikethreshold)           // randomizálja hogy melyik platformon less tüske
            {
                GameObject newspike = spikepool.Getobjectpooled(); // a megeadott elemet sokszorosítja


                float spikeXposition = Random.Range(-platwidths[platselector] / 2f + 1f, platwidths[platselector] / 2f - 1f); //véletlenszerő értéket számol az adott platform két vége között

                Vector3 spikeposition = new Vector3(spikeXposition, 0.5f, 0f);                                                //a tüske a platformhoz képest hol legyen, ha 0.5-tel megesebb pont a felszínen van

                newspike.transform.position = transform.position + spikeposition;
                newspike.transform.rotation = transform.rotation;
                newspike.SetActive(true);
            }


            if (Random.Range(0f, 100f) < powerupthreshold)  //eldöntjük hogy legyen e itt power upp
            {
                GameObject newpowerup = poweruppool.Getobjectpooled();

                newpowerup.transform.position = transform.position + new Vector3(platdist / 2f, Random.Range(1f, poweruphight), 0f); // két platform közé keről

                newpowerup.SetActive(true);
            }

            if (Random.Range(0f, 100f) < enemythreshold)
            {
                GameObject newenemy = enemypool.Getobjectpooled();

                newenemy.transform.position = transform.position + new Vector3(platdist / 2f, Random.Range(1f, enemyhight), 0f); // két platform közé keről

                newenemy.SetActive(true);
            }



            //transform.position = new Vector3(transform.position.x + (platwidths[platselector] / 2), heightchange, transform.position.z); //  mozduljon arréb a pont
        }
    }