// spawn the platforms, obstacles, power ups, and coins
    private PlatformObject spawnObjects(ObjectLocation location, Vector3 position, Vector3 direction, bool activateImmediately)
    {
        setupSection(location, false);
        int localIndex = infiniteObjectManager.getNextObjectIndex(ObjectType.Platform, spawnData);

        if (localIndex == -1)
        {
            print("Unable to spawn platform. No platforms can be spawned based on the probability rules");
            return(null);
        }
        PlatformObject platform = spawnPlatform(localIndex, location, position, direction, activateImmediately);

        if (platform.canSpawnCollidable() && Random.value >= noCollidableProbability.getValue(infiniteObjectHistory.getTotalDistance(false)))
        {
            // First try to spawn an obstacle. If there is any space remaining on the platform, then try to spawn a coin.
            // If there is still some space remaing, try to spawn a powerup.
            // An extension of this would be to randomize the order of ObjectType, but this way works if the probabilities
            // are setup fairly
            spawnCollidable(ObjectType.Obstacle, position, direction, location, platform, localIndex, activateImmediately);
            if (platform.canSpawnCollidable())
            {
                spawnCollidable(ObjectType.Coin, position, direction, location, platform, localIndex, activateImmediately);
                if (platform.canSpawnCollidable())
                {
                    spawnCollidable(ObjectType.PowerUp, position, direction, location, platform, localIndex, activateImmediately);
                }
            }
        }

        return(platform);
    }
Beispiel #2
0
    // There character doesn't move, all of the objects around it do. Make sure the character is in the correct position and
    // move all of those objects.
    public void Update()
    {
        // height is independent from the target position
        //Zorb stays hereas well simila to the character but it happens only when the size of the zorb is small

//		targetPosition.y = thisTransform.position.y;
//		if (thisTransform.position != targetPosition) {
//			thisTransform.position = Vector3.MoveTowards(thisTransform.position, targetPosition, horizontalSpeed * Time.deltaTime);
//		}

        if (thisTransform.rotation != targetRotation)
        {
            thisTransform.rotation = Quaternion.RotateTowards(thisTransform.rotation, targetRotation, rotationSpeed);
        }

        float forwardSpeed = forwardSpeeds.getValue(totalMoveDistance) * Time.deltaTime;

        totalMoveDistance += forwardSpeed;
        infiniteObjectGenerator.moveObjects(forwardSpeed);

        if (Input.GetButton("EnableGodMode"))
        {
            gameManager.godMode = true;
        }
    }
    // returns the section based off of the distance.
    public int getSection(float distance, bool isSceneObject)
    {
        if (sectionSelectionType == SectionSelectionType.None)
        {
            return(0);
        }

        int activeSection = (isSceneObject ? activeSceneSection : activePlatformSection);

        if (sectionSelectionType == SectionSelectionType.ProbabilityLoop || sectionSelectionType == SectionSelectionType.ProbabilityRandom)
        {
            if (Random.value < sectionList.getValue(distance))
            {
                if (sectionSelectionType == SectionSelectionType.ProbabilityRandom)
                {
                    activeSection = Random.Range(startSection, endSection);
                }
                else
                {
                    if (startSection > endSection)
                    {
                        activeSection = (activeSection + 1) % (startSection - endSection + 1); // inclusive
                    }
                    else
                    {
                        activeSection = startSection;
                    }
                }
            }
        }
        else     // linear
        {
            activeSection = (int)sectionList.getValue(distance);
        }

        if (isSceneObject)
        {
            activeSceneSection = activeSection;
        }
        else
        {
            activePlatformSection = activeSection;
        }

        return(activeSection);
    }
Beispiel #4
0
    // Returns the probability that this object should appear based off of the current distance
    public float getProbability(float distance)
    {
        // Chance of no probability of no occur says so
        if (noOccurProbabilities.count() > 0)
        {
            float prob = noOccurProbabilities.getValue(distance);
            if (Random.value < prob)
            {
                return(0);
            }
        }

        return(occurProbabilities.getValue(distance));
    }