コード例 #1
0
        private void buttonsListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            var dialogue     = (Dialogue)dialogueListBox.SelectedItem;
            var button       = (DialogueButton)buttonsListBox.SelectedItem;
            var nextPromptId = button.Json["NextPromptID"].ToString();

            if (string.IsNullOrWhiteSpace(nextPromptId))
            {
                dialogueTextBox.Clear();
                buttonsListBox.Items.Clear();
            }
            else
            {
                //find the next prompt
                var nextPrompt = dialogue.Json["DialogPrompts"].FirstOrDefault(o => o["Number"].ToString().Equals(nextPromptId));
                dialogueTextBox.Text = button.Json["ActionName"].ToString() + Environment.NewLine + nextPrompt["PromptBody"].ToString();
                buttonsListBox.Items.Clear();
                foreach (var action in nextPrompt["Action"])
                {
                    var obj = new DialogueButton()
                    {
                        Json = action,
                    };

                    buttonsListBox.Items.Add(obj);
                }
            }
        }
コード例 #2
0
    public void SetupActionData(DialogueData dialogueData, int curLine, DialogueObject dialogueObj)
    {
        for (int i = 0; i < dialogueButtonList.Count; i++)
        {
            Destroy(dialogueButtonList[i]);
        }
        dialogueButtonList.Clear();

        for (int i = 0; i < dialogueData.dialogueLines[curLine].actionData.Length; i++)
        {
            ActionData curActionData = dialogueData.dialogueLines[curLine].actionData[i];

            if (curActionData.condition.haveCondition)
            {
                Condition curCondition = curActionData.condition;

                switch (curCondition.keyType)
                {
                case Condition.KeyType.FLOAT:
                    if (PlayerPrefs.GetFloat(curCondition.playerPrefKey)
                        == curCondition.targetFloatKey)
                    {
                        break;
                    }
                    return;

                case Condition.KeyType.INT:
                    if (PlayerPrefs.GetInt(curCondition.playerPrefKey)
                        == curCondition.targetIntKey)
                    {
                        break;
                    }
                    return;

                case Condition.KeyType.STRING:
                    if (PlayerPrefs.GetString(curCondition.playerPrefKey)
                        == curCondition.targetStringKey)
                    {
                        break;
                    }
                    return;
                }
            }

            //Spawn dialogue button
            GameObject     spawnDialogueGO      = Instantiate(dialogueButton, dialogueButtonGroup);
            DialogueButton dialogueButtonScript = spawnDialogueGO.GetComponent <DialogueButton>();
            dialogueButtonScript.Setup(dialogueData, curLine, i, dialogueObj);
            dialogueButtonList.Add(spawnDialogueGO);
        }
    }
コード例 #3
0
        private void dialogueListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            var dialogue = (Dialogue)dialogueListBox.SelectedItem;

            var promptBody = dialogue.Json["PromptBody"].ToString();

            dialogueTextBox.Text = promptBody;

            foreach (var action in dialogue.Json["Action"])
            {
                var obj = new DialogueButton()
                {
                    Json = action,
                };

                buttonsListBox.Items.Add(obj);
            }
        }
コード例 #4
0
    public void FixedUpdate()
    {
        if (_Phase == SpeechPhase.CanTalk)
        {
            SpeechNotice.CalculatePosition(gameObject.transform.position);
        }

        // Tween textboxes if the phase is conversation.
        if (_Phase == SpeechPhase.Conversation)
        {
            TextBackground.Tween();
            Speaker.Tween();
            Content.Tween();

            for (int i = 0; i < DialogueLines[_DialogueIndex].Buttons.Count; i++)
            {
                DialogueButton button = DialogueLines[_DialogueIndex].Buttons[i];
                button.Button.Tween();
            }
        }
    }
コード例 #5
0
    public void OnGUI()
    {
        switch (_Phase)
        {
        case SpeechPhase.CanTalk:
            GUI.skin = MapSkin;
            if (SpeechNotice.IsClicked())
            {
                _Maestro.PlaySoundEffect(ButtonSound);

                _Phase         = SpeechPhase.Conversation;
                _DialogueIndex = _DialogueStartIndex;
                TransitionTextbox();
            }
            break;

        case SpeechPhase.Conversation:
            GUI.skin = DialogueSkin;
            TextBackground.DrawMe();
            Speaker.DrawMe();
            Content.DrawMe();

            for (int i = 0; i < DialogueLines[_DialogueIndex].Buttons.Count; i++)
            {
                DialogueButton button = DialogueLines[_DialogueIndex].Buttons[i];
                if (button.Button.IsClicked())
                {
                    _Maestro.PlaySoundEffect(ButtonSound);

                    _DialogueIndex      = button.DialogueIndex;
                    _DialogueStartIndex = button.NewDialogueStartIndex;
                    TransitionTextbox();
                }
            }
            break;

        default:
            break;
        }
    }
コード例 #6
0
    void Start()
    {
        panel = GameObject.FindGameObjectWithTag("ConvoPanel");

        if (panel == null)
        {
            Debug.LogError("Convoseration Panel isn't tagged correctly");
        }

        text = panel.transform.Find("ConvoText").GetComponent <Text>();

        if (text != null)
        {
            convoScript = text.GetComponent <ConversationScript>();
        }

        diaButton = panel.transform.Find("Button").GetComponent <DialogueButton>();

        if (GlobalVars.isTutorial)
        {
            index = 2;
        }
    }
コード例 #7
0
    //When something hits its 2D collider
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.tag.Equals("Player"))
        {
            //----------Special Cases only During Tutorial----------------
            if (IsSceneTutorial())
            {
                dButton = GameObject.FindGameObjectWithTag("ConvoUIButton").GetComponent <DialogueButton>();
                dButton.SwitchingState(); //turns on dialogue when levels is finished
            }

            if (GlobalVars.isTutorial) //if a level is completed before the game "crashes"
            {
                crashing = true;       //activate crashing prompt
            }
            //------------------This is normal-----------------
            else //Display the result values
            {
                _text.text = "Final Time Is: " + totalTime.ToString();
                _panel.gameObject.SetActive(true);
                _panel.transform.Find("BronzeText").GetComponent <Text>().text = BronzeTime.ToString() + ".00";
                _panel.transform.Find("SilverText").GetComponent <Text>().text = SilverTime.ToString() + ".00";
                _panel.transform.Find("GoldText").GetComponent <Text>().text   = GoldTime.ToString() + ".00";
            }

            endTime = true; //stop the timer

            int medalNum = 0;

            if (SceneManager.GetActiveScene().name != "Tutorial") //calcuates the level time into medals
            {
                medalNum = MedalHandler.CalcMedalType(BronzeTime, SilverTime, GoldTime, totalTime);
            }
            else //just show the medals if it is the tutorial
            {
                medalNum = 3;
            }

            switch (medalNum) //activates a medal based upon the number it gets
            {
            case 3:
                goldMedal.gameObject.SetActive(true);
                goto case 2;

            case 2:
                silverMedal.gameObject.SetActive(true);
                goto case 1;

            case 1:
                bronzeMedal.gameObject.SetActive(true);
                break;

            default:
                print(":(");
                break;
            }

            //stop time if the level isn't the tutorial. We need time to still be functioning in the tutorial for animations to play
            if (!IsSceneTutorial())
            {
                Time.timeScale = 0;
            }
        }
    }