Exemple #1
0
    void Update()
    {
        if (!tutorial_mode)
        {
            if (choice_mode == true)
            {
                if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W))
                {
                    if (cursor < choices.Length - 1)
                    {
                        source.PlayOneShot(choose, 1);

                        cursor += 1;
                        transform.Find("Pointer").transform.GetComponent<RectTransform>().anchorMin = new Vector2(.50f, .235f + .1f * cursor);
                        transform.Find("Pointer").transform.GetComponent<RectTransform>().anchorMax = new Vector2(.56f, .31f + .1f * cursor);
                    }
                }
                else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S))
                {
                    if (cursor > 0)
                    {
                        source.PlayOneShot(choose, 1);

                        cursor -= 1;
                        transform.Find("Pointer").transform.GetComponent<RectTransform>().anchorMin = new Vector2(.50f, .235f + .1f * cursor);
                        transform.Find("Pointer").transform.GetComponent<RectTransform>().anchorMax = new Vector2(.56f, .31f + .1f * cursor);
                    }
                }
                else if (Input.GetKeyDown(KeyCode.Space))
                {
                    done = true;
                    GameEventArgs g = new GameEventArgs();
                    g.DialogueBox = this;
                    if (choices[cursor].setbool != null)
                    {
                        gameManager.SetData(choices[cursor].setbool, true);
                    }
                    if (choices[cursor].setDayBool != null)
                    {
                        gameManager.SetData(choices[cursor].setDayBool, true);
                    }
                    if (choices[cursor].CEA.ChoiceAction != ContinueTutorialDialogue)
                    {
                        if (!gameManager.playerData.DialogueHistory.ContainsKey(choices[cursor].CEA.IDNum + "," + choices[cursor].CEA.DialogueID + "," + cursor))
                        {
                            gameManager.playerData.DialogueHistory.Add(choices[cursor].CEA.IDNum + "," + choices[cursor].CEA.DialogueID + "," + cursor, true);
                        }
                    }
                    if (choices[cursor].removeitem != null)
                    {
                        gameManager.dayData.removeItem(choices[cursor].removeitem);
                    }
                    if (choices[cursor].CEA != null)
                    {
                        g.ConvertChoiceEventArgs(choices[cursor].CEA);
                        g.DialogueBox = this;
                        choice_mode = false;
                        Interactable.Action oldaction = g.ChoiceAction;
                        EventManager.NotifyDialogChoiceMade(this, g);
                        if (!(oldaction == continueDialogue || oldaction == ContinueTutorialDialogue))
                        {
                            gameObject.GetComponent<AudioSource>().enabled = true;
                            EventManager.NotifySpaceBar(this, new GameEventArgs());
                        }
                    }
                    else
                    {
                        EventManager.NotifyDialogChoiceMade(this, new GameEventArgs());
                        EventManager.NotifySpaceBar(this, new GameEventArgs());
                    }
                }
            }
            else if (choice_mode == false && Input.GetKeyDown(KeyCode.Space))
            {
                if (Dialog != null)
                {
                    if (Dialog.CEA != null)
                    {
                        GameEventArgs g = new GameEventArgs();
                        g.ConvertChoiceEventArgs(Dialog.CEA);
                        g.DialogueBox = this;
                        Interactable.Action oldaction = Dialog.CEA.ChoiceAction;
                        EventManager.NotifyDialogChoiceMade(this, g);
                        if (!(oldaction == continueDialogue || oldaction == ContinueTutorialDialogue))
                        {
                            gameObject.GetComponent<AudioSource>().enabled = true;
                            EventManager.NotifySpaceBar(this, new GameEventArgs());
                        }
                    }
                    else
                    {
                        if (Dialog.choices != null)
                        {
                            EventManager.NotifyDialogChoiceMade(this, new GameEventArgs());
                        }
                        EventManager.NotifySpaceBar(this, new GameEventArgs());
                    }
                }
                else
                {
                    EventManager.NotifySpaceBar(this, new GameEventArgs());
                }
            }
        }
    }