//public AudioClip bgMusic; public GameWorldState(GamePanel gamePanel, GameTime time) : base(gamePanel, time) { texts1[0] = "We are heros, and our mission is protecting our Home\nEarth...."; texts1[1] = "There was a Monster from University on Earth in 10 years\n" + "and we lived in the scare in that 10 years...."; texts1[2] = "Now is the time for us, kill it and get freedom!...."; texts1[3] = " LET'S GO!....."; textTutorial = texts1[0]; bufferedImage = new Bitmap(GameFrame.SCREEN_WIDTH, GameFrame.SCREEN_HEIGHT); megaMan = new MegaMan(400, 400, this); physicalMap = new PhysicalMap(0, 0, this); backgroundMap = new BackgroundMap(0, 0, this); camera = new Camera(0, 50, GameFrame.SCREEN_WIDTH, GameFrame.SCREEN_HEIGHT, this); bulletManager = new BulletManager(this); particularObjectManager = new ParticularObjectManager(this); particularObjectManager.addObject(megaMan); initEnemies(); //bgMusic = CacheDataLoader.getInstance().getSound("bgmusic"); previousState = state; }
public void DungeonGenerated() { Debug.Log("Dungeon has been generated!"); // Place the trigger for regeneration at the exit PhysicalMap physicalMap = this.generator.GetPhysicalMap(); // Get the end position Vector3 endPos = physicalMap.GetEndPosition(); // Create and place the exit trigger GameObject exitTrigger = new GameObject("ExitTrigger"); exitTrigger.transform.parent = physicalMap.dynamicMapTr; exitTrigger.transform.position = endPos; // Add a box trigger to it BoxCollider coll = exitTrigger.AddComponent <BoxCollider>(); coll.size = new Vector3(5, 5, 5); coll.isTrigger = true; // Make it regenerate the map exitTrigger.AddComponent <RegenerateDungeonTriggerBehaviour>().runtimeGenerator = this; }
public void Clear() { PhysicalMap physicalMap = generator.physicalMap; if (physicalMap == null) { return; } foreach (SelectionObjectType sot in System.Enum.GetValues(typeof(SelectionObjectType)).Cast <SelectionObjectType>()) { ClearList(physicalMap, sot); } }
void Update() { if (Input.GetMouseButtonDown(0)) { /*physical = mapObject.GetComponent<PhysicalMap>(); * physical.init(xSize, ySize); * HeightMapGenerator hgen = new HeightMapGenerator(); * Heightmap heightmap = hgen.generateMap(xSize, ySize); * WaterMap watermap = new WaterMap(heightmap); * terrainmap = new TerrainMap(heightmap, watermap); * temperaturemap = new TemperatureMap(terrainmap, Random.Range(0, 11)); * tr = new TemperatureRenderer(new LandmassMap(terrainmap), temperaturemap); * physical.draw(tr);*/ physical = mapObject.GetComponent <PhysicalMap>(); physical.init(xSize, ySize); MapSerializable mser = MapSerializable.loadFromFile("testHM"); Heightmap heightmap = new Heightmap(xSize, ySize, 0.5f, mser.grid); WaterMap watermap = new WaterMap(heightmap); terrainmap = new TerrainMap(heightmap, watermap); mser = MapSerializable.loadFromFile("testTM"); temperaturemap = new TemperatureMap(xSize, ySize, mser.grid, terrainmap); tr = new TemperatureRenderer(new LandmassMap(terrainmap), temperaturemap); physical.draw(tr); } if (Input.GetMouseButtonDown(1)) { if (state == 0) { RecursiveWindGenerator wgen = new RecursiveWindGenerator(temperaturemap); wm = new WindMap(xSize, ySize, terrainmap, temperaturemap, 3); WindSpeedRenderer wsr = new WindSpeedRenderer(wm, new LandmassMap(terrainmap)); WindDirectionRenderer wdr = new WindDirectionRenderer(wm, new LandmassMap(terrainmap)); physical.draw(wsr); state++; } else if (state >= 1) { RecursiveWindGenerator wgen = new RecursiveWindGenerator(temperaturemap); wm = new WindMap(xSize, ySize, terrainmap, temperaturemap, state); WindSpeedRenderer wsr = new WindSpeedRenderer(wm, new LandmassMap(terrainmap)); WindDirectionRenderer wdr = new WindDirectionRenderer(wm, new LandmassMap(terrainmap)); physical.draw(wdr); state++; } } }
void Update() { PhysicalMap physicalMap = generator.physicalMap; if (physicalMap == null) { return; } string s = "Map dimensions:"; foreach (VirtualMap.Dimensions dim in physicalMap.GetMapDimensions()) { s += "\nStorey " + dim.storey + " L: " + dim.left + " R: " + dim.right + " B: " + dim.bottom + " T: " + dim.top + " DIM X: " + dim.width_x + " DIM Y: " + dim.width_y; } Debug.Log(s); }
private List <GameObject> SelectInternal(PhysicalMap physicalMap, SelectionObjectType type) { if (physicalMap == null) { Debug.Log("NO PHYSICAL MAP!"); return(null); } DaedalusDebugUtils.Assert(physicalMap.gameObjectLists != null, "Physical map's game object lists are null!"); List <GameObject> list = physicalMap.GetObjectsOfType(type) as List <GameObject>; if (list.Count == 0) { Debug.Log("NO ITEMS!"); return(list); } if (OVERRIDE_MATERIALS) { Material currentMat = list[0].GetComponentsInChildren <MeshRenderer>()[0].sharedMaterial; if (originalMaterials.ContainsKey(type) && originalMaterials[type] != null) { // Already selected! return(list); } else { originalMaterials[type] = currentMat; } Material sharedMat = new Material(currentMat); sharedMat.color = Color.blue; sharedMat.name = "Debug Material"; foreach (GameObject go in list) { foreach (MeshRenderer r in go.GetComponentsInChildren <MeshRenderer>()) { r.sharedMaterial = sharedMat; } } } return(list); }
void Start() { PhysicalMap physicalMap = generator.physicalMap; if (physicalMap == null) { return; } string s = "Room dimensions:"; int i = 0; foreach (VirtualRoom.Dimensions dim in physicalMap.GetAllRoomDimensions()) { s += "\nRoom " + i + " X: " + dim.start_x + " Y: " + dim.start_y + " DIM X: " + dim.width_x + " DIM Y: " + dim.width_y + " STOREY: " + dim.storey; i++; } Debug.Log(s); }
private void ClearList(PhysicalMap physicalMap, SelectionObjectType type) { List <GameObject> list = physicalMap.GetObjectsOfType(type); if (OVERRIDE_MATERIALS) { if (originalMaterials.ContainsKey(type) && originalMaterials[type] != null) { foreach (GameObject go in list) { foreach (MeshRenderer r in go.GetComponentsInChildren <MeshRenderer>()) { r.sharedMaterial = originalMaterials[type]; } } originalMaterials[type] = null; } } }
public List <GameObject> SelectObjectsByZone(int zone_number) { PhysicalMap physicalMap = generator.physicalMap; if (physicalMap == null) { Debug.Log("NO PHYSICAL MAP!"); return(null); } DaedalusDebugUtils.Assert(physicalMap.zones != null, "Physical map's zone lists are null!"); DaedalusDebugUtils.Assert(zone_number >= 0, "Zone number must be >= 0!"); DaedalusDebugUtils.Assert(zone_number <= physicalMap.zones.Count - 1, "Zone number too high!"); List <GameObject> list = physicalMap.GetObjectsOfZone(zone_number) as List <GameObject>; if (list.Count == 0) { Debug.Log("NO ITEMS!"); return(list); } return(list); }
void DrawConnections(VirtualCell input_cell, List <CellLocation> unvisited_locations, PhysicalMap physicalMap, VirtualMap virtualMap, int max_distance) { unvisited_locations.Remove(input_cell.location); Vector3 input_pos = physicalMap.GetRealWorldPosition(input_cell.location, virtualMap.storey_number); //Debug.Log("Has connected cells: " + start_cell.connectedCells.Count); foreach (CellLocation connected_cell_location in input_cell.connectedCells) { //Debug.Log(connected_cell_location); Vector3 end_pos = physicalMap.GetRealWorldPosition(connected_cell_location, virtualMap.storey_number); //Debug.Log(input_cell.distance_from_root * 1f / virtualMap.GetMaximumDistance()); Color col = Color.Lerp(Color.red, Color.green, input_cell.distance_from_root * 1f / max_distance); Handles.color = col; Handles.DrawLine(input_pos, end_pos); if (unvisited_locations.Contains(connected_cell_location)) { DrawConnections(virtualMap.GetCell(connected_cell_location), unvisited_locations, physicalMap, virtualMap, max_distance); } } }
void OnSceneGUI() { if (showDebugCoordinates || showDebugConnections) { PhysicalMap physicalMap = this.targetInstance.GetPhysicalMap(); VirtualMap[] virtualMaps = this.targetInstance.GetVirtualMaps(); if (this.targetInstance.HasGeneratedDungeon()) { if (physicalMap != null && virtualMaps.Length > 0) { GUIStyle guiStyle = new GUIStyle(); if (showDebugCoordinates) { for (int i = 0; i < virtualMaps.Length; i++) { foreach (VirtualCell c in virtualMaps[i].GetAllCells()) { Vector3 p = physicalMap.GetRealWorldPosition(c.location, i); if (c.location.x % 2 == 1 && c.location.y % 2 == 1) { guiStyle.normal.textColor = Color.yellow; int actual_x = (c.location.x - 1) / 2; int actual_y = (c.location.y - 1) / 2; Handles.Label(p, c.location.x + "," + c.location.y + "\n(" + actual_x + "," + actual_y + ")", guiStyle); } else { guiStyle.normal.textColor = Color.white; Handles.Label(p, c.location.x + "," + c.location.y, guiStyle); } } } } if (showDebugConnections) { for (int i = 0; i < virtualMaps.Length; i++) { VirtualMap virtualMap = virtualMaps[i]; List <CellLocation> unvisited_locations = new List <CellLocation>(virtualMap.WalkableLocations); //Debug.Log("Starting from " + start_location); int max_distance = virtualMap.GetMaximumDistance(); int stop_iter = 0; while (unvisited_locations.Count > 0) { CellLocation start_location = unvisited_locations[0]; // We start from a walkable cell (doesn't matter which one) VirtualCell start_cell = virtualMap.GetCell(start_location); DrawConnections(start_cell, unvisited_locations, physicalMap, virtualMap, max_distance); stop_iter++; if (stop_iter == 100) { DaedalusDebugUtils.Assert(false, "Looping in show debug connectsion!"); break; // ERROR HERE! } } } } // TEST path check //VirtualMap test_virtualMap = virtualMaps[0]; //List<CellLocation> test_unvisited_locations = new List<CellLocation>(test_virtualMap.WalkableLocations); //test_virtualMap.ExistsPathBetweenLocations(test_unvisited_locations[0], test_unvisited_locations[test_unvisited_locations.Count - 1]); } } } }
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; }
public List <GameObject> SelectObjects(SelectionObjectType type) { PhysicalMap physicalMap = generator.physicalMap; return(SelectInternal(physicalMap, type)); }
void OnGUI() { this.generator = EditorGUILayout.ObjectField(this.generator, typeof(GeneratorBehaviour), true) as GeneratorBehaviour; if (debugger == null) { debugger = new GeneratorDebugger(); } if (generator != null) { debugger.generator = generator; // if (debugger == null) { // GUIStyle style = new GUIStyle(); // style.normal.textColor = Color.red; // GUILayout.Label("Add a Generator Debugger component to the generator you want to debug!",style); // return; // } EditorGUI.BeginDisabledGroup(Application.isPlaying == true); PhysicalMap physicalMap = generator.physicalMap; if (physicalMap == null) { GUIStyle style = new GUIStyle(); style.normal.textColor = Color.red; GUILayout.Label("No map has been generated, generate first!", style); } EditorGUI.BeginDisabledGroup(physicalMap == null || generator == null); // int i = 0; // foreach(PhysicalMapZone zone in physicalMap.zones){ for (int i = 0; i < physicalMap.zones.Count; i++) { if (GUILayout.Button("Select Storey " + i)) { List <GameObject> gos = debugger.SelectObjectsByZone(i); if (gos != null) { Selection.objects = gos.ToArray(); } } // i++; } foreach (SelectionObjectType sot in System.Enum.GetValues(typeof(SelectionObjectType)).Cast <SelectionObjectType>()) { if (GUILayout.Button("Select " + sot)) { List <GameObject> gos = debugger.SelectObjects(sot); if (gos != null) { Selection.objects = gos.ToArray(); } } } if (GUILayout.Button("Clear")) { debugger.Clear(); // Debug.Log (Selection.objects); // Debug.Log (debugger); Selection.objects = new Object[0]; } EditorGUI.EndDisabledGroup(); } else { GUILayout.Label("Link your GeneratorBehaviour here."); } }