public void CreateNode(Vector2 position, NodePrefabInfos infos) { int index = 0; while (_nodes.ContainsKey(index)) { index++; } Node n = Instantiate(nodePrefab); n.Editor = this; n.transform.SetParent(modelZone.transform); n.transform.localPosition = position; n.transform.localScale = Vector2.one; NodeInfos i = new NodeInfos(); i.id = index; i.posX = position.x; i.posY = position.y; n.NodeInfos = i; n.NodePrefabInfos = infos; n.NodeInfos.type = infos.nodeName; _nodes.Add(i.id, n); }
private void Awake() { //ici on crée les prefabs par defauts, a terme ca doit sortir NodePrefabInfos prefabStart = new NodePrefabInfos(); prefabStart.nodeName = "Start"; prefabStart.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, "StartOutput")); prefabStart.visible = false; prefabs.Add(prefabStart.nodeName, prefabStart); NodePrefabInfos prefabEnd = new NodePrefabInfos(); prefabEnd.nodeName = "End"; prefabEnd.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamIn, "EndInput")); prefabs.Add(prefabEnd.nodeName, prefabEnd); NodePrefabInfos prefabStationSelector = new NodePrefabInfos(); prefabStationSelector.nodeName = "Hangar selector"; prefabStationSelector.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamHangar, ParamInfos.ParamDirection.ParamOut, "station")); prefabs.Add(prefabStationSelector.nodeName, prefabStationSelector); NodePrefabInfos prefabExplore = new NodePrefabInfos(); prefabExplore.nodeName = "Explore"; prefabExplore.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamIn, "ExploreInput")); prefabExplore.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, "ExploreOutput")); prefabs.Add(prefabExplore.nodeName, prefabExplore); NodePrefabInfos prefabMoveTo = new NodePrefabInfos(); prefabMoveTo.nodeName = "Move To"; prefabMoveTo.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamIn, "MoveInput")); prefabMoveTo.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamHangar, ParamInfos.ParamDirection.ParamIn, "Station")); prefabMoveTo.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, "MoveOutput")); prefabs.Add(prefabMoveTo.nodeName, prefabMoveTo); if (readOnly) { RectTransform r = prefabZone.GetComponent <RectTransform>(); r.sizeDelta = Vector2.zero; r = GetComponentInChildren <ScrollRect>().GetComponentInChildren <RectTransform>(); r.anchoredPosition = Vector2.zero; r.sizeDelta = Vector2.zero; } else { foreach (NodePrefabInfos i in prefabs.Values) { CreateNodePrefab(i); } CreateNode(Vector2.zero, prefabs["Start"]); } detailZone.gameObject.SetActive(false); }
private void CreateNodePrefab(NodePrefabInfos infos) { if (infos.visible) { NodeType nodeType = Instantiate <NodeType>(nodeTypePrefab, prefabZone); nodeType.GetComponentInChildren <Text>().text = infos.nodeName; nodeType.infos = infos; nodeType.name = infos.nodeName; } }
private void Awake() { //ici on crée les prefabs par defauts, a terme ca doit sortir NodePrefabInfos prefabStart = new NodePrefabInfos(); prefabStart.nodeName = "Start"; prefabStart.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param1_1, "StartOutput")); prefabStart.visible = false; prefabs.Add(prefabStart.nodeName, prefabStart); NodePrefabInfos prefabEnd = new NodePrefabInfos(); prefabEnd.nodeName = "End"; prefabEnd.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param0_N, "EndInput")); prefabs.Add(prefabEnd.nodeName, prefabEnd); NodePrefabInfos prefabStationSelector = new NodePrefabInfos(); prefabStationSelector.nodeName = "Hangar selector"; prefabStationSelector.Configs.Add("hangarID", "Hangars"); prefabStationSelector.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamHangar, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param0_N, "station")); prefabs.Add(prefabStationSelector.nodeName, prefabStationSelector); NodePrefabInfos prefabExplore = new NodePrefabInfos(); prefabExplore.nodeName = "Explore"; prefabExplore.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param1_N, "ExploreInput")); prefabExplore.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param1_1, "ExploreOutput")); prefabExplore.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamBookmark, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param0_N, "FoundLocation")); prefabExplore.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamBoolean, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param0_N, "FoundSomtingh")); prefabs.Add(prefabExplore.nodeName, prefabExplore); NodePrefabInfos prefabMine = new NodePrefabInfos(); prefabMine.nodeName = "Mine"; prefabMine.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param1_N, MineNode.InFlow)); prefabMine.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamBookmark, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param1_1, MineNode.Bookmark)); prefabMine.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param1_1, MineNode.OutFlow)); prefabs.Add(prefabMine.nodeName, prefabMine); NodePrefabInfos prefabMoveTo = new NodePrefabInfos(); prefabMoveTo.nodeName = "Move To"; prefabMoveTo.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param1_N, "MoveInput")); prefabMoveTo.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamHangar, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param1_1, "Station")); prefabMoveTo.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param1_1, "MoveOutput")); prefabs.Add(prefabMoveTo.nodeName, prefabMoveTo); NodePrefabInfos prefabIf = new NodePrefabInfos(); prefabIf.nodeName = "If"; prefabIf.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param1_N, IfNode.InFlow)); prefabIf.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamBoolean, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param1_1, IfNode.TestValue)); prefabIf.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param1_1, IfNode.OutFlowTrue)); prefabIf.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param1_1, IfNode.OutFlowFalse)); prefabs.Add(prefabIf.nodeName, prefabIf); NodePrefabInfos prefabLoop = new NodePrefabInfos(); prefabLoop.nodeName = "Loop"; prefabLoop.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param1_N, "FlowIn")); prefabLoop.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param1_1, "FlowOutRepeat")); prefabLoop.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamFlow, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param1_1, "FlowOutEnd")); prefabs.Add(prefabLoop.nodeName, prefabLoop); NodePrefabInfos prefabNotNull = new NodePrefabInfos(); prefabNotNull.nodeName = "NotNull"; prefabNotNull.inputs.Add(new ParamInfos(ParamInfos.ParamType.ParamBookmark, ParamInfos.ParamDirection.ParamIn, ParamInfos.ParamConnectType.Param1_N, NotNull.InputParam)); prefabNotNull.outputs.Add(new ParamInfos(ParamInfos.ParamType.ParamBoolean, ParamInfos.ParamDirection.ParamOut, ParamInfos.ParamConnectType.Param1_1, NotNull.OutputParam)); prefabs.Add(prefabNotNull.nodeName, prefabNotNull); if (readOnly) { transform.Find("PrefabZone").gameObject.SetActive(false); RectTransform r = transform.Find("Scroll View").GetComponent <RectTransform>(); r.offsetMin = Vector2.zero; r.offsetMax = Vector2.zero; } else { foreach (NodePrefabInfos i in prefabs.Values) { CreateNodePrefab(i); } CreateNode(Vector2.zero, prefabs["Start"]); } detailZone.gameObject.SetActive(false); }