public static uConversationNode getNodeByStringID(string id) { uConversationNode node = null; strIdMap.TryGetValue(id, out node); return(node); }
public void addNode(uConversationNode node) { foreach (uConversationNode c in nodeList) { foreach (long uid in c.getAlternatives().Keys) { uConversationNode.Alternative a = null; c.getAlternatives().TryGetValue(uid, out a); if (a.getUID() == node.getUID()) { a.setTarget(node); } } foreach (long uid in node.getAlternatives().Keys) { uConversationNode.Alternative a = null; node.getAlternatives().TryGetValue(uid, out a); if (a.getUID() == c.getUID()) { a.setTarget(c); } } } nodeList.Add(node); nodes++; }
public static uConversationNode getNodeByID(long id) { uConversationNode node = null; idMap.TryGetValue(id, out node); return(node); }
public Alternative newAlternative(uConversationNode target) { Alternative alt = new Alternative(target.getUID()); alt.setTarget(target); alternatives.Add(alt.getUID(), alt); return(alt); }
public uConversationNode GoToAlternative(string s) { uConversationNode forreturn = null; // foreach(Alternative a in getAlternatives().Values) { // uConversationNode tempNode = uConversationNode.getNodeByID(a.getUID()); // Debug.Log(a.getText() + " -> " + tempNode.getText()); // if(((forreturn != null && forreturn.getPrioritizedAlternative < tempNode.blocks.Count) || (forreturn == null)) && s.Equals(a.getText()) && tempNode.ABlockSatisfied()) { // if(s.Equals(a.getText())) { // Alternative a = getPrioritizedAlternative(); // forreturn = tempNode; // } // } return(getNodeByID((getPrioritizedAlternative(s).getUID()))); }
public void ResponseClicked(GameObject responseChosen) { // Debug.Log(curNode.getAlternativeStrings()[responseChosen.transform.GetSiblingIndex()]); if (responseChosen.transform.GetChild(0).GetComponent <Text>().text.Equals("Goodbye")) { curNode = uConversationNode.getNodeByStringID(startConvID); UpdateUI(); this.Interact(); } else { curNode = curNode.GoToAlternative(curNode.getAlternativeStrings()[responseChosen.transform.GetSiblingIndex()]); ActionEventInvoker.primaryInvoker.invokeAction(new PlayerAction(curNode.getDirectObject(), ActionType.CONVERSATION_NODE_HIT)); UpdateUI(); } }
// Use this for initialization void Start() { // foreach(uConversation c in LoadResources.Instance.Conversations) { // if(c.getName().Equals(name)) { // conv = c; // break; // } // } // for(int i = 0; i < conv.getNodeList().Count; i++) { // uConversationNode node = conv.getNodeList()[i]; // Debug.Log(i + ". " + node.getText()); // } curNode = uConversationNode.getNodeByStringID(startConvID); nameUI1.text = name; nameUI2.text = name; if (curNode == null) { Debug.Log(this.name + " cannot find their conversation!"); } curText.text = curNode.getText(); int numResponses = 0; foreach (string s in curNode.getAlternativeStrings()) { // Debug.Log("Alternatives: " + s); if (numResponses > 0) { GameObject newButton = (GameObject)Instantiate(buttonPrefab); newButton.GetComponent <RectTransform>().SetParent(buttonHolder.transform, false); newButton.GetComponent <RectTransform>().anchoredPosition = Vector2.zero - new Vector2(0, 18 + (numResponses - 1) * 55); newButton.GetComponent <RectTransform>().localScale = Vector3.one; newButton.GetComponent <RectTransform>().localEulerAngles = Vector3.zero; newButton.GetComponent <RectTransform>().GetChild(0).GetComponent <Text>().text = s; } else { buttonPrefab.transform.GetChild(0).GetComponent <Text>().text = s; } numResponses++; } }
public void removeNode(uConversationNode node) { nodeList.Remove(node); nodes--; }
public void setTarget(uConversationNode node) { uid = node.uid; target = node; }