// Update is called once per frame
    void Update()
    {
        if (_isProcess) // Condition for 3D text generation processing
        {
            // Setting the parent of the 3D text
            _Text3Ds[_text3DPointer].transform.SetParent(_stageCurrent.Text3DHolder);

            // Re-positioning the 3D text to 0
            _Text3Ds[_text3DPointer].transform.localPosition = Vector3.zero;

            // Re-rotating the 3D text to 0 degrees
            _Text3Ds[_text3DPointer].transform.localRotation = Quaternion.identity;

            // Setting up the stage number of the stage
            _Text3Ds[_text3DPointer].SetText("" + _stageCurrent.StageNumber);

            //TODO: Give special effect when 3D texts are shown

            // Getting the next stage
            _stageCurrent = _stageCurrent.LinkedStage;

            // Condition to check if the next platform is the
            // end platform then stoping the 3D text generation
            if (_stageCurrent.LinkedStage == null)
            {
                _text3DPointer = _size; // Stopping future process
                return;                 // Exiting process
            }

            _text3DPointer++; // Going to next process
        }
    }
    /// <summary>
    /// This method sets up the initial setup for the enemy generation.
    /// </summary>
    /// <param name="numberOfEnemies">The number of enemies to generate,
    ///                               of type int</param>
    /// <param name="stage">The stage from which to start to put enemies
    ///                     on, of type BouncyStage</param>
    public void SetupGeneration(int numberOfEnemies, BouncyStage stage)
    {
        // Correcting the number of enemies generation
        // if any errors found
        _numberOfEnemies = numberOfEnemies >= EnemyMax ?
                           EnemyMax :
                           numberOfEnemies;

        _currentStage = stage;              // Setting the current stage

        _processCounter = 0;                // Resetting the process counter

        _status = ProcessStatus.Generating; // Starting to add
                                            // enemies
    }
    /// <summary>
    /// This method adds an enemy to the game world.
    /// </summary>
    /// <param name="index">The index of the enemy to add,
    ///                     of type int</param>
    private void AddEnemy(int index)
    {
        // Showing the enemy
        EnemiesAvailable[index]
        .transform.gameObject.SetActive(true);

        // Getting enemy model
        EnemiesAvailable[index].GetCharacterModel();

        // Setting the enemy's position
        EnemiesAvailable[index]
        .SetStartPosition(_currentStage.StagePosition);

        // Setting the enemy's rotation
        EnemiesAvailable[index]
        .SetStartRotation(_currentStage.LinkedStagePosition);

        // Setting the stage number of the enemy
        EnemiesAvailable[index]
        .SetStageNumber(_currentStage.StageNumber);

        // Making the enemy into a racer
        EnemiesAvailable[index].MakeRacer();

        // Adding the enemy in the used list
        _enemiesUsed.Add(EnemiesAvailable[index]);

        // Removing the enemy from the available list
        EnemiesAvailable.RemoveAt(index);

        // Getting the next linked stage
        _currentStage = _currentStage.LinkedStage;

        // Incrementing the generated counter
        _processCounter++;

        // Condition for finishing adding all the enemies
        if (_processCounter >= _numberOfEnemies)
        {
            _status = ProcessStatus.None; // Process Done
        }
    }
 /// <summary>
 /// This method sets up the conditions needed to start
 /// placing 3D texts to the stages.
 /// </summary>
 /// <param name="stage">The stage from which 3D texts should
 ///                     start to be placed, of type
 ///                     BouncyStage</param>
 public void Generate3DTexts(BouncyStage stage)
 {
     _stageCurrent  = stage; // Setting the current stage
     _text3DPointer = 0;     // Starting the 3D placement
                             // process
 }
    /// <summary>
    /// This method adds 1 or 2 points to the line renderer which are
    /// self point and the average point.
    /// </summary>
    /// <param name="stage">The stage from which to add a point,
    ///                     of type BouncyStage</param>
    private void AddLinkPoint(BouncyStage stage)
    {
        // Condition for adding the average point
        if (StageObjectsUsed.childCount > 2)
        {
            _linePoint = Vector3.zero; // Resetting the line point

            // Condition for adding obstacles
            if (_offsetObstacle == OffsetObstacle &&
                _isObstacleAvailable)
            {
                // Calculating the average point
                _linePoint.Set((stage.transform.position.x
                                + stage.LinkedStagePosition.x) / 2,

                               (stage.transform.position.y
                                + stage.LinkedStagePosition.y) / 2,

                               (stage.transform.position.z
                                + stage.LinkedStagePosition.z) / 2);

                // Setting the position
                ObstacleContainer.GetChild(_pointerObstacle)
                .position = _linePoint;

                // Setting the rotation of the obstacle, the value
                // is taken from the last stage placed because that
                // and the obstacle should have the same rotation
                ObstacleContainer.GetChild(_pointerObstacle)
                .rotation = StageObjectsUsed
                            .GetChild(StageObjectsUsed.childCount - 1)
                            .transform.rotation;

                // Showing the obstacle
                ObstacleContainer.GetChild(_pointerObstacle)
                .gameObject.SetActive(true);

                // Storing the obstacle used
                _obstaclesUsed.Add(
                    ObstacleContainer.GetChild(_pointerObstacle));

                _pointerObstacle++; // Pointing to the next obstacle
            }
            else // NOT adding obstacles
            {
                // Calculating the average point
                _linePoint.Set(_isOffsetStageZAxis ?
                               stage.LinkedStagePosition.x :
                               (stage.transform.position.x
                                + stage.LinkedStagePosition.x) / 2,

                               (stage.transform.position.y
                                + stage.LinkedStagePosition.y) / 2,

                               _isOffsetStageZAxis ?
                               (stage.transform.position.z
                                + stage.LinkedStagePosition.z) / 2 :
                               stage.LinkedStagePosition.z);

                /*// Calculating the average point
                 * _linePoint.Set(stage.LinkedStagePosition.x,
                 *
                 *            (stage.transform.position.y
                 + stage.LinkedStagePosition.y) / 2,
                 +
                 +            (stage.transform.position.z
                 + stage.LinkedStagePosition.z) / 2);*/
            }

            AddLinkPoint(_linePoint); // Adding the average point
        }

        AddLinkPoint(stage.transform.position); // Adding the self point.

        // Incrementing the offset obstacle counter
        _offsetObstacle = _offsetObstacle + 1 > OffsetObstacle ?
                          1 :
                          _offsetObstacle + 1;
    }
    /// <summary>
    /// This method adds a bouncy stage and obstacle objects to the game world.
    /// </summary>
    /// <param name="index">The index of the bouncy stage, of type int</param>
    private void AddBouncyStage(int index)
    {
        // Condition for getting new stage distance value for z-axis
        if (_isOffsetStageZAxis)
        {
            CalculateStageOffset(ref _offsetZAxis);
        }
        // Condition for getting new stage distance value for x-axis
        else
        {
            CalculateStageOffset(ref _offsetXAxis);
        }

        _stagePosition = Vector3.zero; // Resetting the value
                                       // to get accurate
                                       // calculation

        // Condition to change the x-axis position randomly
        if (_isOffsetStageZAxis)
        {
            CalculateStageSideOffset(ref _offsetXAxis,
                                     Random.Range(
                                         -OffsetSide,
                                         OffsetSide));
        }
        // Condition to change the z-axis position randomly
        else
        {
            CalculateStageSideOffset(ref _offsetZAxis,
                                     Random.Range(
                                         -OffsetSide,
                                         OffsetSide));
        }

        // Setting up the new stage object position
        _stagePosition.Set(_offsetXAxis,
                           _offsetYAxis,
                           _offsetZAxis);

        _currentBouncyStage = null; // Removing the previous stage

        // Storing the newly added bouncy stage
        _currentBouncyStage = BouncyStagesAvailable.GetChild(index)
                              .GetChild(0).GetComponent <BouncyStage>();

        // Setting the stage object position
        _currentBouncyStage.transform.parent.position = _stagePosition;

        // Showing the stage object
        _currentBouncyStage.transform.parent.gameObject.SetActive(true);

        // Condition to check if the stage being added is BouncyStageBreakable
        if (_currentBouncyStage.GetComponent <BouncyStageBreakable>() != null)
        {
            // Enabling the script and showing the model
            _currentBouncyStage.gameObject.SetActive(true);

            // Resetting bouncy breakable stage
            _currentBouncyStage.GetComponent <BouncyStageBreakable>().ResetStage();
        }

        // Removing the stage object from the available list
        _currentBouncyStage.transform.parent.SetParent(StageObjectsUsed);

        // Linking the current stage with the previous stage
        _currentBouncyStage.GetComponent <BouncyStage>().LinkedStage =
            StageObjectsUsed.GetChild(StageObjectsUsed.childCount - 2)
            .GetChild(0)
            .GetComponent <BouncyStage>();

        // Setting the the stage number of the stage
        _currentBouncyStage.GetComponent <BouncyStage>().StageNumber
            = _stageNumberCounter++;

        // Calculating the new position of the current stage, needed for
        // calculating the direction
        _stagePosCurrent.Set(_currentBouncyStage.transform.parent.position.x,
                             0,
                             _currentBouncyStage.transform.parent.position.z);

        // Calculating the new position of the previous stage, needed for
        // calculating the direction
        _stagePosPrevious.Set(StageObjectsUsed.GetChild(StageObjectsUsed.childCount - 2)
                              .transform.position.x,
                              0,
                              StageObjectsUsed.GetChild(StageObjectsUsed.childCount - 2)
                              .transform.position.z);

        // Rotating the current stage to face the previous stage
        _currentBouncyStage.transform.parent.rotation = Quaternion.LookRotation(
            _stagePosPrevious - _stagePosCurrent);

        // Adding the self and average points
        AddLinkPoint(_currentBouncyStage);

        _stageGeneratedCounter++; // stage object added
    }