public override void OnInspectorGUI() { MapInterpreterBehaviour t = (MapInterpreterBehaviour)target; if (g == null) { g = t.gameObject.GetComponent <GeneratorBehaviour>(); } if (p == null) { p = t.gameObject.GetComponent <PhysicalMapBehaviour>(); } if (v == null) { v = t.gameObject.GetComponent <VirtualMapGeneratorBehaviour>(); } t.drawRocks = EditorGUILayout.Toggle("Draw Rocks", t.drawRocks); t.drawWallCorners = EditorGUILayout.Toggle("Draw Wall Corners", t.drawWallCorners); t.drawDoors = EditorGUILayout.Toggle("Place Doors in Passages", t.drawDoors); if (v != null && v.HasRooms) { t.createColumnsInRooms = EditorGUILayout.Toggle("Draw Columns in Rooms", t.createColumnsInRooms); } t.useDirectionalFloors = EditorGUILayout.Toggle("Use Directional Floors", t.useDirectionalFloors); if (t.useDirectionalFloors) { t.randomOrientations = false; } else { t.randomOrientations = EditorGUILayout.Toggle("Randomize Orientations", t.randomOrientations); } if (t.useDirectionalFloors) { t.isolateDirectionalWallsForRooms = EditorGUILayout.Toggle(new GUIContent("Isolate Rooms", "If enabled, room corners will be isolated from the rest of the dungeon."), t.isolateDirectionalWallsForRooms); } t.usePerimeter = EditorGUILayout.Toggle("Use Perimeter Walls", t.usePerimeter); // if (t.usePerimeter) t.internalPerimeter =EditorGUILayout.Toggle("Internal Perimeter",t.internalPerimeter); if (g.mapDimensionsType == MapDimensionsType.THREE_DEE) { t.addCeilingToCorridors = EditorGUILayout.Toggle("Add Ceiling to Corridors", t.addCeilingToCorridors); if (v.HasRooms) { t.addCeilingToRooms = EditorGUILayout.Toggle("Add Ceiling To Rooms", t.addCeilingToRooms); } } }
public override void OnInspectorGUI() { PhysicalMapBehaviour t = (PhysicalMapBehaviour)target; if (g == null) { g = t.gameObject.GetComponent <GeneratorBehaviour>(); } if (i == null) { i = t.gameObject.GetComponent <MapInterpreterBehaviour>(); } if (v == null) { v = t.gameObject.GetComponent <VirtualMapGeneratorBehaviour>(); } if (v.createStartAndEnd) { t.createEntranceAndExit = EditorGUILayout.Toggle("Add Entrance and Exit", t.createEntranceAndExit); if (t.createEntranceAndExit) { // EditorGUILayout.BeginHorizontal(); t.createPlayer = EditorGUILayout.Toggle("Add Player", t.createPlayer); if (t.createPlayer) { t.playerPrefab = EditorGUILayout.ObjectField("Player Prefab", t.playerPrefab, typeof(GameObject), true) as GameObject; } // EditorGUILayout.EndHorizontal(); } } if (!t.AutomaticBatching) { t.enabledBatching = EditorGUILayout.Toggle("Perform Batching", t.enabledBatching); } if (!t.AutomaticOrientation && !t.ForcedOrientation) { t.mapPlaneOrientation = (MapPlaneOrientation)EditorGUILayout.EnumPopup("Orientation", t.mapPlaneOrientation); } }
public override void OnInspectorGUI() { errorStyle = new GUIStyle(); errorStyle.normal.textColor = Color.red; GeneratorBehaviour t = (GeneratorBehaviour)target; PhysicalMapBehaviour physicalMapBehaviour = t.gameObject.GetComponent <PhysicalMapBehaviour>(); MapInterpreterBehaviour interpreterBehaviour = t.gameObject.GetComponent <MapInterpreterBehaviour>(); VirtualMapGeneratorBehaviour vmapGeneratorBehaviour = t.gameObject.GetComponent <VirtualMapGeneratorBehaviour>(); targetInstance = t; t.mapDimensionsType = (MapDimensionsType)EditorGUILayout.EnumPopup("Map Dimensions Type", t.mapDimensionsType); t.MapWidth = EditorGUILayout.IntSlider("Map Width", t.MapWidth, 2, GeneratorBehaviour.MAX_SIZE); t.MapHeight = EditorGUILayout.IntSlider("Map Length", t.MapHeight, 2, GeneratorBehaviour.MAX_SIZE); EditorGUILayout.BeginHorizontal(); t.useSeed = EditorGUILayout.Toggle("Use seed", t.useSeed); EditorGUI.BeginDisabledGroup(t.useSeed == false); t.seed = EditorGUILayout.IntSlider("Seed", t.seed, 0, 10000); EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); if (t.mapDimensionsType == MapDimensionsType.THREE_DEE) { t.multiStorey = EditorGUILayout.Toggle("Multi-Storey", t.multiStorey); if (t.multiStorey) { t.numberOfStoreys = EditorGUILayout.IntSlider("Number of Storeys", t.numberOfStoreys, 1, 10); } else { t.numberOfStoreys = 1; } } else { t.multiStorey = false; t.numberOfStoreys = 1; } this.showAdvanced = EditorGUILayout.Foldout(this.showAdvanced, "Advanced Options"); if (this.showAdvanced) { GUILayout.BeginHorizontal(); t.printTimings = EditorGUILayout.Toggle("Print Timings", t.printTimings); GUILayout.EndHorizontal(); EditorGUILayout.LabelField("Last used seed: " + t.lastUsedSeed); showDebugCoordinates = EditorGUILayout.Toggle("Show Debug Coordinates", showDebugCoordinates); showDebugConnections = EditorGUILayout.Toggle("Show Debug Connections", showDebugConnections); } EditorGUI.BeginDisabledGroup(Application.isPlaying == true); bool canGenerate = true; if (vmapGeneratorBehaviour == null) { GUILayout.Label("Attach a Virtual Map Generator Behaviour to enable generation!", errorStyle); canGenerate = false; } if (physicalMapBehaviour == null) { GUILayout.Label("Attach a Physical Map Behaviour to enable generation!", errorStyle); canGenerate = false; } else if (t.mapDimensionsType == MapDimensionsType.THREE_DEE && !physicalMapBehaviour.SupportsThreeDeeMap) { GUILayout.Label("The attached Physical Map Behaviour does not support a 3D map!", errorStyle); canGenerate = false; } if (interpreterBehaviour == null) { GUILayout.Label("Attach a Map Interpreter Behaviour to enable generation!", errorStyle); canGenerate = false; } EditorGUI.BeginDisabledGroup(!canGenerate); if (GUILayout.Button("Generate!")) { t.Generate(); } EditorGUI.EndDisabledGroup(); #region Save/Load buttons EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Save")) { SavePrefab(); } EditorGUILayout.EndHorizontal(); #endregion EditorGUI.EndDisabledGroup(); }
public void Generate() { isCurrentlyGenerating = true; // Make sure we have a VirtualMapGeneratorBheaviour component virtualMapGeneratorBehaviour = gameObject.GetComponent <VirtualMapGeneratorBehaviour>(); if (virtualMapGeneratorBehaviour == null) { Debug.LogError("You need to attach a VirtualMapGeneratorBehaviour to this gameObject to enable generation!", this); return; } // Make sure we have a PhysicalMapBehaviour component physicalMapBehaviour = gameObject.GetComponent <PhysicalMapBehaviour>(); if (physicalMapBehaviour == null) { Debug.LogError("You need to attach a PhysicalMapBehaviour to this gameObject to enable generation!", this); return; } // Make sure we have a MapInterpreterBehaviour component interpreterBehaviour = gameObject.GetComponent <MapInterpreterBehaviour>(); if (interpreterBehaviour == null) { Debug.LogError("You need to attach a MapInterpreterBehaviour to this gameObject to enable generation!", this); return; } // Remove the existing map if (rootMapGo != null) { if (physicalMap != null) { physicalMap.CleanUp(); DestroyImmediate(physicalMap); } if (Application.isPlaying) { Destroy(rootMapGo); } else { DestroyImmediate(rootMapGo); } virtualMaps = null; physicalMap = null; } // Remove any other existing children as well foreach (Transform childTr in this.transform) { DestroyImmediate(childTr.gameObject); } if (printTimings) { preDate = System.DateTime.Now; } if (!ForceCommonSenseOptions()) { return; } physicalMapBehaviour.MeasureSizes(); SetGeneratorValues(); virtualMapGeneratorBehaviour.Initialise(); lastUsedSeed = virtualMapGeneratorBehaviour.InitialiseSeed(useSeed, seed); virtualMaps = virtualMapGeneratorBehaviour.GenerateAllMaps(MapWidth, MapHeight, numberOfStoreys); mapInterpreter = interpreterBehaviour.Generate(); physicalMap = physicalMapBehaviour.Generate(virtualMaps, this, mapInterpreter); this.rootMapGo = physicalMap.rootMapGo; if (printTimings) { postDate = System.DateTime.Now; TimeSpan timeDifference = postDate.Subtract(preDate); Debug.Log("Generated in " + timeDifference.TotalMilliseconds.ToString() + " ms"); } BroadcastMessage("DungeonGenerated", SendMessageOptions.DontRequireReceiver); isCurrentlyGenerating = false; }
protected void DrawSpecificInspector(SerializedObject m_Object) { PhysicalMapBehaviour t = (PhysicalMapBehaviour)target; if (i == null) { return; } if (!i.useDirectionalFloors) { EditorGUILayout.PropertyField(m_Object.FindProperty("corridorFloorVariations"), true); } else { EditorGUILayout.PropertyField(m_Object.FindProperty("corridorFloorUVariations"), new GUIContent("Corridor Floor U Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorFloorIVariations"), new GUIContent("Corridor Floor I Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorFloorLVariations"), new GUIContent("Corridor Floor L Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorFloorTVariations"), new GUIContent("Corridor Floor T Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorFloorXVariations"), new GUIContent("Corridor Floor X Variations"), true); } if (!i.useDirectionalFloors) { EditorGUILayout.PropertyField(m_Object.FindProperty("corridorWallVariations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorColumnVariations"), true); } else { EditorGUILayout.PropertyField(m_Object.FindProperty("corridorWallOVariations"), new GUIContent("Corridor Wall O Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorWallUVariations"), new GUIContent("Corridor Wall U Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorWallIVariations"), new GUIContent("Corridor Wall I Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorWallLVariations"), new GUIContent("Corridor Wall L Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorWallTVariations"), new GUIContent("Corridor Wall T Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("corridorWallXVariations"), new GUIContent("Corridor Wall X Variations"), true); } if (v.HasRooms) { if (!i.useDirectionalFloors) { EditorGUILayout.PropertyField(m_Object.FindProperty("roomFloorVariations"), true); } else { EditorGUILayout.PropertyField(m_Object.FindProperty("roomFloorInsideVariations"), new GUIContent("Room Floor Inside Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("roomFloorBorderVariations"), new GUIContent("Room Floor Border Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("roomFloorCornerVariations"), new GUIContent("Room Floor Corner Variations"), true); } if (!i.useDirectionalFloors) { EditorGUILayout.PropertyField(m_Object.FindProperty("roomWallVariations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("roomColumnVariations"), true); } else { EditorGUILayout.PropertyField(m_Object.FindProperty("roomWallOVariations"), new GUIContent("Room Wall O Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("roomWallUVariations"), new GUIContent("Room Wall U Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("roomWallIVariations"), new GUIContent("Room Wall I Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("roomWallLVariations"), new GUIContent("Room Wall L Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("roomWallTVariations"), new GUIContent("Room Wall T Variations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("roomWallXVariations"), new GUIContent("Room Wall X Variations"), true); } if (i.createColumnsInRooms) { EditorGUILayout.PropertyField(m_Object.FindProperty("insideRoomColumnVariations"), true); } if (i.drawDoors) { EditorGUILayout.PropertyField(m_Object.FindProperty("doorVariations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("roomDoorVariations"), true); } EditorGUILayout.PropertyField(m_Object.FindProperty("passageColumnVariations"), true); } if (i.drawRocks) { EditorGUILayout.PropertyField(m_Object.FindProperty("rockVariations"), true); } if (t.createEntranceAndExit) { EditorGUILayout.PropertyField(m_Object.FindProperty("entrancePrefab"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("exitPrefab"), true); } if (i.usePerimeter) { EditorGUILayout.PropertyField(m_Object.FindProperty("perimeterWallVariations"), true); EditorGUILayout.PropertyField(m_Object.FindProperty("perimeterColumnVariations"), true); } }