Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (dr == null)
        {
            initDR();
        }

        if (!dr.CheckDialogFileName(dialogFileName))
        {
            Debug.Log("dialogFileName:" + dialogFileName + ", actual: " + dr.GetDialogFileName());
            initDR();
            UpdateInScene();
            return;
        }

        if (black == null)
        {
            UpdateInScene();
        }

        if (cerealing && Input.GetKeyUp(KeyCode.S))
        {
            dr.Jump("SkippedEating");
            jumpToAction = true;
            skipping     = true;
        }

        //Debug.Log(failedPuzzle);

        if (autoStarting && !Init.initing)
        {
            black.SetActive(true);
            Diabox.enabled = true;
            Debug.Log("autoStarting");
            dr.Begin("splash");             // for splash screens
            //_playerController.busy = true;
            _playerController.playerMoving = false;
            _playerController.busy         = true;
            tagStarted = true;
        }

        if (textInProgress)
        {
            black.SetActive(true);
            Diabox.enabled = true;
            Debug.Log("text in progress");
            ReformatWaitText();
        }

        if (selecting && !jumpToAction)
        {
            _playerController.playerMoving = false;
            _playerController.busy         = true;

            if (Input.GetKeyUp(KeyCode.DownArrow))
            {
                indexSelected++;
                if (indexSelected >= currSelectOptions.Count)
                {
                    indexSelected = currSelectOptions.Count - 1;
                }
                ReformatChoices();
            }
            else if (Input.GetKeyUp(KeyCode.UpArrow))
            {
                indexSelected--;
                if (indexSelected < 0)
                {
                    indexSelected = 0;
                }
                ReformatChoices();
            }
            else if (Input.GetKeyUp(KeyCode.Return))
            {
                selecting = false;
                string selectedOption = currSelectOptions[indexSelected];
                string jumpAction     = selectActions[selectedOption];
                dr.Jump(jumpAction);
                jumpToAction = true;
            }
        }
        else if
        (skipping || autoStarting ||
         (tagStarted && (!dialogEnded) &&
          !puzzling && !textInProgress && !inputInAction &&
          (Input.GetKeyUp(KeyCode.Return) || jumpToAction)))
        {
            indexSelected = 0;
            // if (tagStarted){
            //  Debug.Log("tagStarted");
            // }
            // if (!dialogEnded){
            //  Debug.Log("!dialogEnded");
            // }
            // if (Input.GetKeyUp(KeyCode.Return)){
            //  Debug.Log("Return");
            // }
            // if (jumpToAction){
            //  Debug.Log("jumpToAction");
            // }
            autoStarting   = false;
            skipping       = false;
            jumpToAction   = false;
            textInProgress = false;
            inputInAction  = false;
            black.SetActive(true);
            Diabox.enabled = true;
            Debug.Log("entered");


            string[] thisAction = dr.NextAction();

            ReformatScores();

            if (thisAction[0].Equals(""))
            {
                Debug.Log("can't get current action");
            }
            else
            {
                selecting = false;
                currSelectOptions.Clear();
                switch (thisAction[0])
                {
                case "Text":
                    _playerController.playerMoving = false;
                    ReformatText(thisAction[1]);
                    Debug.Log(thisAction[1]);
                    break;

                case "WaitText":
                    _playerController.playerMoving = false;
                    _playerController.busy         = true;
                    ProcessWaitText(thisAction[1]);
                    Debug.Log(thisAction[1]);
                    textInProgress = true;
                    framesPerSec   = (int)Math.Round(1 / Time.deltaTime);
                    break;

                case "Select":
                    selecting     = true;
                    selectActions = dr.GetSelectChoices(Int32.Parse(thisAction[1]));
                    foreach (KeyValuePair <string, string> entry in selectActions)
                    {
                        currSelectOptions.Add(entry.Key);
                        Debug.Log(entry.Key + " gives " + entry.Value);
                    }
                    _playerController.playerMoving = false;
                    _playerController.busy         = true;
                    ReformatChoices();
                    break;

                case "Puzzle":
                    Debug.Log("entering puzzle");
                    InitPuzzle(thisAction[1]);
                    // if (hasThoughtSpiral || true){
                    //  Debug.Log("hasspiral");
                    //  ThoughtSpiralPuzzle.Initialize(thisAction[1], WinnableScores());
                    //  puzzling = true;
                    //  //_playerController.busy = true;
                    //  _playerController.playerMoving = false;
                    // }
                    break;

                case "End":
                    Debug.Log("end of file reached");
                    TerminateScene();
                    break;

                case "EndTag":
                    Debug.Log("end of tag reached");
                    tagStarted = false;
                    EndPart();
                    break;

                case "COUCH":
                    TerminateScene();
                    TouchDaCouch(thisAction [1]);
                    break;

                default:
                    Debug.Log("unknown option " + thisAction[0]);
                    break;
                }
            }
        }
        else
        {
            if (puzzling)
            {
                //_playerController.busy = true;
                _playerController.playerMoving = false;
                _playerController.busy         = true;
            }
            else
            {
                //_playerController.busy = false;
                _playerController.playerMoving = true;
                //_playerController.busy = false;
            }
        }
    }