public void useNode(SecuenceNode c) { if (c.Content == null || !(c.Content is Dialog)) { c.Content = ScriptableObject.CreateInstance <Dialog>(); } myNode = c; // This could be used aswell, but I only advise this your class inherrits from UnityEngine.Object or has a CustomPropertyDrawer // Since you'll find your item using: serializedObject.FindProperty("list").GetArrayElementAtIndex(index).objectReferenceValue // which is a UnityEngine.Object // reorderableList = new ReorderableList(serializedObject, serializedObject.FindProperty("list"), true, true, true, true); // Add listeners to draw events fragmentsReorderableList = new ReorderableList(new ArrayList(), typeof(Dialog.Fragment), true, true, true, true); fragmentsReorderableList.drawHeaderCallback += DrawFragmentsHeader; fragmentsReorderableList.drawElementCallback += DrawFragment; fragmentsReorderableList.onAddCallback += AddFragment; fragmentsReorderableList.onRemoveCallback += RemoveFragment; fragmentsReorderableList.onReorderCallback += ReorderFragments; optionsReorderableList = new ReorderableList(new ArrayList(), typeof(Dialog.DialogOption), true, true, true, true); //optionsReorderableList.elementHeight = 70; optionsReorderableList.drawHeaderCallback += DrawOptionsHeader; optionsReorderableList.drawElementCallback += DrawOption; optionsReorderableList.onAddCallback += AddOption; optionsReorderableList.onRemoveCallback += RemoveOption; optionsReorderableList.onReorderCallback += ReorderOptions; }
void drawLines(Rect from, SecuenceNode to) { if (to == null) return; // Visible loop line curveFromTo(from, to.Position, l, s); if (!loopCheck.ContainsKey(to)) { loopCheck.Add(to, true); float h = to.Position.height / (to.Childs.Length * 1.0f); for (int i = 0; i < to.Childs.Length; i++) { Rect fromRect = sumRect(to.Position, new Rect(0, h * i, 0, h-to.Position.height)); // Looking child line if (lookingChildNode == to && i == lookingChildSlot) { if (hovering != -1) curveFromTo(fromRect, nodes[hovering].Position, l, s); else curveFromTo(fromRect, new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1, 1), l, s); } else drawLines(fromRect, to.Childs[i]); } } }
public void useNode(SecuenceNode c) { if(c.Content != null) c.Content = null; node = c; }
public void useNode(SecuenceNode c) { if(c.Content == null || !(c.Content is GameEvent)) c.Content = ScriptableObject.CreateInstance<GameEvent>(); this.node = c; }
public void init() { Debug.Log("Root created"); this.nodes = new List <SecuenceNode>(); root = this.createChild(); Debug.Log(root); DontDestroyOnLoad(this); }
public override ISecuenceInterpreter createSecuenceInterpreterFor(SecuenceNode node) { foreach(ISecuenceInterpreter si in secuenceInterpreters){ if(si.CanHandle(node)) return si.Clone(); } return null; }
public void init() { Debug.Log ("Root created"); root = ScriptableObject.CreateInstance<SecuenceNode>(); Debug.Log (root); root.init (); DontDestroyOnLoad(this); }
public void init() { Debug.Log ("Root created"); this.nodes = new List<SecuenceNode>(); root = this.createChild(); Debug.Log (root); DontDestroyOnLoad(this); }
public void init() { Debug.Log("Root created"); root = ScriptableObject.CreateInstance <SecuenceNode>(); Debug.Log(root); root.init(); DontDestroyOnLoad(this); }
public void removeChild(SecuenceNode child) { this.childs.Remove(child); if(Application.isEditor) ScriptableObject.DestroyImmediate (child); else ScriptableObject.Destroy (child); }
public SecuenceNode addNewChild() { SecuenceNode node = ScriptableObject.CreateInstance <SecuenceNode>(); node.init(); this.childs.Add(node); return(node); }
public void useNode(SecuenceNode c) { if (!(c.Content is Checkable)) { c.Content = null; } myNode = c; }
public void useNode(SecuenceNode c) { if (c.Content == null || !(c.Content is Dialog)) { c.Content = ScriptableObject.CreateInstance <Dialog>(); } myNode = c; }
public void useNode(SecuenceNode c) { if(c.Content != null) c.Content = null; c.ChildSlots = 0; node = c; }
public void useNode(SecuenceNode c) { if (c.Content != null) { c.Content = null; } node = c; }
public void useNode(SecuenceNode c) { if (c.Content == null || !(c.Content is GameEvent)) { c.Content = ScriptableObject.CreateInstance <GameEvent>(); } this.node = c; }
public void removeChild(SecuenceNode child) { for (int i = 0; i < childs.Length; i++) { if (child == childs[i]) { this.removeChild(i); break; } } }
private void findNodes(SecuenceNode node, Dictionary<SecuenceNode, bool> checkList) { if (node == null) return; if (checkList.ContainsKey(node)) checkList[node] = true; foreach (var c in node.Childs) findNodes(c, checkList); }
public override ISecuenceInterpreter createSecuenceInterpreterFor(SecuenceNode node) { foreach (ISecuenceInterpreter si in secuenceInterpreters) { if (si.CanHandle(node)) { return(si.Clone()); } } return(null); }
public void useNode(SecuenceNode c) { if (c.Content != null) { c.Content = null; } c.ChildSlots = 0; node = c; }
public void removeChild(SecuenceNode child) { this.childs.Remove(child); if (Application.isEditor) { ScriptableObject.DestroyImmediate(child); } else { ScriptableObject.Destroy(child); } }
public bool removeChild(SecuenceNode node) { int pos = nodes.IndexOf(node); if (pos != -1) { nodes.RemoveAt(pos); SecuenceNode.DestroyImmediate(node); } return pos != -1; }
public bool removeChild(SecuenceNode node) { int pos = nodes.IndexOf(node); if (pos != -1) { nodes.RemoveAt(pos); SecuenceNode.DestroyImmediate(node); } return(pos != -1); }
public void Tick() { Dialog dialog = node.Content as Dialog; if (!launched) { wasLooking = CameraManager.Target; fragments = new Queue <Dialog.Fragment>(dialog.getFragments()); launched = true; next = true; chosen = -1; } if (next) { if (fragments.Count > 0) { if (fragments.Peek().Entity != null) { CameraManager.smoothLookTo(fragments.Peek().Entity.gameObject); } DialogGUI gui = ScriptableObject.CreateInstance <DialogGUI>(); gui.init(this, fragments.Dequeue()); GUIManager.addGUI(gui); } else { if (dialog.getOptions() != null && dialog.getOptions().Length > 1) { DialogGUI gui = ScriptableObject.CreateInstance <DialogGUI>(); gui.init(this, dialog.getOptions()); GUIManager.addGUI(gui); } else { chosen = 0; } } next = false; } if (chosen != -1) { finished = true; CameraManager.lookTo(wasLooking); if (node.Childs.Length > chosen) { nextNode = node.Childs[chosen]; } chosen = -1; } }
void createWindows(SecuenceNode node) { rects[node] = GUILayout.Window(windowId, rects[node], nodeWindow, node.Name, GUILayout.MinWidth(300)); nodos.Add (windowId, node); windowId++; float altura = 100; for(int i = 0; i< node.Childs.Length; i++){ if(!rects.ContainsKey(node.Childs[i])) rects.Add(node.Childs[i], new Rect(rects[node].x + /*rects[node].width*/ + 315, rects[node].y + i*altura, 150, 0)); curveFromTo(rects[node], rects[node.Childs[i]], new Color(0.3f,0.7f,0.4f), s); createWindows(node.Childs[i]); } }
void OnGUI() { windowId = 0; SecuenceNode nodoInicial = secuence.Root; if (!rects.ContainsKey(nodoInicial)) { rects.Add(nodoInicial, new Rect(10, 10, 300, 0)); } BeginWindows(); nodos.Clear(); createWindows(nodoInicial); EndWindows(); }
public void useNode(SecuenceNode c) { if (c.Content == null || !(c.Content is SerializableGameEvent)) { c.Content = ScriptableObject.CreateInstance <SerializableGameEvent> (); } var sge = c.Content as SerializableGameEvent; if (sge.Name == null) { sge.Name = ""; } this.node = c; }
private void findNodes(SecuenceNode node, Dictionary <SecuenceNode, bool> checkList) { if (node == null) { return; } if (checkList.ContainsKey(node)) { checkList[node] = true; } foreach (var c in node.Childs) { findNodes(c, checkList); } }
public void removeChild(int i) { SecuenceNode node = this.childs[i]; if (node != null) { this.childs.RemoveAt(i); if (Application.isEditor) { ScriptableObject.DestroyImmediate(node); } else { ScriptableObject.Destroy(node); }; } }
void nodeWindow(int id) { SecuenceNode myNode = nodos[id]; string[] editorNames = NodeEditorFactory.Intance.CurrentNodeEditors; int preEditorSelected = NodeEditorFactory.Intance.NodeEditorIndex(myNode); int editorSelected = EditorGUILayout.Popup( preEditorSelected, NodeEditorFactory.Intance.CurrentNodeEditors ); NodeEditor editor = (editors.ContainsKey(myNode))?editors[myNode]:null; if (editor == null || preEditorSelected != editorSelected) { editor = NodeEditorFactory.Intance.createNodeEditorFor(editorNames[editorSelected]); editor.useNode(myNode); if (!editors.ContainsKey(myNode)) { editors.Add(myNode, editor); } else { editors[myNode] = editor; } } editor.draw(); nodos[id] = editor.Result; if (Event.current.type != EventType.layout) { Rect lastRect = GUILayoutUtility.GetLastRect(); Rect myRect = rects [myNode]; myRect.height = lastRect.y + lastRect.height; rects [myNode] = myRect; this.Repaint(); } GUI.DragWindow(); }
public override int NodeEditorIndex(SecuenceNode node) { int i = 0; foreach (NodeEditor nodeEditor in nodeEditors) { if (nodeEditor.manages(node)) { return(i); } else { i++; } } return(0); }
void createWindows(SecuenceNode node) { rects[node] = GUILayout.Window(windowId, rects[node], nodeWindow, node.Name, GUILayout.MinWidth(300)); nodos.Add(windowId, node); windowId++; float altura = 100; for (int i = 0; i < node.Childs.Length; i++) { if (!rects.ContainsKey(node.Childs[i])) { rects.Add(node.Childs[i], new Rect(rects[node].x + /*rects[node].width*/ +315, rects[node].y + i * altura, 150, 0)); } curveFromTo(rects[node], rects[node.Childs[i]], new Color(0.3f, 0.7f, 0.4f), s); createWindows(node.Childs[i]); } }
public void Tick() { if(!SecuenceFinished){ if(currentInterpreter == null){ currentInterpreter = SecuenceInterpreterFactory.Intance.createSecuenceInterpreterFor(currentNode); currentInterpreter.UseNode(currentNode); } currentInterpreter.Tick(); if(currentInterpreter.HasFinishedInterpretation()){ Debug.Log ("Finished interpretation"); currentNode = currentInterpreter.NextNode(); if(currentInterpreter is Object) Object.DestroyImmediate(currentInterpreter as Object); currentInterpreter = null; } } }
void drawLines(Rect from, SecuenceNode to) { if (to == null) { return; } // Visible loop line curveFromTo(from, to.Position, l, s); if (!loopCheck.ContainsKey(to)) { loopCheck.Add(to, true); float h = to.Position.height / (to.Childs.Length * 1.0f); for (int i = 0; i < to.Childs.Length; i++) { Rect fromRect = sumRect(to.Position, new Rect(0, h * i, 0, h - to.Position.height)); // Looking child line if (lookingChildNode == to && i == lookingChildSlot) { if (hovering != -1) { curveFromTo(fromRect, nodes[hovering].Position, l, s); } else { curveFromTo(fromRect, new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1, 1), l, s); } } else { drawLines(fromRect, to.Childs[i]); } } } }
public void Tick() { if (!SecuenceFinished) { if (currentInterpreter == null) { currentInterpreter = SecuenceInterpreterFactory.Intance.createSecuenceInterpreterFor(currentNode); currentInterpreter.UseNode(currentNode); } currentInterpreter.Tick(); if (currentInterpreter.HasFinishedInterpretation()) { Debug.Log("Finished interpretation"); currentNode = currentInterpreter.NextNode(); if (currentInterpreter is Object) { Object.DestroyImmediate(currentInterpreter as Object); } currentInterpreter = null; } } }
public bool CanHandle(SecuenceNode node) { return(node != null && node.Content != null && node.Content is Dialog); }
public bool CanHandle(SecuenceNode node) { return node!= null && node.Content != null && node.Content is GameEvent; }
public bool manages(SecuenceNode c) { return(c.Content != null && c.Content is Dialog); }
public abstract int NodeEditorIndex(SecuenceNode node);
public void useNode(SecuenceNode c) { if(c.Content == null || !(c.Content is Dialog)) c.Content = ScriptableObject.CreateInstance<Dialog>(); myNode = c; }
public bool manages(SecuenceNode c) { return c.Content != null && c.Content is Checkable; }
public void useNode(SecuenceNode c) { if(c.Content == null || !(c.Content is GameEvent)) c.Content = ScriptableObject.CreateInstance<GameEvent>(); var ge = c.Content as GameEvent; if(ge.Name == null) ge.Name = ""; this.node = c; }
public bool manages(SecuenceNode c) { return c.Content != null && c.Content is GameEvent; }
public void Tick() { Dialog dialog = node.Content as Dialog; if(!launched){ wasLooking = CameraManager.Target; fragments = new Queue<Dialog.Fragment>(dialog.getFragments()); launched = true; next = true; chosen = -1; } if(next){ if(fragments.Count > 0){ if(fragments.Peek().Entity != null) CameraManager.smoothLookTo(fragments.Peek().Entity.gameObject); DialogGUI gui = ScriptableObject.CreateInstance<DialogGUI>(); gui.init(this, fragments.Dequeue()); GUIManager.addGUI (gui); }else{ if(dialog.getOptions() != null && dialog.getOptions().Length>1){ DialogGUI gui = ScriptableObject.CreateInstance<DialogGUI>(); gui.init(this, dialog.getOptions()); GUIManager.addGUI (gui); } else chosen = 0; } next = false; } if(chosen != -1){ finished = true; CameraManager.lookTo(wasLooking); if (node.Childs.Length > chosen) nextNode = node.Childs[chosen]; chosen = -1; } }
public bool CanHandle(SecuenceNode node) { return node!= null && node.Content != null && node.Content is Dialog; }
void nodeWindow(int id) { SecuenceNode myNode = nodes[id]; if (myNode.Collapsed) { if (GUILayout.Button("Open")) myNode.Collapsed = false; } else { string[] editorNames = NodeEditorFactory.Intance.CurrentNodeEditors; int preEditorSelected = NodeEditorFactory.Intance.NodeEditorIndex(myNode); GUILayout.BeginHorizontal(); int editorSelected = EditorGUILayout.Popup(preEditorSelected, editorNames); if (GUILayout.Button("-", collapseStyle, GUILayout.Width(15), GUILayout.Height(15))) myNode.Collapsed = true; if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15))) secuence.removeChild(myNode); GUILayout.EndHorizontal(); NodeEditor editor = null; editors.TryGetValue(myNode, out editor); if (editor == null || preEditorSelected != editorSelected) { editor = NodeEditorFactory.Intance.createNodeEditorFor(editorNames[editorSelected]); editor.useNode(myNode); if (!editors.ContainsKey(myNode)) editors.Add(myNode, editor); else editors[myNode] = editor; } GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); editor.draw(); GUILayout.EndVertical(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); int i = 0; foreach (var c in myNode.Childs) { var n = (i+1) + ""; if (c != null) n = c.Name; if (GUILayout.Button(n)) { // Detach myNode.Childs[i] = null; // Start search lookingChildNode = myNode; lookingChildSlot = i; } i++; } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); nodes[id] = editor.Result; } if (Event.current.type != EventType.layout) { Rect lastRect = GUILayoutUtility.GetLastRect (); Rect myRect = myNode.Position; myRect.height = lastRect.y + lastRect.height; myNode.Position = myRect; this.Repaint(); } if (Event.current.type == EventType.mouseMove) { if (new Rect(0, 0, myNode.Position.width, myNode.Position.height).Contains(Event.current.mousePosition)) { hovering = id; } } if (Event.current.type == EventType.mouseDown) { if (hovering == id) focusing = hovering; if (lookingChildNode != null) { // link creation between nodes lookingChildNode.Childs[lookingChildSlot] = myNode; // finishing search lookingChildNode = null; } } GUI.DragWindow(); }
void nodeWindow(int id) { SecuenceNode myNode = nodes[id]; if (myNode.Collapsed) { if (GUILayout.Button("Open")) { myNode.Collapsed = false; } } else { string[] editorNames = NodeEditorFactory.Intance.CurrentNodeEditors; int preEditorSelected = NodeEditorFactory.Intance.NodeEditorIndex(myNode); GUILayout.BeginHorizontal(); int editorSelected = EditorGUILayout.Popup(preEditorSelected, editorNames); if (GUILayout.Button("-", collapseStyle, GUILayout.Width(15), GUILayout.Height(15))) { myNode.Collapsed = true; } if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15))) { secuence.removeChild(myNode); } GUILayout.EndHorizontal(); NodeEditor editor = null; editors.TryGetValue(myNode, out editor); if (editor == null || preEditorSelected != editorSelected) { editor = NodeEditorFactory.Intance.createNodeEditorFor(editorNames[editorSelected]); editor.useNode(myNode); if (!editors.ContainsKey(myNode)) { editors.Add(myNode, editor); } else { editors[myNode] = editor; } } GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); editor.draw(); GUILayout.EndVertical(); GUILayout.BeginVertical(); GUILayout.FlexibleSpace(); int i = 0; foreach (var c in myNode.Childs) { var n = (i + 1) + ""; if (c != null) { n = c.Name; } if (GUILayout.Button(n)) { // Detach myNode.Childs[i] = null; // Start search lookingChildNode = myNode; lookingChildSlot = i; } i++; } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); nodes[id] = editor.Result; } if (Event.current.type != EventType.layout) { Rect lastRect = GUILayoutUtility.GetLastRect(); Rect myRect = myNode.Position; myRect.height = lastRect.y + lastRect.height; myNode.Position = myRect; this.Repaint(); } if (Event.current.type == EventType.mouseMove) { if (new Rect(0, 0, myNode.Position.width, myNode.Position.height).Contains(Event.current.mousePosition)) { hovering = id; } } if (Event.current.type == EventType.mouseDown) { if (hovering == id) { focusing = hovering; } if (lookingChildNode != null) { // link creation between nodes lookingChildNode.Childs[lookingChildSlot] = myNode; // finishing search lookingChildNode = null; } } GUI.DragWindow(); }
public bool manages(SecuenceNode c) { return c.Content != null && c.Content is Dialog; }
public override int NodeEditorIndex(SecuenceNode node) { int i = 0; foreach (NodeEditor nodeEditor in nodeEditors) if(nodeEditor.manages(node)) return i; else i++; return 0; }
public bool CanHandle(SecuenceNode node) { return node!= null && node.Content != null && node.Content is Checkable; }
public void UseNode(SecuenceNode node) { this.node = node; }
void OnGUI() { if (secuence == null) { this.Close(); } this.wantsMouseMove = true; if (closeStyle == null) { closeStyle = new GUIStyle(GUI.skin.button); closeStyle.padding = new RectOffset(0, 0, 0, 0); closeStyle.margin = new RectOffset(0, 5, 2, 0); closeStyle.normal.textColor = Color.red; closeStyle.focused.textColor = Color.red; closeStyle.active.textColor = Color.red; closeStyle.hover.textColor = Color.red; } if (collapseStyle == null) { collapseStyle = new GUIStyle(GUI.skin.button); collapseStyle.padding = new RectOffset(0, 0, 0, 0); collapseStyle.margin = new RectOffset(0, 5, 2, 0); collapseStyle.normal.textColor = Color.blue; collapseStyle.focused.textColor = Color.blue; collapseStyle.active.textColor = Color.blue; collapseStyle.hover.textColor = Color.blue; } SecuenceNode nodoInicial = secuence.Root; GUILayout.BeginVertical(GUILayout.Height(20)); GUILayout.BeginHorizontal(); if (GUILayout.Button("New Node")) { secuence.createChild(); } if (GUILayout.Button("Set Root")) { if (nodes.ContainsKey(focusing)) { secuence.Root = nodes[focusing]; } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); // Clear mouse hover if (Event.current.type == EventType.mouseMove) { hovering = -1; } BeginWindows(); nodes.Clear(); createWindows(secuence); if (Event.current.type == EventType.repaint) { drawLines(secuence); } EndWindows(); }
public bool manages(SecuenceNode c) { return c.Content == null; }
public SecuenceInterpreter(Secuence secuence) { currentNode = secuence.Root; }
public void useNode(SecuenceNode c) { if(!(c.Content is Checkable)) c.Content = null; myNode = c; }
public void UseNode(SecuenceNode node){ this.node = node; }
public abstract ISecuenceInterpreter createSecuenceInterpreterFor(SecuenceNode node);