Ejemplo n.º 1
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();
        }
    }
Ejemplo n.º 2
0
        private void FindPidsInDialog(BackgroundWorker worker, string filename, List <Tuple <int, int> > pids)
        {
            if (!filename.HaveExtension("fodlg"))
            {
                return;
            }

            DialogParser fodlg = new DialogParser(filename);

            if (fodlg == null)
            {
                return;
            }

            if (fodlg.Parse())
            {
                bool   header     = false;
                string headerText = "? (" + Path.GetFileName(filename) + ")\r\n\r\n";
                Dialog dialog     = fodlg.GetDialog();
                if (dialog == null)
                {
                    return;
                }

                string lNode = "" + dialog.Nodes.Count.ToString().Length;
                foreach (Node node in dialog.Nodes)
                {
                    int    answerId = 0;
                    string lAnswer  = "" + node.Answers.Count.ToString().Length;
                    foreach (Answer answer in node.Answers)
                    {
                        answerId++;
                        int    demandId = 0;
                        int    resultId = 0;
                        string lDemand  = "" + answer.Demands.Count.ToString().Length;
                        string lResult  = "" + answer.Results.Count.ToString().Length;
                        foreach (Demand demand in answer.Demands)
                        {
                            demandId++;
                            if (demand.Item != null)
                            {
                                int pid = -1;
                                if (itemPids.Defines.TryGetValue(demand.Item.PidDefine, out pid) &&
                                    pids.IsWantedObject(objectItem, pid))
                                {
                                    if (!header)
                                    {
                                        if (resultsLog.Text.Length > 0)
                                        {
                                            worker.SendResult("\r\n");
                                        }
                                        worker.SendResult(headerText);
                                        header = true;
                                    }
                                    worker.SendResult(string.Format("\t[Node {0," + lNode + "} Answer {1," + lAnswer + "} Demand {2," + lDemand + "}] {3} {4} {5}\r\n",
                                                                    node.Id,
                                                                    answerId,
                                                                    demandId,
                                                                    demand.Item.PidDefine,
                                                                    demand.Operator == "=" ? "==" : demand.Operator,
                                                                    demand.Value));

                                    worker.SendResult("Dialogs"
                                                      + "|" + Path.GetFileName(filename)
                                                      + "|Node " + node.Id
                                                      + "^" + node.Text["engl"]
                                                      + "|Answer " + answerId
                                                      + "^" + answer.Text["engl"]
                                                      + "|Demand " + demandId + ": "
                                                      + demand.Item.PidDefine + " "
                                                      + (demand.Operator == "=" ? "==" : demand.Operator) + " "
                                                      + demand.Value);
                                }
                            }
                        }
                        foreach (Result result in answer.Results)
                        {
                            resultId++;
                            if (result.Item != null)
                            {
                                int pid = -1;
                                if (itemPids.Defines.TryGetValue(result.Item.PidDefine, out pid) &&
                                    pids.IsWantedObject(objectItem, pid))
                                {
                                    if (!header)
                                    {
                                        if (resultsLog.Text.Length > 0)
                                        {
                                            worker.SendResult("\r\n");
                                        }
                                        worker.SendResult(headerText);
                                        header = true;
                                    }

                                    worker.SendResult(string.Format("\t[Node {0," + lNode + "} Answer {1," + lAnswer + "} Result {2," + lResult + "}] {3} {4} {5}\r\n",
                                                                    node.Id,
                                                                    answerId,
                                                                    resultId,
                                                                    result.Item.PidDefine,
                                                                    result.Operator,
                                                                    result.Value));

                                    worker.SendResult("Dialogs"
                                                      + "|" + Path.GetFileName(filename)
                                                      + "|Node " + node.Id
                                                      + "^" + node.Text["engl"]
                                                      + "|Answer " + answerId
                                                      + "^" + answer.Text["engl"]
                                                      + "|Result " + resultId + ": "
                                                      + result.Item.PidDefine + " "
                                                      + result.Operator + " "
                                                      + result.Value);
                                }
                            }
                        }
                    }
                }
            }
        }