Ejemplo n.º 1
0
        private void StoryUpdate(Ballpoint.StoryUpdate update)
        {
            textDisplay.text = update.text;
            var hasChoices = update.choices.Count > 0;

            choicesParent.SetActive(hasChoices);
            nextButtonVisibilityContainer.SetActive(!hasChoices);
            if (hasChoices)
            {
                var buttons = choicesParent.GetComponentsInChildren <Button>();
                foreach (var button in buttons)
                {
                    button.gameObject.SetActive(false);
                }

                for (var i = 0; i < update.choices.Count; i++)
                {
                    var    buttonExists = i < buttons.Length;
                    Button button;
                    if (buttonExists)
                    {
                        button = buttons[i];
                    }
                    else
                    {
                        button = Instantiate(choicePrefab, choicesParent.transform);
                        var currentI = i; // if we don't do this, it uses the final value of i
                        button.onClick.AddListener(() => ink.Continue(currentI));
                    }
                    button.GetComponentInChildren <UnityEngine.UI.Text>().text = update.choices[i];
                    button.gameObject.SetActive(true);
                }
            }
        }
Ejemplo n.º 2
0
        // must async auto-continue, or new messages happen immediately,
        // in the middle of the old message, leading to out-of-order issues.
        private IEnumerator AutoContinue(StoryUpdate update)
        {
            if (autoContinue && (ink.story.canContinue && update.choices.Count == 0))
            {
                yield return(new WaitForSeconds(0));

                ink.Continue();
            }
            if (autoContinue && update.atEnd)
            {
                Quit();
            }
        }
Ejemplo n.º 3
0
        void Update()
        {
            float x = Input.GetAxis("Horizontal");

            if (x != 0)
            {
                scale.x = x < 0 ? -x_scale : x_scale;         // Flip the Character
            }
            transform.localScale = scale;

            if (Input.GetButtonUp("Submit") && interactTarget != null)
            {
                interactTarget.Interact();
                var choiceIndex = choices.IndexOf(interactTarget.name);
                if (choiceIndex < 0)
                {
                    Debug.LogWarning($"No such choice at this time: {interactTarget.name}");
                }
                else
                {
                    ink.Continue(choiceIndex);
                }
            }
        }