Esempio n. 1
0
 private void Update()
 {
     if (triggerHighlight.IsHighLighted() && !sequenceFound)
     {
         PlayerFlute.Note[] playerNotes = GameController.GetInstance().player.GetComponentInChildren <PlayerFlute>().ReadMemory();
         sequenceFound = false;
         int i = 0;
         if (playerNotes.Length >= goodSequence.Length)
         {
             while (!sequenceFound && i < playerNotes.Length)
             {
                 int j = 0;
                 while (j < goodSequence.Length &&
                        playerNotes.Length - i >= goodSequence.Length &&
                        (playerNotes[i + j] == goodSequence[j] || goodSequence[j] == PlayerFlute.Note.Whatever))
                 {
                     j++;
                 }
                 if (j == goodSequence.Length)
                 {
                     sequenceFound = true;
                 }
                 else
                 {
                     i++;
                 }
             }
         }
     }
     if (sequenceFound && !scenarioWarned)
     {
         waitTime += Time.deltaTime;
         if (waitTime >= waitBufferAfterFound)
         {
             scenario.InitScenario();
             scenarioWarned = true;
         }
     }
 }
Esempio n. 2
0
    void Update()
    {
        bool manualTrigger     = Input.GetKeyDown(KeyCode.Space) && triggerHighlight != null && triggerHighlight.IsHighLighted();
        bool automaticTrigger  = goTriggerAutomatically;
        bool playerIsAvailable = GameController.GetInstance().player.GetComponent <PlayerMode>().GetCurrentMode() == PlayerMode.Mode.CONTROLLER;

        if ((manualTrigger || automaticTrigger) && playerIsAvailable && !dialogIsInProgress)
        {
            textUI                 = GameController.GetInstance().LaunchDialogBox(this);
            endOfLineCursorImg     = textUI.GetComponentInChildren <Image>();
            dialogIsInProgress     = true;
            currentDialog          = parser.GetDialog(dialogId);
            goTriggerAutomatically = false;
        }

        if (dialogIsInProgress)
        {
            if (lineId == 0 || Input.GetKeyDown(KeyCode.Space))
            {
                if (showLineProgressively && Input.GetKeyDown(KeyCode.Space))
                {
                    textUI.text = currentDialog[lineId];
                    ReachEndOfLine();
                }
                else if (lineId < currentDialog.Count)
                {
                    showLineProgressively = true;
                    StopWaitingForNextLine();
                }
                else
                {
                    dialogId    = Mathf.Min(parser.GetDialogCount() - 1, dialogId + 1);
                    textUI.text = "";
                    GameController.GetInstance().QuitDialogBox();
                    dialogIsInProgress = false;
                    currentDialog      = null;
                    lineId             = 0;
                    StopWaitingForNextLine();
                }
            }

            if (showLineProgressively)
            {
                if (timeSinceLastChar >= 1 / GameController.GetInstance().dialogSpeed)
                {
                    cursorId++;
                    textUI.text       = currentDialog[lineId].Substring(0, cursorId);
                    timeSinceLastChar = 0;
                    if (cursorId == currentDialog[lineId].Length)
                    {
                        ReachEndOfLine();
                    }
                }
                timeSinceLastChar += Time.deltaTime;
            }

            if (waitingForNextLine)
            {
                timeSinceLastCursorFlash += Time.deltaTime;
                if (timeSinceLastCursorFlash >= 1 / endOfLineCursorFlashSpeed)
                {
                    endOfLineCursorImg.enabled = !endOfLineCursorImg.enabled;
                    timeSinceLastCursorFlash   = 0;
                }
            }
        }

        if (showLineProgressively && !voix.isPlaying)
        {
            voix.Play();
        }
        else if (!showLineProgressively && voix.isPlaying)
        {
            voix.Stop();
        }
    }