Exemple #1
0
    //routine to update the dodging of the camera;
    IEnumerator MoveCamera()
    {
        while (true)
        {
            //if the player is up and is dodging, become immortal and start moving camera;
            if (isDodgeKeyPressed() && !isPlayerDown)
            {
                isPlayerDown           = true;
                dodgingCamera.pathMode = PathMode.Normal;
                //can't come back until it has ended moving;
                yield return(StartCoroutine(dodgingCamera.MoveTransform()));
            }
            //if the player is down and releases the key (or input is disabled), camera comes back;
            if (!isDodgeKeyPressed() && isPlayerDown)
            {
                dodgingCamera.pathMode = PathMode.ReverseNormal;
                //can't dodge again until it returns up;
                yield return(StartCoroutine(dodgingCamera.MoveTransform()));

                isPlayerDown = false;
            }
            yield return(null);
        }
    }
Exemple #2
0
    //the actual flow of the game, yielding to other coroutines;
    IEnumerator ExecuteGameFlow()
    {
        //setting initial data;
        StageData currentStage        = firstStage;
        bool      isThereAnotherStage = true;

        //setting player position in case it's somewhere else;
        player.movementPattern = currentStage.GetComponent <SplineData> ();
        player.SetTransformAt(0);

        //game loop;
        while (isThereAnotherStage)
        {
            //starts on 1st stage;
            currentStage.SpawnAllTargets();
            EnableInput(true);
            //wait for action message;
            if (currentStage.spawners.Count > 0)
            {
                yield return(StartCoroutine(StartStageAction()));
            }
            //now wait till all targets are dead;
            yield return(StartCoroutine(currentStage.CheckIfStageClear()));

            //TODO:stop if player dead;
            //after killing all sets camera movement;
            player.movementPattern = currentStage.GetComponent <SplineData> ();
            //disable input while moving;
            EnableInput(false);
            //check if there is another stage!
            if (player.movementPattern.fixedFinalPosition == null)
            {
                isThereAnotherStage = false;
                EndLevel(true);
            }
            else
            {
                //coroutine to move the camera to the next stage;
                yield return(StartCoroutine(player.MoveTransform()));

                //after moving switch to new stage;
                currentStage = player.movementPattern.fixedFinalPosition.GetComponent <StageData> ();
            }
        }
        yield return(null);
    }