Exemplo n.º 1
0
        // PUBLIC METHODS: ------------------------------------------------------------------------

        public void Add(IDialogueItem item, bool isChoice)
        {
            Log log = new Log(
                item.GetContent(),
                isChoice,
                item.actor,
                item.actorSpriteIndex
                );

            this.logs.Add(log);
            this.eventAdd.Invoke(log);
        }
Exemplo n.º 2
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
                    );
            }
        }