Exemplo n.º 1
0
        public static bool StartChoices(DialogueItemChoiceGroup item, DatabaseDialogue.ConfigData config)
        {
            DialogueUI.RequireInstance(config);
            DialogueUI.Instance.wrapChoices.SetActive(true);

            bool choicesAvailable = DialogueUI.Instance.SetupChoices(item, config);

            if (choicesAvailable && item.timedChoice)
            {
                DialogueUI.Instance.StartTimer(item.timeout.GetValue(item.gameObject));
            }

            return(choicesAvailable);
        }
Exemplo n.º 2
0
        // PUBLIC METHODS: ------------------------------------------------------------------------

        public static void ShowText(IDialogueItem item, DatabaseDialogue.ConfigData config)
        {
            DialogueUI.RequireInstance(config);

            DialogueUI.Instance.currentMessage         = (item.content != null ? item.content.GetText() : "");
            DialogueUI.Instance.typewritterEnabled     = config.enableTypewritterEffect;
            DialogueUI.Instance.typewritterCharsPerSec = config.charactersPerSecond;
            DialogueUI.Instance.typewritterStartTime   = Time.time;

            string msg = (config.enableTypewritterEffect ? "" : DialogueUI.Instance.currentMessage);

            DialogueUI.Instance.textMessage.text = msg;
            DialogueUI.Instance.wrapMessage.SetActive(true);
        }
Exemplo n.º 3
0
        public static void StartLine(IDialogueItem item, DatabaseDialogue.ConfigData config)
        {
            DialogueUI.RequireInstance(config);
            DialogueUI dialogue = DialogueUI.Instance;

            dialogue.currentMessage        = item.GetContent();
            dialogue.typewriterEnabled     = config.enableTypewriterEffect;
            dialogue.typewriterCharsPerSec = config.charactersPerSecond;
            dialogue.typewriterStartTime   = Time.time;
            dialogue.gibberish             = null;

            string msg = (config.enableTypewriterEffect ? "" : dialogue.currentMessage);

            dialogue.textMessage.text = msg;

            if (dialogue.wrapLogs != null)
            {
                dialogue.wrapLogs.SetActive(true);
            }
            if (dialogue.wrapGraphic != null)
            {
                dialogue.wrapGraphic.SetActive(true);
            }
            if (dialogue.wrapMessage != null)
            {
                dialogue.wrapMessage.SetActive(true);
            }

            if (dialogue.textTitle != null)
            {
                dialogue.textTitle.gameObject.SetActive(false);
            }
            if (dialogue.actorColor != null)
            {
                dialogue.actorColor.gameObject.SetActive(false);
            }
            if (dialogue.actorImage != null)
            {
                dialogue.actorImage.gameObject.SetActive(false);
            }
            if (dialogue.actorRawImage != null)
            {
                dialogue.actorRawImage.gameObject.SetActive(false);
            }
            if (dialogue.actorPrefabContainer != null)
            {
                dialogue.actorPrefabContainer.gameObject.SetActive(false);
            }

            if (item.actor != null)
            {
                if (dialogue.textTitle != null)
                {
                    dialogue.textTitle.gameObject.SetActive(true);
                    dialogue.textTitle.text = item.actor.GetName();
                }

                if (dialogue.actorColor != null)
                {
                    dialogue.actorColor.gameObject.SetActive(true);
                    dialogue.actorColor.color = item.actor.color;
                }

                if (item.actorSpriteIndex < item.actor.actorSprites.data.Length)
                {
                    ActorSprites.Data spriteData = item.actor.actorSprites.data[item.actorSpriteIndex];
                    switch (spriteData.type)
                    {
                    case ActorSprites.DataType.Sprite:
                        if (dialogue.actorImage != null)
                        {
                            dialogue.actorImage.gameObject.SetActive(true);
                            dialogue.actorImage.sprite = spriteData.sprite;
                        }
                        break;

                    case ActorSprites.DataType.Texture:
                        if (dialogue.actorRawImage != null)
                        {
                            dialogue.actorRawImage.gameObject.SetActive(true);
                            dialogue.actorRawImage.texture = spriteData.texture;
                        }
                        break;

                    case ActorSprites.DataType.Prefab:
                        if (dialogue.actorPrefabContainer != null)
                        {
                            dialogue.actorPrefabContainer.gameObject.SetActive(true);
                            for (int i = dialogue.actorPrefabContainer.childCount - 1; i >= 0; --i)
                            {
                                Destroy(dialogue.actorPrefabContainer.GetChild(i).gameObject);
                            }

                            GameObject instance = Instantiate(
                                spriteData.prefab,
                                dialogue.actorPrefabContainer
                                );
                            instance.transform.localScale = Vector3.one;
                        }
                        break;
                    }
                }

                if (item.actor.useGibberish)
                {
                    dialogue.gibberish = new GibberishEffect(
                        item.actor.gibberishAudio,
                        item.actor.gibberishPitch,
                        item.actor.gibberishVariation
                        );
                }
            }

            if (config.enableTypewriterEffect)
            {
                DialogueUI.Instance.typewriter = new TypeWriterEffect(
                    DialogueUI.Instance.currentMessage
                    );
            }
        }