Esempio n. 1
0
    void GotoState(SequenceState state)
    {
        switch (state)
        {
        case SequenceState.SHOWING_DIALOG:
            controller = leftController;
            switch (curSequence.dialogType)
            {
            case DialogStructure.LEFT:
                controller = leftController;
                break;

            case DialogStructure.RIGHT:
                controller = rightController;
                break;
            }
            controller.Initialize(curSequence);
            controller.ShowDialog(() => {
                GotoState(SequenceState.PRINTING);
            });
            break;

        case SequenceState.PRINTING:
            curSequenceCharacterIndex      = 0;
            timeSinceCharAdded             = 0;
            controller.DialogTextArea.text = "";     // Clear the text for printing
            scrollSpeed = curSequence.scrollSpeed;
            curSequence.OnSequenceStart();
            controller.PlayPortraitEmotionAnim(curSequence.emotionState);
            break;

        case SequenceState.PRINTING_FAST:
            scrollSpeed *= 2;     // Double the scroll speed for fast printing
            break;

        case SequenceState.WAITING_FOR_PROMPT:
            elapsedAdvanceWaitTime = 0.0f;
            break;

        case SequenceState.HIDING_DIALOG:
            controller.DialogTextArea.text = "";     // Clear the text before hiding
            controller.HideDialog(() => {
                curSequence.OnSequenceEnd();
                GotoState(SequenceState.SHOWING_DIALOG);
            });
            break;

        case SequenceState.FINISHED:
            controller.DialogTextArea.text = "";     // Clear the text before hiding
            controller.HideDialog(() => {
                CompleteNarrativeSequence();
            });
            break;
        }
        curState = state;
    }
Esempio n. 2
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        DialogUIController controller = animator.gameObject.GetComponent <DialogUIController>();

        if (controller == null)
        {
            Debug.LogErrorFormat("DialogAnimationBehaviour attached to animator on something without a DialogUIController. Remove this animation from {0}", animator.name);
            return;
        }

        switch (state)
        {
        case StateTransitionState.ENTER:
            controller.OnFinishedShowDialog();
            break;

        case StateTransitionState.EXIT:
            controller.OnFinishedHideDialog();
            break;
        }
    }