void Update()
    {
        if (transform.position.x < groundPoint.position.x)
        {
            int   random   = Random.Range(0, groundPoolers.Length);
            float distance = groundWidths[random] / 2;
            float gap      = Random.Range(minGap, maxGap);
            float height   = Random.Range(minY, maxY);

            transform.position = new Vector3(
                transform.position.x + distance + gap,
                height,
                0);

            GameObject ground = groundPoolers[random].getPooledGameObject();

            ground.transform.position = new Vector3(
                transform.position.x,
                height,
                0);
            ground.SetActive(true);

            coinGenerator.spawnCoins(
                transform.position,
                groundWidths[random]);

            transform.position = new Vector3(
                transform.position.x + distance,
                transform.position.y,
                0);
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (transform.position.x < generationPoint.transform.position.x)
        {
            distanceBetween = Random.Range(distanceBetweenMin, distanceBetweenMax);

            platformSelector = Random.Range(0, theObjectPools.Length);

            heightChange = transform.position.y + Random.Range(maxHeightChange, -maxHeightChange);

            if (heightChange > maxHeight)
            {
                heightChange = maxHeight;
            }
            else if (heightChange < minHeight)
            {
                heightChange = minHeight;
            }

            //create powerup check
            if (Random.Range(0f, 100f) < powerupThreshold)
            {
                GameObject newPowerup = powerupPool.GetPooledObject();

                newPowerup.transform.position = transform.position + new Vector3(distanceBetween / 2f, Random.Range(1f, powerupHeight), 0f);
                newPowerup.SetActive(true);
            }

            transform.position = new Vector3(transform.position.x + (platformWidths[platformSelector] / 2) + distanceBetween, heightChange, transform.position.z);

            //Instantiate (/*thePlatform*/ thePlatforms[platformSelector], transform.position, transform.rotation);


            GameObject newPlatform = theObjectPools[platformSelector].GetPooledObject();

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

            if (Random.Range(0f, 100f) < randomCoinThreshold)
            {
                theCoinGenerator.spawnCoins(new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z));
            }

            if (Random.Range(0f, 100f) < randomSpikeThreshold)
            {
                GameObject newSpike = spikePool.GetPooledObject();

                float spikeXPosition = Random.Range(-platformWidths [platformSelector] / 2 + 1f, platformWidths [platformSelector] / 2 - 1f);

                Vector3 spikePosition = new Vector3(spikeXPosition, 0.5f, 0f);

                newSpike.transform.position = transform.position + spikePosition;
                newSpike.transform.rotation = transform.rotation;
                newSpike.SetActive(true);
            }

            transform.position = new Vector3(transform.position.x + (platformWidths[platformSelector] / 2), transform.position.y, transform.position.z);
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (transform.position.x < groundpt.position.x)
        {
            int   rand = Random.Range(0, grndpooler.Length);
            float dist = groundWidths[rand] / 2;

            float gap = Random.Range(minGap, maxGap);

            float ht = Random.Range(MinY, MaxY);
            transform.position = new Vector3(transform.position.x + dist + gap, ht, -transform.position.z);

            GameObject ground = grndpooler[rand].getPoolObj();
            ground.SetActive(true);
            ground.transform.position = transform.position;

            coingenerator.spawnCoins(transform.position, groundWidths[rand]);

            transform.position = new Vector3(transform.position.x + dist, transform.position.y, -transform.position.z);
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (transform.position.x < generationPoint.position.x)
        {
            //random num (min, max)
            distanceBetween = Random.Range(distanceBetweenMin, distanceBetweenMax);

            platformNum = Random.Range(0, objPool.Length);

            //height change
            heightChange = transform.position.y + Random.Range(maxHeightChange, -maxHeightChange);
            if (heightChange > maxHeight)
            {
                heightChange = maxHeight;
            }
            else if (heightChange < minHeight)
            {
                heightChange = minHeight;
            }

            transform.position = new Vector3(transform.position.x + (platformWidth[platformNum] / 2.0f) + distanceBetween, heightChange, transform.position.z);

            //creates an object at a point
            //Instantiate(platform[platformNum], transform.position, transform.rotation);

            GameObject obj = objPool[platformNum].getPooledObject();
            obj.transform.position = transform.position;
            obj.transform.rotation = transform.rotation;
            obj.SetActive(true);

            //spawn coins
            if ((int)Random.Range(0, coinChance) == 1)
            {
                coinGenerator.spawnCoins(new Vector3(transform.position.x, transform.position.y + 1f, transform.position.z));
            }

            transform.position = new Vector3(transform.position.x + (platformWidth[platformNum] / 2.0f), transform.position.y, transform.position.z);
        }
    }
Example #5
0
    // Update is called once per frame
    void Update()
    {
        if (transform.position.x < generationPoint.position.x)                  // this gameobject transform position compare to the generation gameobject position
        {
            //distanceBetween = Random.Range(distanceBetweenMin, distanceBetweenMax);
            if (ScoreManager.scoreCount < 1000)
            {
                PlatFormSelector = Random.Range(0, 3);

            }
            else if (ScoreManager.scoreCount > 1000 && ScoreManager.scoreCount < 4500)
            {
                PlatFormSelector = Random.Range(0, 4);
                ///theObjectPools.Length
            }
            else if (ScoreManager.scoreCount > 4500 && ScoreManager.scoreCount < 5000)
            {
                PlatFormSelector = Random.Range(0, 5);
            }
            else if (ScoreManager.scoreCount > 5000 && ScoreManager.scoreCount < 7000)
            {
                PlatFormSelector = Random.Range(0, 6);
            }
            else if (ScoreManager.scoreCount >= 7000)
            {
                PlatFormSelector = Random.Range(0, theObjectPools.Length);
            }

            //else
            //{
            //    Debug.Log("DIFFICULTY SPIKE");                                  // it works will implement later
            //    PlatFormSelector = Random.Range(0, theObjectPools.Length);
            //}
            //heightChange = transform.position.y + Random.Range(maxHeightChange, -maxHeightChange);
            //else if (ScoreManager.scoreCount > 300)
            //{
            //    PlatFormSelector = Random.Range(0, 4);

            //    Debug.Log("difficulty spiike");

            //    //difficultyPlat.transform.position = transform.position;
            //    //difficultyPlat.transform.position = transform.position;
            //    //difficultyPlat.SetActive(true);
            //}

            transform.position = new Vector3(transform.position.x + (PlatFormWidth[PlatFormSelector]) / 2 + distanceBetween, transform.position.y, transform.position.z);

            if (heightChange > maxHeight)
            {
                heightChange = maxHeight;
            }
            else if (heightChange < minHeight)
            {
                heightChange = minHeight;
            }                                                      // adding in width and the distance in between and not overlapping

            /// random platform of the amount in the platform arrays.
                                       // Instantiate(thePlatforms[PlatFormSelector], transform.position,transform.rotation);

            GameObject newPlatform = theObjectPools[PlatFormSelector].getPooledObject();                    // call the pooling script with the getPooled to set them to active from the transform.position 
            newPlatform.transform.position = transform.position;
            newPlatform.transform.rotation = transform.rotation;
            newPlatform.SetActive(true);

            //Debug.Log(ScoreManager.scoreCount);


            //GameObject difficultyPlat = theObjectPools[4].getPooledObject();
            //difficultyPlat.transform.position = new Vector3(transform.position.x + (PlatFormWidth[PlatFormSelector]) / 2 + distanceBetween, transform.position.y, transform.position.z);
            //difficultyPlat.transform.rotation = newPlatform.transform.rotation;
            //difficultyPlat.SetActive(false);

            //if (ScoreManager.scoreCount> 300)
            //{
            //    PlatFormSelector = Random.Range(0, 4);

            //    //difficultyPlat.transform.position = transform.position;
            //    //difficultyPlat.transform.position = transform.position;
            //    //difficultyPlat.SetActive(true);
            //}

            transform.position = new Vector3(transform.position.x + PlatFormWidth[PlatFormSelector] + distanceBetween, transform.position.y, transform.position.z);

            coingenerator.spawnCoins(new Vector3(transform.position.x + 10, transform.position.y + 1.8f, transform.position.z));


            if(ScoreManager.scoreCount > ForEvery)                        // spawn power ups for every 650 score rate
            {
                ForEvery += 800;
                coingenerator.spawnPowerUp(new Vector3(transform.position.x + 10, transform.position.y + 1.8f, transform.position.z));
            }
            if(ScoreManager.scoreCount > MagnetEvery)
            {
                //Debug.Log("MAGNET SPAWN");
                MagnetEvery += Random.Range(100,1500);
                coingenerator.spawnMagnetUp(new Vector3(transform.position.x + 10, transform.position.y + 2f, transform.position.z));
            }
            if (ScoreManager.scoreCount >WingEvery)
            {
                WingNewPosition = Random.Range(8f, 12f);
                    if (Random.value >= 0.1)         // 90% of getting the Wing for next above 500 score points
                {

                    WingEvery += 300;
                    coingenerator.spawnWingsUp(new Vector3(transform.position.x + WingNewPosition, transform.position.y - 1.5f, 2.16f));
                }
            }

            //if (ScoreManager.scoreCount > ForRewinery)
            //{

            //    ForRewinery += 200;
            //    coingenerator.spawnRewindUp(new Vector3(transform.position.x -5f, transform.position.y + 3f, 2.16f));
            //}

        }

    }