public override void OnClickedButton(Entity player, Entity ui, int arrayIndex, ButtonType buttonType) { DialogueUI dialogueUI = World.EntityManager.GetComponentData <DialogueUI>(ui); dialogueUI.confirmedChoice = (byte)(arrayIndex + 1); // 0 is unselected World.EntityManager.SetComponentData(ui, dialogueUI); }
private void OnCompletedDialogue(Entity e, ref DialogueUI dialogue, ref RenderText renderText) { //Debug.LogError("completedTree " + " 1!"); dialogue.completedTree = 1; //dialogue.branchID = 0; //SetBranch(0, e, ref dialogue, ref renderText); }
/// <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); }
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); }
private void IncrementDialogue(Entity e, ref DialogueUI dialogue, ref RenderText renderText) { int linkChoice = dialogue.confirmedChoice - 1; DialogueDatam dialogueTree = meta[dialogue.treeID]; var currentBranch = dialogueTree.dialogueTree.branches[dialogue.branchID]; int branchID = -1; if (currentBranch.links.Length > 0 && linkChoice < currentBranch.links.Length) { //Debug.LogError("linkChoice was " + linkChoice); branchID = currentBranch.links[linkChoice]; } if (branchID == -1) { OnCompletedDialogue(e, ref dialogue, ref renderText); return; } int linkIndex = -1; for (int i = 0; i < dialogueTree.dialogueTree.branches.Length; i++) { if (dialogueTree.dialogueTree.branches[i].id == branchID) { linkIndex = i; break; } } if (linkIndex == -1) { OnCompletedDialogue(e, ref dialogue, ref renderText); } else { SetBranch(linkIndex, e, ref dialogue, ref renderText); } }
private void IncrementLetters(ref DialogueUI dialogue, ref RenderText renderText) { dialogue.RandomizeCooldown(); dialogue.IncreaseIndex(ref renderText); //RefreshPanelSize(e, newText); }