public override void Draw() { if (m_transistionNode != null) { m_fromWin = AnimationTreeEditor.instance.GetCorrespondingWindow(m_transistionNode.m_fromState); m_toWin = AnimationTreeEditor.instance.GetCorrespondingWindow(m_transistionNode.m_toState); if ( m_fromWin == null || m_toWin == null ) { return; } m_globalStartPosition = m_fromWin.LocalToGlobalCoord(m_transistionNode.m_startConnection) + m_startPosOffset; m_globalEndPosition = m_toWin.LocalToGlobalCoord(m_transistionNode.m_endConnection) + m_endPosOffset; Vector2 camOffset = AnimationTreeEditor.instance.m_cameraOffset; if (Active) { AnimationTreeEditor.instance.DrawLine(m_globalStartPosition + camOffset, m_globalEndPosition + camOffset, new Color(0.5f, 0.5f, 1, 1), false, 2); } Color col = Color.white; if (m_transistionNode.Progress > 0) { col = Color.red; } AnimationTreeEditor.instance.DrawConnectionLine(m_globalStartPosition + camOffset, m_globalEndPosition + camOffset, col, false); UpdateLinkPositions(); } }
//調整中 public void MoveToNodeWindow(NodeWindow window) { RectTransform viewRect = windowViewObject.gameObject.GetComponent <RectTransform>(); RectTransform windowRect = window.gameObject.GetComponent <RectTransform>(); //viewRect.DOAnchorPos(windowRect.anchoredPosition, 1.0f).SetEase(Ease.OutCirc); //viewRect.DOMove(windowRect.position, 1.0f).SetEase(Ease.OutCirc); }
public void Load(TextAsset ta, Planet livePreview) { if (ta == null) { return; } savepath = AssetDatabase.GetAssetPath(ta); windows.Clear(); settings = TerrainModule.LoadTextAsset(ta, true, 0, 1f); if (settings != null) { foreach (Node n in settings.nodes) { NodeWindow nw = new NodeWindow(n); if (n is OutputNode) { nw.livePreview = livePreview; } windows.Add(nw); } } }
public ConnectionButton( NodeWindow window, ConnectionButtonType type, string label, Alignment align ) { ButtonLabel = label; LabelAlignment = align; LastPosition = new Vector2(); m_type = type; m_parentWindow = window; }
void init() { minSize = new Vector2(300, 50); nodeManager = new NodeManager(); NodeBase heightOutput = NodeBase.createNewHeightOutput(); nodeManager.addNode(NodeWindow.createNew(heightOutput, new Vector2(0f, 100f), nodeManager.findNodeWindow, nodeManager.findNode)); //AssetDatabase.CreateAsset(this, "assert"); }
public Node(int id, NodeWindow window, Vector2 mousePosition) { this.Id = id; this.Window = window; MinNodeSize.position = mousePosition; MaxNodeSize.position = mousePosition; NodeInfo = new NodeInfo(); //new NodeInfo(this); Instance = this; }
public static NodeWindow createNew(NodeBase node, Vector2 pos, FindNodeWindowFun funFind, NodeBase.FindNodeFun funFindNode) { NodeWindow rlt = new NodeWindow(); rlt.node = new NodeWrapper(node); rlt.pos = pos; //rlt.funFindNodeWindow = funFind; rlt.node.value.setFun(funFindNode); //rlt.funFindNode = funFindNode; return(rlt); }
public bool RemoveWindow(Node node) { NodeWindow n = this.SearchWindow(node); if (n != null) { if (n.parentWindow != null) { n.parentWindow.childWindows.Remove(n); } nodeWindowList.Remove(n); Destroy(n.gameObject); return(true); } return(false); }
/// <summary> /// 删除自身 /// </summary> public void Delete() { onNodeDelete?.Invoke(this); foreach (var item in m_NextNodes) { item.m_PrevNodes.Remove(this); } m_NextNodes.Clear(); foreach (var item in m_PrevNodes) { item.m_NextNodes.Remove(this); } m_PrevNodes.Clear(); this.RemoveFromHierarchy(); NodeWindow.OnNodeDelete(data); }
public static void InteractableObjects(Rect fullArea, Rect leftArea, Rect mainArea) { var list = Rm_RPGHandler.Instance.Repositories.Interactable.AllInteractables; GUI.Box(leftArea, "", "backgroundBox"); GUI.Box(mainArea, "", "backgroundBoxMain"); GUILayout.BeginArea(PadRect(leftArea, 0, 0)); RPGMakerGUI.ListArea(list, ref selectedInteractable, Rm_ListAreaType.Interactables, false, true); GUILayout.EndArea(); GUILayout.BeginArea(mainArea); RPGMakerGUI.Title("Interactables"); if (selectedInteractable != null) { RPGMakerGUI.TextField("ID: ", selectedInteractable.ID); selectedInteractable.Name = RPGMakerGUI.TextField("Name: ", selectedInteractable.Name); GUILayout.BeginHorizontal(); gameObject = RPGMakerGUI.PrefabSelector("Prefab:", gameObject, ref selectedInteractable.PrefabPath); gameObject = RPGMakerGUI.PrefabGeneratorButton(Rmh_PrefabType.Interactable, gameObject, ref selectedInteractable.PrefabPath, null, selectedInteractable.ID); GUILayout.EndHorizontal(); selectedInteractable.Image = RPGMakerGUI.ImageSelector("Image", selectedInteractable.Image, ref selectedInteractable.ImagePath, true); if (GUILayout.Button("Open Interaction Window", "genericButton", GUILayout.MaxHeight(30))) { var trees = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees; var existingTree = trees.FirstOrDefault(t => t.ID == selectedInteractable.ID); if (existingTree == null) { existingTree = NodeWindow.GetNewTree(NodeTreeType.Dialog); existingTree.ID = selectedInteractable.ID; existingTree.Name = selectedInteractable.Name; trees.Add(existingTree); } DialogNodeWindow.ShowWindow(selectedInteractable.ID); selectedInteractable.ConversationNodeId = existingTree.ID; } } else { EditorGUILayout.HelpBox("Add or select a new field to customise interactables.", MessageType.Info); } GUILayout.EndArea(); }
public static NodeWindow Instantiate(GameObject prefab, GameObject parent, Node node) { NodeWindow obj = Instantiate(prefab, parent.transform).GetComponent <NodeWindow>(); obj.node = node; if (node.color != "") { obj.SetColor(node.color); } else if (node is BaseNode) { obj.bg.color = obj.baseNodeColor; obj.bgTitle.color = obj.baseNodeColor; } obj.removeButton.SetActive(node.optional); obj.titleText.text = node.title; obj.description.text = node.text; obj.icon.sprite = ImageIO.GetIcon(node.iconName); obj.SetComponentForParameter(); return(obj); }
private void OnClickRemoveNode(NodeWindow node) { var removedNodes = from n in nodes where n.selected select n; foreach (var n in removedNodes) { connections = (from conn in connections where conn.inPoint != n.inPoint && conn.outPoint != n.outPoint select conn) .ToList(); foreach (var conn in connections) { conn.conditions = (from evt in conn.conditions where evt != n select evt) .ToList(); } } nodes = (from n in nodes where !n.selected select n).ToList(); Save(); }
private string GetNewName(string baseName, NodeWindow exceptNode) { string namePattern = @"^" + baseName + @"(?:\s\(\d+\))*\s\((\d+)\)$"; Regex regex = new Regex(namePattern); string initialName = baseName; int index = 0; var subPool = from node in nodes where node.isWorkspace from subnode in ((SubWindows.Group)node).nodes select subnode; foreach (var name in nodes.Concat(subPool).Where(n => n != exceptNode).Select(n => n.nodeName)) { if (name == baseName) { index = 1; } else { var mc = regex.Matches(name); int i = 0; foreach (Match m in mc) { i = int.Parse(m.Groups[1].Value); } if (i != 0) { index = Math.Max(index, i + 1); } } } if (index != 0) { initialName = baseName + " (" + index + ")"; } return(initialName); }
public NodeWindow AddWindow(Node node, bool isOpen = true, NodeWindow parentWindow = null) { var obj = NodeWindow.Instantiate(NodeWindowPrefab, windowViewObject, node); nodeWindowList.Add(obj); if (isOpen == false) { //obj.Close(); } //親ウインドウがある時は位置を調整する。 if (parentWindow != null) { obj.parentWindow = parentWindow; RectTransform objTrans = obj.GetComponent <RectTransform>(); RectTransform prentTrans = parentWindow.GetComponent <RectTransform>(); int a = obj.parentWindow.childWindows.Count; int b = (a % 2 == 0) ? -1:1; int x = a / 2 * b; objTrans.anchoredPosition = new Vector2(prentTrans.anchoredPosition.x + x * 600, prentTrans.anchoredPosition.y - prentTrans.sizeDelta.y - 150); LineViewModel.instance.AddLine(prentTrans, objTrans); } return(obj); }
void MyDragLine() { if (startLineNode != null) { if (bDragingInputLine) { Vector2 lineEnd = startLineNode.getInputPortRect(startLinePort).center; drawBezier(Event.current.mousePosition, lineEnd, new Color(0.8f, 0.8f, 0.8f), true); } else if (bDragingOutputLine) { Vector2 lineStart = startLineNode.getOutputPortRect().center; drawBezier(lineStart, Event.current.mousePosition, new Color(0.8f, 0.8f, 0.8f), true); } } nodeManager.forEachNodes((n) => { for (int i = 0; i < n.getInputNum(); i++) { var inputNode = nodeManager.findNodeWindow(n.getInputGuid(i)); if (inputNode != null) { var endPos = n.getInputPortRect(i).center; var startPos = inputNode.getOutputPortRect().center; drawBezier(startPos, endPos, new Color(0.8f, 0.8f, 0.8f), true); } } }); if (Event.current.type == EventType.MouseDrag) { if (bDragingInputLine) { } } if (Event.current.type == EventType.MouseDown) { if (Event.current.button == 0) { nodeManager.forEachNodes((n) => { for (int i = 0; i < n.getInputNum(); i++) { if (n.getInputPortRect(i).Contains(Event.current.mousePosition)) { if (nodeManager.findNodeWindow(n.getInputGuid(i)) != null) { bDragingOutputLine = true; startLineNode = nodeManager.findNodeWindow(n.getInputGuid(i)); n.setInput(i, ""); } else { bDragingInputLine = true; startLineNode = n; startLinePort = i; } } } if (n.hasOutput()) { if (n.getOutputPortRect().Contains(Event.current.mousePosition)) { bDragingOutputLine = true; startLineNode = n; } } }); } } if (Event.current.type == EventType.MouseUp) { if (Event.current.button == 0) { if (bDragingInputLine) { nodeManager.forEachNodes((n) => { if (n != startLineNode) { if (n.hasOutput() && n.getOutputPortRect().Contains(Event.current.mousePosition)) { startLineNode.setInput(startLinePort, n.getGuid()); } } }); } else if (bDragingOutputLine) { nodeManager.forEachNodes((n) => { if (n != startLineNode) { for (int i = 0; i < n.getInputNum(); i++) { if (n.getInputPortRect(i).Contains(Event.current.mousePosition)) { n.setInput(i, startLineNode.getGuid()); } } } }); } bDragingInputLine = false; bDragingOutputLine = false; this.Repaint(); } } }
public void addNode(NodeWindow node) { nodes.Add(node.getGuid(), node); }
private Node() { m_NextNodes = new List <Node <T> >(); m_PrevNodes = new List <Node <T> >(); this.RegisterCallback <PointerDownEvent>((a) => { this.BringToFront(); }, TrickleDown.NoTrickleDown); #region 节点顶部 #region 连接点 connectPointIn = new ConnectPoint <T>(this, Point.In); connectPointIn.AddToClassList("connectPoint"); connectPointIn.RegisterCallback <PointerDownEvent>((a) => { a.StopPropagation(); }); connectPointOut = new ConnectPoint <T>(this, Point.Out); connectPointOut.AddToClassList("connectPoint"); connectPointOut.RegisterCallback <PointerDownEvent>((a) => { a.StopPropagation(); }); #endregion Label label = new Label() { text = $"节点", }; label.AddToClassList("text"); VisualElement title = new VisualElement(); title.AddToClassList("title"); title.RegisterCallback <MouseMoveEvent>((a) => { if (isMove) { this.transform.position += (Vector3)a.mouseDelta; } }); title.RegisterCallback <PointerDownEvent>((a) => { isMove = true; }); title.RegisterCallback <PointerUpEvent>((a) => { isMove = false; }); title.RegisterCallback <PointerEnterEvent>((a) => { isMove = false; }); title.Add(connectPointIn); title.Add(label); title.Add(connectPointOut); title.RegisterCallback <MouseDownEvent>((v) => { if (v.button == 0 && v.clickCount == 2) { if (Contains(m_ContentUI)) { Remove(m_ContentUI); } else { Add(m_ContentUI); } } else if (v.button == 1 && v.clickCount == 1) { GenericMenu genericMenu = new GenericMenu(); genericMenu.AddItem(new GUIContent("Delete"), false, Delete); NodeWindow.AddCreateNodeMenu(genericMenu, this.transform.position + new Vector3(150, 60, 0), "Add Next Node", (node) => { AddNextNode(node); }); NodeWindow.AddCreateNodeMenu(genericMenu, this.transform.position - new Vector3(20, 20, 0), "Add Prev Node", (node) => { node.AddNextNode(this); }); genericMenu.ShowAsContext(); } }); #endregion Add(title); }
// Select a window at the passed screen position public void SelectWindow(Vector2 position) { NodeWindow lastActiveWin = ActiveWindow; ActiveWindow = null; // Loop backwards through all the windows for ( int i = m_Windows.Count-1; i >=0; i-- ) { NodeWindow nodeWin = m_Windows[i]; // If the position is in the window if (ActiveWindow == null && nodeWin.IsInWindow(position)) { nodeWin.Active = true; ActiveWindow = nodeWin; StateWindow sWin = nodeWin as StateWindow; if (sWin == null) { // If the node is not a state node (no transition drawing), then we are now dragging the window Dragging = true; } else { if (!m_drawingNewTransition) { // If we are in the state window's dragging area and not in the transition drawing area, start dragging if (sWin.IsInDraggingArea(position)) { Dragging = true; } else { // Start drawing a new transition m_drawingNewTransition = true; m_newTransitionStart = position; m_fromStateWindow = sWin; } } else { // Finish drawing transition and create a new one m_drawingNewTransition = false; AT_StateTransition trans = CreateNewTransition( m_fromStateWindow, sWin ); ActiveWindow = GetCorrespondingWindow(trans); } } } else { nodeWin.Active = false; } } if (ActiveWindow != null) { Selection.activeGameObject = ActiveWindow.GetTreeNode().gameObject; // Put the selected window at the back of the window list so it is drawn on top of other windows m_Windows.Remove(ActiveWindow); m_Windows.Add(ActiveWindow); ActiveWindow.Active = true; RefreshVariablesWindow(); } else { } DateTime newClickTime = DateTime.Now; // If we clicked on the same window again if (lastActiveWin == ActiveWindow) { float timeDiff = (float)(DateTime.Now.Subtract(m_lastTimeWindowSelected).TotalSeconds); if (timeDiff < 1) { // Double-clicked on same window if (ActiveWindow != null) { AT_ContainerNode cont = ActiveWindow.GetTreeNode() as AT_ContainerNode; if (cont != null) { if (cont.Expandable) { // Select a child so that we draw all the children of this container if (cont.Children.Count > 0) { Selection.activeGameObject = cont.Children[0].gameObject; } else { if (cont.transform.childCount > 0) { Selection.activeGameObject = cont.transform.GetChild(0).gameObject; } } } } } else // Double-clicked in open space { // Move up to the next container node in the tree AT_ContainerNode cont = null; if (m_activeContainer != null && m_activeContainer.Parent != null) { cont = FindNextContainerNode(m_activeContainer.Parent.gameObject); } else { cont = FindNextContainerNode(Selection.activeGameObject.transform.parent.gameObject); } // If we can move up, do so if (cont != null) { if (cont.gameObject != m_selectedAnimationTree.Root.gameObject) { Selection.activeGameObject = cont.transform.GetChild(0).gameObject; } else { Selection.activeGameObject = cont.gameObject; } } } // Store the min clicked time to reset double click calculation newClickTime = DateTime.MinValue; } } m_lastTimeWindowSelected = newClickTime; // Check if we clicked the control variables window if (m_controlVarsWindow != null && m_controlVarsWindow.IsInWindow(position)) { ActiveWindow = m_controlVarsWindow; } }
protected void CreateNodePressed(object sender, EventArgs args) { NodeWindow NWin = new NodeWindow(nodes, lat, lon); }
void ToolWindowOnGUI() { GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout); myFoldoutStyle.fontStyle = FontStyle.Bold; bShowAddTool = EditorGUILayout.Foldout(bShowAddTool, "Add Node", myFoldoutStyle); if (bShowAddTool) { NodeBase newNode = null; GUILayout.Label("Add Generator"); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Generator")) { newNode = NodeBase.createNewNode(NodeType.Generator); } } GUILayout.EndHorizontal(); GUILayout.Label("Add Operator"); GUILayout.BeginHorizontal(); { if (GUILayout.Button("Unary Operator")) { newNode = NodeBase.createNewNode(NodeType.UnaryOperator); } if (GUILayout.Button("Binary Operator")) { newNode = NodeBase.createNewNode(NodeType.BinaryOperator); } if (GUILayout.Button("Ternary Operator")) { newNode = NodeBase.createNewNode(NodeType.TernaryOperator); } } GUILayout.EndHorizontal(); GUILayout.Label("Add Output"); GUILayout.BeginHorizontal(); { //if (GUILayout.Button("Height Output")) { // newNode = NodeBase.createNewHeightOutput(); //} if (GUILayout.Button("Texture Output")) { newNode = NodeBase.createNewTextureOutput(); } if (GUILayout.Button("Grass Output")) { newNode = NodeBase.createNewGrassOutput(); } if (GUILayout.Button("Tree Output")) { newNode = NodeBase.createNewTreeOutput(); } } GUILayout.EndHorizontal(); if (newNode != null) { Vector2 newPos = this.scrollPosition; NodeWindow newNodeWindow = NodeWindow.createNew(newNode, newPos, nodeManager.findNodeWindow, nodeManager.findNode); newNodeWindow.initWindow(getNewWinID(), OnNodeDelete, OnNodeSelected); newNode.label = getNewName(newNode.label); nodeManager.addNode(newNodeWindow); } GUILayout.Space(20); } if (nodeManager.findNodeWindow(curSelectedNode) != null) { bShowDetailConfig = EditorGUILayout.Foldout(bShowDetailConfig, "Detail Config", myFoldoutStyle); if (bShowDetailConfig) { var curNode = nodeManager.findNodeWindow(curSelectedNode); curNode.DrawProperty(gui); } } }
private KeyValuePair <List <NodeWindow>, List <Connection> > GetSystem(List <ScriptTree.Node> rawNodes) { List <NodeWindow> nodes = new List <NodeWindow>(); List <Connection> conns = new List <Connection>(); foreach (var rn in rawNodes) { NodeWindow node; if (rn.Base == "") { var p = GetSystem(rn.Members); SubWindows.Group g = new SubWindows.Group(p.Key, p.Value, rn.Name, new Vector2((float)rn.Position.X, (float)rn.Position.Y), 250, inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, OnClickGroup, Events, OnClickDegroup, Save, GetNewName, SelectedNodes, SelectedConnections); var start = g.nodes.Find(n => n.nodeName == rn.StartMember); var end = g.nodes.Find(n => n.nodeName == rn.EndMember); if (start != null) { var startConn = new Connection(start.inPoint, g.startPoint, null, null); g.connections.Add(startConn); } if (end != null) { var endConn = new Connection(g.endPoint, end.outPoint, null, null); g.connections.Add(endConn); } node = g; } else { node = new NodeWindow(rn.Base, rn.Name, new Vector2((float)rn.Position.X, (float)rn.Position.Y), 250, inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, OnClickGroup, GetNewName, SelectedNodes, SelectedConnections); node.paramPairs = rn.Params.ToList(); node.nodeName = rn.Name; } nodes.Add(node); } foreach (var rn in rawNodes) { var startNode = nodes.Find(n => n.nodeName == rn.Name); Debug.Assert(startNode != null); if (rn.Succ != null) { foreach (var succ in rn.Succ) { var destNode = nodes.Find(n => n.nodeName == succ.Dest); Debug.Assert(destNode != null); var conn = new Connection(destNode.inPoint, startNode.outPoint, OnClickRemoveConnection, Events); foreach (var cond in succ.Condition) { conn.conditions.Add(nodes.Find(n => n.nodeName == cond)); } conn.stopPrev = succ.EndPrev; conns.Add(conn); } } } return(new KeyValuePair <List <NodeWindow>, List <Connection> >(nodes, conns)); }
private void CardMenuItem_Click(object sender, RoutedEventArgs e) { NodeWindow nodeWindow = new NodeWindow(this); nodeWindow.Show(); }
private void SetParentWindow(NodeWindow window) { this._parentWindow = window; this._parentWindow.childWindows.Add(this); }
public static SubNodeListComponent Instantiate(GameObject prefab, GameObject parent, List <SubNodeParameter> parameters, NodeWindow prentWindow) { SubNodeListComponent obj = Instantiate(prefab, parent.transform).GetComponent <SubNodeListComponent>(); obj.prentWindow = prentWindow; obj.parameters = parameters; obj.AddUnits(obj.parameters); return(obj); }
public static void WorldMap(Rect fullArea, Rect leftArea, Rect mainArea) { leftAreaB = new Rect(leftArea.xMax + 5, leftArea.y, leftArea.width, leftArea.height); mainAreaAlt = new Rect(leftAreaB.xMax + 5, leftArea.y, mainArea.width - (leftAreaB.width + 5), leftArea.height); GUI.Box(leftArea, "", "backgroundBox"); GUI.Box(leftAreaB, "", "backgroundBox"); GUI.Box(mainAreaAlt, "", "backgroundBox"); GUILayout.BeginArea(PadRect(leftArea, 0, 0)); RPGMakerGUI.ListArea(worldAreaList, ref selectedWorldArea, Rm_ListAreaType.WorldAreas, false, false); GUILayout.EndArea(); GUILayout.BeginArea(leftAreaB); if (selectedWorldArea != null) { var rect = RPGMakerGUI.ListArea(selectedWorldArea.Locations, ref selectedWorldAreaLocation, Rm_ListAreaType.Location, false, false, Rme_ListButtonsToShow.AllExceptHelp, true, selectedWorldArea.ID); } GUILayout.EndArea(); GUILayout.BeginArea(mainAreaAlt); worldAreaScrollPos = GUILayout.BeginScrollView(worldAreaScrollPos); RPGMakerGUI.Title("World Areas (Not Finished)"); if (selectedWorldArea != null) { selectedWorldArea.Name = RPGMakerGUI.TextField("Name: ", selectedWorldArea.Name); selectedWorldArea.ImageContainer.Image = RPGMakerGUI.ImageSelector("Image:", selectedWorldArea.ImageContainer.Image, ref selectedWorldArea.ImageContainer.ImagePath); if (GUILayout.Button("Open Interaction Node Tree", "genericButton", GUILayout.MaxHeight(30))) { var trees = Rm_RPGHandler.Instance.Nodes.WorldMapNodeBank.NodeTrees; var existingTree = trees.FirstOrDefault(t => t.ID == selectedWorldArea.ID); if (existingTree == null) { existingTree = NodeWindow.GetNewTree(NodeTreeType.WorldMap); existingTree.ID = selectedWorldArea.ID; Debug.Log(existingTree.ID + ":::" + existingTree.Name); existingTree.Name = selectedWorldArea.Name; trees.Add(existingTree); } WorldMapNodeWindow.ShowWindow(selectedWorldArea.ID); } } if (selectedWorldArea != null) { RPGMakerGUI.SubTitle("Location Info:"); if (selectedWorldAreaLocation != null) { var loc = selectedWorldAreaLocation; loc.Name = RPGMakerGUI.TextField("Name:", loc.Name); loc.ImageContainer.Image = RPGMakerGUI.ImageSelector("Name:", loc.ImageContainer.Image, ref loc.ImageContainer.ImagePath); loc.Description = RPGMakerGUI.TextField("Description:", loc.Description); RPGMakerGUI.SceneSelector("Scene:", ref loc.SceneName); if (RPGMakerGUI.Toggle("Use Custom Spawn Location?", ref loc.UseCustomLocation)) { loc.CustomSpawnLocation = EditorGUILayout.Vector3Field("Location:", loc.CustomSpawnLocation); } } else { EditorGUILayout.HelpBox("Select a location in the world area to begin editing it.", MessageType.Info); } } else { EditorGUILayout.HelpBox("Add or select a new field to customise world areas.", MessageType.Info); } GUILayout.EndScrollView(); GUILayout.EndArea(); }
void SetupNodeWindow() { NodeWindow = new NodeWindow(editorPath, ConstellationScript); }
void SetupNodeWindow() { //SetupWindow(); NodeWindow = new NodeWindow(editorPath, ScriptDataService, nodeWindowSize, nodeWindowScrollPosition); }
private static void QuestDetails(Quest quest, bool inQuestChain) { if (RPGMakerGUI.Foldout(ref showSelectedQuestDetails, "Selected Quest - Main Details")) { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.MaxWidth(85)); quest.Image.Image = RPGMakerGUI.ImageSelector("", quest.Image.Image, ref quest.Image.ImagePath); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.ExpandWidth(true)); quest.Name = RPGMakerGUI.TextField("Name: ", quest.Name); quest.Description = RPGMakerGUI.TextArea("Description:", quest.Description); quest.ConditionMode = (QuestConditionMode)RPGMakerGUI.EnumPopup("Condition Mode:", quest.ConditionMode); if (GUILayout.Button("Open Dialog/Event On Accept", "genericButton", GUILayout.MaxHeight(30))) { var trees = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees; var existingTree = trees.FirstOrDefault(t => t.ID == quest.DialogNodeTreeID); if (existingTree == null) { existingTree = NodeWindow.GetNewTree(NodeTreeType.Dialog); existingTree.ID = quest.ID; existingTree.Name = quest.Name; trees.Add(existingTree); } DialogNodeWindow.ShowWindow(quest.ID); quest.DialogNodeTreeID = existingTree.ID; } if (GUILayout.Button("Open Dialog/Event On Complete", "genericButton", GUILayout.MaxHeight(30))) { var trees = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees; var existingTree = trees.FirstOrDefault(t => t.ID == quest.CompletedDialogNodeTreeID); if (existingTree == null) { existingTree = NodeWindow.GetNewTree(NodeTreeType.Dialog); existingTree.ID = "complete_" + quest.ID; existingTree.Name = "Completed " + quest.Name; trees.Add(existingTree); } DialogNodeWindow.ShowWindow(existingTree.ID); quest.CompletedDialogNodeTreeID = existingTree.ID; } GUILayout.Space(5); RPGMakerGUI.Toggle("Player Keeps Quest Items?", ref quest.PlayerKeepsQuestItems); RPGMakerGUI.Toggle("Is Repeatable?", ref quest.Repeatable); RPGMakerGUI.Toggle("Can Abandon?", ref quest.CanAbandon); if (RPGMakerGUI.Toggle("Has Time Limit?", ref quest.HasTimeLimit)) { quest.TimeLimit = RPGMakerGUI.FloatField("- Time Limit:", quest.TimeLimit); } if (RPGMakerGUI.Toggle("Run Event On Accept?", ref quest.RunEventOnAccept)) { RPGMakerGUI.PopupID <NodeChain>("- Event:", ref quest.EventOnAcceptID); } if (RPGMakerGUI.Toggle("Run Event On Completion?", ref quest.RunEventOnComplete)) { RPGMakerGUI.PopupID <NodeChain>("- Event:", ref quest.EventOnCompletionId); } if (RPGMakerGUI.Toggle("Run Event On Cancel?", ref quest.RunEventOnCancel)) { RPGMakerGUI.PopupID <NodeChain>("- Event:", ref quest.EventOnCancelId); } GUILayout.Space(5); GUILayout.EndVertical(); GUILayout.EndHorizontal(); RPGMakerGUI.EndFoldout(); } if (RPGMakerGUI.Foldout(ref showSelectedQuestReq, "Requirements")) { List <Quest> availableReqQuests = new List <Quest>(); if (inQuestChain) { availableReqQuests = Rm_RPGHandler.Instance.Repositories.Quests.AllQuests.Where(q => selectedQuestChain.QuestsInChain.FirstOrDefault(qu => qu.ID == q.ID) == null).ToList(); } else { availableReqQuests = Rm_RPGHandler.Instance.Repositories.Quests.AllQuests; } RPGMakerGUI.FoldoutList(ref showReqAcceptedQuests, "Required Completed Quests", quest.Requirements.QuestCompletedIDs, availableReqQuests, "+Quest", "", "Click +Quest to add a requirement for a completed quest."); RPGMakerGUI.FoldoutList(ref showCustomVarReqSetters, "Custom Var Requirements", quest.Requirements.CustomRequirements, Rm_RPGHandler.Instance.DefinedVariables.Vars, "+VariableReq", "", "Click +VariableReq to add a varaible requirement", "VariableID", "Name", "ID", "Name", false, "Value"); RPGMakerGUI.SubTitle("More Requirements"); if (RPGMakerGUI.Toggle("Require Player Level:", ref quest.Requirements.RequireLevel)) { quest.Requirements.LevelRequired = RPGMakerGUI.IntField("- Required Level:", quest.Requirements.LevelRequired); } if (RPGMakerGUI.Toggle("Require Player Class:", ref quest.Requirements.RequireClass)) { RPGMakerGUI.PopupID <Rm_ClassNameDefinition>("- Class ID:", ref quest.Requirements.RequiredClassID); } RPGMakerGUI.Toggle("Require Reputation Above Amount :", ref quest.Requirements.ReqRepAboveValue); if (quest.Requirements.ReqRepAboveValue) { quest.Requirements.ReqRepBelowValue = false; } RPGMakerGUI.Toggle("Require Reputation Below Amount :", ref quest.Requirements.ReqRepBelowValue); if (quest.Requirements.ReqRepBelowValue) { quest.Requirements.ReqRepAboveValue = false; } if (quest.Requirements.ReqRepAboveValue || quest.Requirements.ReqRepBelowValue) { RPGMakerGUI.PopupID <ReputationDefinition>("- Reputation Faction:", ref quest.Requirements.ReputationFactionID); var prefix = quest.Requirements.ReqRepAboveValue ? "Above " : "Below "; quest.Requirements.ReputationValue = RPGMakerGUI.IntField("- " + prefix + "Amount:", quest.Requirements.ReputationValue); } if (RPGMakerGUI.Toggle("Require Trait Level?", ref quest.Requirements.RequireTraitLevel)) { RPGMakerGUI.PopupID <Rm_TraitDefintion>("- Trait:", ref quest.Requirements.RequiredTraitID); quest.Requirements.TraitLevel = RPGMakerGUI.IntField("- Level:", quest.Requirements.TraitLevel); } if (RPGMakerGUI.Toggle("Require Learnt Skill?", ref quest.Requirements.RequireLearntSkill)) { RPGMakerGUI.PopupID <Skill>("- Skill:", ref quest.Requirements.LearntSkillID); } RPGMakerGUI.EndFoldout(); } var result = RPGMakerGUI.FoldoutToolBar(ref showSelectedQuestMainConditions, "Quest Conditions", "+Condition", false, false); if (showSelectedQuestMainConditions) { if (quest.Conditions.Count == 0) { EditorGUILayout.HelpBox("Click +Condition to add a new quest condition.", MessageType.Info); } for (int index = 0; index < quest.Conditions.Count; index++) { GUILayout.BeginVertical("foldoutBox"); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (index > 0 && GUILayout.Button("Move Up", "genericButton")) { GUI.FocusControl(""); var curCondition = quest.Conditions[index]; var prevCondition = quest.Conditions[index - 1]; quest.Conditions[index - 1] = curCondition; quest.Conditions[index] = prevCondition; return; } if (index < quest.Conditions.Count - 1 && GUILayout.Button("Move Down", "genericButton")) { GUI.FocusControl(""); var curCondition = quest.Conditions[index]; var nextCondition = quest.Conditions[index + 1]; quest.Conditions[index + 1] = curCondition; quest.Conditions[index] = nextCondition; return; } GUILayout.EndHorizontal(); quest.Conditions[index] = ShowConditionInfo(quest.Conditions[index]); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Delete", "genericButton", GUILayout.Height(25), GUILayout.Width(100))) { GUI.FocusControl(""); quest.Conditions.RemoveAt(index); index--; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } if (result == 0) { quest.Conditions.Add(new KillCondition()); } RPGMakerGUI.EndFoldout(); } if (RPGMakerGUI.Foldout(ref showFinalCondition, "Final Condition")) { if (RPGMakerGUI.Toggle("Enable Final Condition?", ref quest.HasFinalCondition)) { quest.FinalCondition = ShowConditionInfo(quest.FinalCondition); } RPGMakerGUI.EndFoldout(); } if (RPGMakerGUI.Foldout(ref showBonusCondition, "Bonus Condition")) { if (RPGMakerGUI.Toggle("Enable Bonus Condition?", ref quest.HasBonusCondition)) { quest.BonusCondition = ShowConditionInfo(quest.BonusCondition); if (RPGMakerGUI.Toggle("- Has Time Limit", ref quest.BonusHasTimeLimit)) { quest.BonusTimeLimit = RPGMakerGUI.FloatField(" - Time Limit:", quest.BonusTimeLimit); } } RPGMakerGUI.EndFoldout(); } if (RPGMakerGUI.Foldout(ref showQuestRewards, "Rewards")) { ShowQuestRewardInfo(ref showQuestMainRewards, "Item Rewards", quest.Rewards); RPGMakerGUI.EndFoldout(); } if (quest.HasBonusCondition) { if (RPGMakerGUI.Foldout(ref showBonusRewards, "Bonus Rewards")) { ShowQuestRewardInfo(ref showQuestBonusRewards, "Bonus Condition Reward", quest.BonusRewards); RPGMakerGUI.EndFoldout(); } } RPGMakerGUI.FoldoutList(ref showCustomVarSetters, "Set Custom Vars on Completion", quest.SetCustomVariablesOnCompletion, Rm_RPGHandler.Instance.DefinedVariables.Vars, "+VariableSetter", "", "Click +VariableSetter to add a varaible setter", "VariableID", "Name", "ID", "Name"); }
private static QuestCondition ShowConditionInfo(QuestCondition condition) { var oldtype = condition.ConditionType; condition.ConditionType = (ConditionType)RPGMakerGUI.EnumPopup("Condition Type:", condition.ConditionType); if (condition.ConditionType != oldtype) { //TODO: if no longer interact node tree than delete that node tree switch (condition.ConditionType) { case ConditionType.Kill: condition = new KillCondition(); break; case ConditionType.Item: condition = new ItemCondition(); break; case ConditionType.Interact: condition = new InteractCondition(); break; case ConditionType.Deliver: condition = new DeliverCondition(); break; case ConditionType.Custom: condition = new CustomCondition(); break; default: throw new ArgumentOutOfRangeException(); } } var killCondition = condition as KillCondition; var itemCondition = condition as ItemCondition; var interactCondition = condition as InteractCondition; var deliverCondition = condition as DeliverCondition; var customCondition = condition as CustomCondition; if (killCondition != null) { if (Rm_RPGHandler.Instance.Combat.NPCsCanFight && Rm_RPGHandler.Instance.Combat.CanAttackNPcs) { RPGMakerGUI.Toggle("Is NPC?", ref killCondition.IsNPC); } else { killCondition.IsNPC = false; } if (killCondition.IsNPC) { RPGMakerGUI.PopupID <NonPlayerCharacter>("NPC to Kill:", ref killCondition.CombatantID); } else { RPGMakerGUI.PopupID <CombatCharacter>("Enemy to Kill:", ref killCondition.CombatantID); } killCondition.NumberToKill = RPGMakerGUI.IntField("Number To Kill:", killCondition.NumberToKill); } if (itemCondition != null) { itemCondition.ItemType = (ItemConditionType)RPGMakerGUI.EnumPopup("Required Item Type:", itemCondition.ItemType); if (itemCondition.ItemType == ItemConditionType.CraftItem) { RPGMakerGUI.PopupID <Item>("CraftItem To Collect:", ref itemCondition.ItemToCollectID, "ID", "Name", "Craft"); } else if (itemCondition.ItemType == ItemConditionType.QuestItem) { RPGMakerGUI.PopupID <Item>("Quest Item To Collect:", ref itemCondition.ItemToCollectID, "ID", "Name", "Quest"); if (Rm_RPGHandler.Instance.Combat.NPCsCanFight && Rm_RPGHandler.Instance.Combat.CanAttackNPcs) { RPGMakerGUI.Toggle("NPC Drops Items?", ref itemCondition.NPCDropsItem); } else { itemCondition.NPCDropsItem = false; } if (itemCondition.NPCDropsItem) { RPGMakerGUI.PopupID <NonPlayerCharacter>("NPC that Drops Item:", ref itemCondition.CombatantIDThatDropsItem); } else { RPGMakerGUI.PopupID <CombatCharacter>("Enemy that Drops Item:", ref itemCondition.CombatantIDThatDropsItem); } } else if (itemCondition.ItemType == ItemConditionType.Item) { RPGMakerGUI.PopupID <Item>("Item To Collect:", ref itemCondition.ItemToCollectID); } itemCondition.NumberToObtain = RPGMakerGUI.IntField("Number To Obtain:", itemCondition.NumberToObtain); } if (interactCondition != null) { if (RPGMakerGUI.Toggle("Talk to NPC?", ref interactCondition.IsNpc)) { RPGMakerGUI.PopupID <NonPlayerCharacter>("NPC to talk to:", ref interactCondition.InteractableID); } else { RPGMakerGUI.PopupID <Interactable>("Object to interact with:", ref interactCondition.InteractableID); } if (GUILayout.Button("Open Interaction Node Tree", "genericButton", GUILayout.MaxHeight(30))) { var trees = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees; var existingTree = trees.FirstOrDefault(t => t.ID == interactCondition.InteractionNodeTreeID); if (existingTree == null) { existingTree = NodeWindow.GetNewTree(NodeTreeType.Dialog); Debug.Log("ExistingTree null? " + existingTree == null); existingTree.ID = interactCondition.ID; Debug.Log(existingTree.ID + ":::" + existingTree.Name); var curSelectedQuest = Rme_Main.Window.CurrentPageIndex == 1 ? selectedQuestChainQuest : selectedQuest; //todo: need unique name existingTree.Name = curSelectedQuest.Name + "Interact"; trees.Add(existingTree); } DialogNodeWindow.ShowWindow(interactCondition.ID); interactCondition.InteractionNodeTreeID = existingTree.ID; } } if (deliverCondition != null) { RPGMakerGUI.PopupID <Item>("Quest Item To Deliver:", ref deliverCondition.ItemToDeliverID, "ID", "Name", "Quest"); if (RPGMakerGUI.Toggle("Deliver to NPC?", ref deliverCondition.DeliverToNPC)) { RPGMakerGUI.PopupID <NonPlayerCharacter>("NPC to deliver to:", ref deliverCondition.InteractableToDeliverToID); } else { RPGMakerGUI.PopupID <Interactable>("Object to deliver with:", ref deliverCondition.InteractableToDeliverToID); } if (GUILayout.Button("Open Interaction On Deliver", "genericButton", GUILayout.MaxHeight(30))) { var trees = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees; var existingTree = trees.FirstOrDefault(t => t.ID == deliverCondition.InteractionNodeTreeID); if (existingTree == null) { existingTree = NodeWindow.GetNewTree(NodeTreeType.Dialog); existingTree.ID = deliverCondition.ID; //todo: need unique name var curSelectedQuest = Rme_Main.Window.CurrentPageIndex == 1 ? selectedQuestChainQuest : selectedQuest; existingTree.Name = curSelectedQuest.Name + "Interact"; trees.Add(existingTree); } DialogNodeWindow.ShowWindow(deliverCondition.ID); deliverCondition.InteractionNodeTreeID = existingTree.ID; } } if (customCondition != null) { var customVar = customCondition.CustomVariableRequirement; RPGMakerGUI.PopupID <Rmh_CustomVariable>("Custom Variable:", ref customVar.VariableID); var foundCvar = Rm_RPGHandler.Instance.DefinedVariables.Vars.FirstOrDefault(v => v.ID == customCondition.CustomVariableRequirement.VariableID); if (foundCvar != null) { switch (foundCvar.VariableType) { case Rmh_CustomVariableType.Float: customVar.FloatValue = RPGMakerGUI.FloatField("Required Value:", customVar.FloatValue); break; case Rmh_CustomVariableType.Int: customVar.IntValue = RPGMakerGUI.IntField("Required Value:", customVar.IntValue); break; case Rmh_CustomVariableType.String: customVar.StringValue = RPGMakerGUI.TextField("Required Value:", customVar.StringValue); break; case Rmh_CustomVariableType.Bool: selectedVarSetterBoolResult = customVar.BoolValue ? 0 : 1; selectedVarSetterBoolResult = EditorGUILayout.Popup("Required Value:", selectedVarSetterBoolResult, new[] { "True", "False" }); customVar.BoolValue = selectedVarSetterBoolResult == 0; break; default: throw new ArgumentOutOfRangeException(); } } } if (condition.ConditionType != ConditionType.Custom) { RPGMakerGUI.Toggle("Use Custom Tracking Text:", ref condition.UseCustomText); } else { condition.UseCustomText = true; } if (condition.UseCustomText) { condition.CustomText = RPGMakerGUI.TextField("Custom Incomplete Text:", condition.CustomText); condition.CustomCompletedText = RPGMakerGUI.TextField("Custom Completed Text:", condition.CustomCompletedText); } GUILayout.Space(5); return(condition); }
static void Init() { NodeWindow window = (NodeWindow)EditorWindow.GetWindow(typeof(NodeWindow)); window.Show(); }
public static void NPCs(Rect fullArea, Rect leftArea, Rect mainArea) { var list = Rm_RPGHandler.Instance.Repositories.Interactable.AllNpcs; GUI.Box(leftArea, "", "backgroundBox"); GUI.Box(mainArea, "", "backgroundBoxMain"); GUILayout.BeginArea(PadRect(leftArea, 0, 0)); RPGMakerGUI.ListArea(list, ref selectedNPCInfo, Rm_ListAreaType.NPCs, false, true); GUILayout.EndArea(); GUILayout.BeginArea(mainArea); RPGMakerGUI.Title("NPCs"); if (selectedCharInfo != null) { RPGMakerGUI.BeginScrollView(); if (RPGMakerGUI.Foldout(ref mainInfoFoldout, "Main Info")) { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(GUILayout.MaxWidth(85)); selectedCharInfo.Image = RPGMakerGUI.ImageSelector("", selectedCharInfo.Image, ref selectedCharInfo.ImagePath); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.ExpandWidth(true)); RPGMakerGUI.TextField("ID: ", selectedCharInfo.ID); selectedCharInfo.Name = RPGMakerGUI.TextField("Name: ", selectedCharInfo.Name); GUILayout.BeginHorizontal(); gameObject = RPGMakerGUI.PrefabSelector("NPC Prefab:", gameObject, ref selectedCharInfo.CharPrefabPath); gameObject = RPGMakerGUI.PrefabGeneratorButton(Rmh_PrefabType.NPC, gameObject, ref selectedCharInfo.CharPrefabPath, null, selectedCharInfo.ID); GUILayout.EndHorizontal(); if (GUILayout.Button("Open Interaction Window", "genericButton", GUILayout.MaxHeight(30))) { var trees = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees; var existingTree = trees.FirstOrDefault(t => t.ID == selectedCharInfo.ID); if (existingTree == null) { existingTree = NodeWindow.GetNewTree(NodeTreeType.Dialog); existingTree.ID = selectedCharInfo.ID; existingTree.Name = selectedCharInfo.Name; trees.Add(existingTree); } DialogNodeWindow.ShowWindow(selectedCharInfo.ID); selectedNPCInfo.Interaction.ConversationNodeId = existingTree.ID; } if (Rm_RPGHandler.Instance.Combat.NPCsCanFight) { if (RPGMakerGUI.Toggle("This NPC Can Fight?", ref selectedNPCInfo.CanFight)) { selectedNPCInfo.CanBeKilled = RPGMakerGUI.Toggle("Can be Perma-killed? ", selectedNPCInfo.CanBeKilled); Rme_Combatants.CombatantDetails(selectedNPCInfo); } } GUILayout.Space(5); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } if (mainInfoFoldout) { RPGMakerGUI.EndFoldout(); } Rme_Combatants.Animations(selectedNPCInfo); if (Rm_RPGHandler.Instance.Combat.NPCsCanFight && selectedNPCInfo.CanFight) { Rme_Combatants.CombatStats(selectedNPCInfo); Rme_Combatants.Loot(selectedNPCInfo); } RPGMakerGUI.EndScrollView(); } else { EditorGUILayout.HelpBox("Add or select a new field to customise Enemy Characters.", MessageType.Info); } GUILayout.EndArea(); }
public void Init( EditorWindow window ) { // Load in texture resources m_lineTexture = ( Texture2D )Resources.Load( "Line Texture 2" ); m_arrowTexture = ( Texture2D )Resources.Load( "ArrowHead" ); m_icons = new Texture2D[6]; m_icons[0] = (Texture2D)Resources.Load("Icon - StateMachine"); m_icons[1] = (Texture2D)Resources.Load("Icon - BlendGraph"); m_icons[2] = (Texture2D)Resources.Load("Icon - Animation"); m_icons[3] = (Texture2D)Resources.Load("Icon - Blend"); m_icons[4] = (Texture2D)Resources.Load("Icon - AddBlend"); m_icons[5] = (Texture2D)Resources.Load("Icon - Pose"); // Init editor to safe state m_editorWindow = window; m_selectedAnimationTree = null; m_Windows.Clear(); m_activeContainer = null; ActiveWindow = null; Dragging = false; ConnectionStart = null; ConnectionEnd = null; m_camerScaleAmount = new Vector2(1, 1); // Find all the enabled animation trees m_activeAnimationTrees = GameObject.FindObjectsOfType(typeof(AnimationTree)) as AnimationTree[]; }