Пример #1
0
        /// <summary>
        /// sets dialogue to a new speech bubble
        /// </summary>
        private void SetBranch(int newBranchID, Entity e, ref DialogueUI dialogue, ref RenderText renderText)
        {
            DialogueDatam dialogueTree = meta[dialogue.treeID];

            dialogue.branchID = newBranchID;
            var branch = dialogueTree.dialogueTree.branches[dialogue.branchID];

            dialogue.SetText(branch.speech, ref renderText);
            renderText.offsetX = ((-branch.speech.Length - 1f) / 2f) * renderText.fontSize;
            RefreshPanelSize(World.EntityManager, e, renderText.fontSize, branch.speech.Length);
        }
Пример #2
0
        protected override void OnSpawnedPanel(Entity character, Entity panelUI, object spawnData)
        {
            var dialogueTree = Bootstrap.instance.data.dialogues[0].dialogueTree;
            //int startingDialogueID = dialogueTree.id;
            //DialogueDatam dialogueTree = meta[startingDialogueID];
            var        branch     = dialogueTree.branches[0];
            float      fontSize   = 0.03f;
            RenderText renderText = new RenderText
            {
                fontSize = fontSize,
                offsetX  = ((-branch.speech.Length - 1f) / 2f) * fontSize
            };

            renderText.SetColor(Color.blue);
            DialogueUI dialogueUI = new DialogueUI
            {
                treeID           = dialogueTree.id,
                timePerLetterMin = 0.07f,
                timePerLetterMax = 0.21f
            };

            dialogueUI.RandomizeCooldown();
            dialogueUI.SetText(branch.speech, ref renderText);
            //UnityEngine.Debug.LogError("Testing dialogue - self talking: " + dialogueTree.data[0].speech);
            World.EntityManager.AddComponentData(panelUI, dialogueUI);
            World.EntityManager.AddComponentData(panelUI, renderText);
            byte uiIndex = ((byte)((int)PlayerUIType.DialogueUI));

            World.EntityManager.SetComponentData(panelUI, new PanelUI
            {
                id          = uiIndex,
                characterID = World.EntityManager.GetComponentData <ZoxID>(character).id,
                size        = new float2((branch.speech.Length) * (fontSize * 1.1f), fontSize),
                dirty       = 1,
                orbitDepth  = uiDatam.orbitDepth,
                anchor      = (byte)UIAnchoredPosition.Middle
            });
            Childrens children = new Childrens {
            };

            World.EntityManager.AddComponentData(panelUI, children);
        }