Ejemplo n.º 1
0
    private AwaitedKeyUI CreateAwaitedUI(bool destroyOnPress, InputType input)
    {
        AwaitedKeyUI awaitedKeyUI = Instantiate(awaitedKeyUIPrefab, awaitedKeysParent).GetComponent <AwaitedKeyUI>();

        awaitedKeyUI.destroyOnPress = destroyOnPress;
        awaitedKeyUI.awaitedInput   = input;
        return(awaitedKeyUI);
    }
Ejemplo n.º 2
0
    private IEnumerator TutorialSequence()
    {
        sequenceManager.enabled         = false;
        sequenceManager.display.enabled = false;
        rollValidateZone.gameObject.SetActive(false);
        walkValidateZone.gameObject.SetActive(false);
        GameManager.instance.exitPortal.enabled = false;

        // Movement
        dialogUI.DisplayText(movementTutorialText);
        yield return(AwaitInput(new List <InputType>()
        {
            InputType.Up, InputType.Left, InputType.Right, InputType.Down
        }));

        step1Wall.SetActive(false);
        SoundController.Instance.PlaySound(SoundName.sequenceSuccess);

        // Roll
        rollValidateZone.gameObject.SetActive(true);
        dialogUI.DisplayText(rollTutorialText);
        AwaitedKeyUI awaitedKeyUIRoll = CreateAwaitedUI(false, InputType.Roll);

        yield return(waitRollValidate);

        Destroy(awaitedKeyUIRoll.gameObject);
        rollValidateZone.gameObject.SetActive(false);
        SoundController.Instance.PlaySound(SoundName.sequenceSuccess);

        // Memory : Part 1
        dialogUI.DisplayText(memoryTutorialText1);
        dialogUI.OnDisplayFinished += DialogUI_OnDisplayFinished;
        yield return(waitStepOk);

        stepOk = false;
        dialogUI.OnDisplayFinished -= DialogUI_OnDisplayFinished;

        sequenceManager.enabled         = true;
        sequenceManager.display.enabled = true;
        sequenceManager.StartGamePhase();

        AwaitedKeyUI awaitedKeyUIRed    = CreateAwaitedUI(false, InputType.Red);
        AwaitedKeyUI awaitedKeyUIBlue   = CreateAwaitedUI(false, InputType.Blue);
        AwaitedKeyUI awaitedKeyUIYellow = CreateAwaitedUI(false, InputType.Yellow);
        AwaitedKeyUI awaitedKeyUIGreen  = CreateAwaitedUI(false, InputType.Green);

        sequenceManager.player.OnValidKeyPress += SequencePlayer_OnValidKeyPress;
        yield return(new WaitUntil(() => stepOk));

        sequenceManager.player.OnValidKeyPress -= SequencePlayer_OnValidKeyPress;
        stepOk = false;

        // Memory : Part 2
        sequenceManager.player.OnSuccess += SequencePlayer_OnSuccess;
        dialogUI.DisplayText(memoryTutorialText2);
        yield return(waitStepOk);

        sequenceManager.player.OnSuccess -= SequencePlayer_OnSuccess;
        stepOk = false;

        SoundController.Instance.PlaySound(SoundName.sequenceSuccess);

        // Memory : Part 3
        dialogUI.DisplayText(memoryTutorialText3);
        yield return(waitAllEnemiesDeath);

        stepOk = false;

        Destroy(awaitedKeyUIRed.gameObject);
        Destroy(awaitedKeyUIBlue.gameObject);
        Destroy(awaitedKeyUIYellow.gameObject);
        Destroy(awaitedKeyUIGreen.gameObject);

        SoundController.Instance.PlaySound(SoundName.sequenceSuccess);

        // Items
        GameManager.instance.GetPlayer().items.SetItem(new Item_Shield(ItemStrength.Medium), 0);
        GameManager.instance.GetPlayer().items.SetItem(new Item_SequenceReducer(ItemStrength.Medium), 1);
        dialogUI.DisplayText(itemsTutorialText);
        yield return(AwaitInput(new List <InputType>()
        {
            InputType.Item1, InputType.Item2
        }));

        step2Wall.SetActive(false);
        SoundController.Instance.PlaySound(SoundName.sequenceSuccess);

        // Walk to portal
        walkValidateZone.gameObject.SetActive(true);
        dialogUI.DisplayText(walkToPortalTutorialText);
        yield return(waitWalkValidate);

        walkValidateZone.gameObject.SetActive(false);

        // Portal : Part 1 (wait)
        dialogUI.DisplayText(portalTutorialText1);
        dialogUI.OnDisplayFinished += DialogUI_OnDisplayFinished;
        yield return(waitStepOk);

        stepOk = false;
        dialogUI.OnDisplayFinished -= DialogUI_OnDisplayFinished;

        // Portal : Part 2 (activate)
        GameManager.instance.timer = 3.0f;
        yield return(new WaitForSeconds(3f));

        dialogUI.OnDisplayFinished += DialogUI_OnDisplayFinished;
        GameManager.instance.exitPortal.OnEnter += ExitPortal_OnEnter;
        dialogUI.DisplayText(portalTutorialText2);
        GameManager.instance.exitPortal.enabled = true;
        GameManager.instance.exitPortal.active  = true;
        yield return(waitStepOk);

        stepOk = false;
        dialogUI.OnDisplayFinished -= DialogUI_OnDisplayFinished;
        yield return(new WaitForSeconds(1f));

        if (!GameManager.instance.levelEnded)
        {
            sequenceManager.player.StopSequencePlay();
            sequenceManager.player.StartSequencePlay(sequenceManager.sequence);

            // Portal : Part 3 (open)
            sequenceManager.player.OnSuccess += SequencePlayer_OnSuccess;
            yield return(waitStepOk);

            stepOk = false;
            dialogUI.DisplayText(finalTutorialText);
        }
        SoundController.Instance.PlaySound(SoundName.sequenceSuccess);
    }