Exemplo n.º 1
0
        /// <summary>
        /// Displays a slider option dialogue which, allowing the user to interact with it
        /// </summary>
        /// <param name="dialogue">The SliderOptionDialogue option which contains the information to be displayed on the view</param>
        /// <param name="onValueConfirmed">The callback which is invoked when the user confirms the value</param>
        public void StartSliderOptionDialogue(SliderOptionDialogue dialogue, Action <int> onValueConfirmed)
        {
            Action <int> handleButtonPressed = value =>
            {
                onValueConfirmed(value);
                sliderOptionViewAnimator.SetBool("InstantTransition", false);
                sliderOptionViewAnimator.SetBool("IsVisible", false);
            };

            if (dialogue.PrecedingDialogue.Statements.Length != 0)
            {
                StartSimpleDialogue(dialogue.PrecedingDialogue, () =>
                {
                    sliderOptionDialogueView.SetContent(dialogue, handleButtonPressed);
                    simpleDialogueViewAnimator.SetBool("InstantTransition", true);
                    simpleDialogueViewAnimator.SetBool("IsVisible", false);
                    sliderOptionViewAnimator.SetBool("InstantTransition", true);
                    sliderOptionViewAnimator.SetBool("IsVisible", true);
                });
            }
            else
            {
                sliderOptionDialogueView.SetContent(dialogue, handleButtonPressed);
                sliderOptionViewAnimator.SetBool("InstantTransition", false);
                sliderOptionViewAnimator.SetBool("IsVisible", true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the content of the dialogue to be displayed to the user
        /// </summary>
        /// <param name="dialogue">the SliderOptionDialogue to render contents from</param>
        /// <param name="handleButtonPressed">A callback which is to be called when the button is pressed</param>
        internal void SetContent(SliderOptionDialogue dialogue, Action <int> handleButtonPressed)
        {
            confirmButton.onClick.RemoveAllListeners();

            npcImage = GameObject.Find("SliderNPCImage").GetComponent <Image>();
            Debug.Log("Slider NPC Name: " + dialogue.PrecedingDialogue.Name);
            npcImage.sprite      = NPCSpriteManager.Instance.GetSprite(dialogue.PrecedingDialogue.Name);
            npcNameText.text     = dialogue.PrecedingDialogue.Name;
            npcDialogueText.text = dialogue.Question;
            slider.maxValue      = dialogue.MaxValue;
            slider.minValue      = dialogue.MinValue;
            slider.value         = (dialogue.MaxValue - dialogue.MinValue) / 2;
            sliderValueText.text = ((int)slider.value).ToString();
            confirmButton.onClick.AddListener(() =>
            {
                handleButtonPressed((int)Math.Round(slider.value));
            });

            cardTypeText.text  = dialogue.CardType + " Decision";
            cardTypeText.color = dialogue.CardType == "Story" ? new Color32(168, 24, 36, 255) : new Color32(219, 164, 44, 255);
        }