public override void OnInspectorGUI() { base.OnInspectorGUI(); MapEdit t = target as MapEdit; if (GUILayout.Button("Generate")) { t.Generate(); } if (GUILayout.Button("Save")) { t.Save(); } if (GUILayout.Button("ShowElse")) { var list = Resources.FindObjectsOfTypeAll(typeof(GameObject)); for (int i = 0; i < list.Length; i++) { if (list[i] != t.gameObject) { list[i].hideFlags = HideFlags.None; } } } }
public override char[,] GenerateMap() { map = GetVoidMap(); InitializePseudoRandomGenerator(); RandomFillMap(); for (int i = 0; i < smoothingIterations; i++) { SmoothMap(); } ProcessMap(); map = MapEdit.AddBorders(map, borderSize, wallChar); width = map.GetLength(0); height = map.GetLength(1); if (createTextFile) { SaveMapAsText(); } return(map); }
public override void ManageMap(bool assembleMap) { if (loadMapFromFile) { // Load the map. LoadMapFromText(); // Flip the map if needed. if (flip) { map = MapEdit.FlipMap(map); } } else { // Generate the map. if (ParameterManager.HasInstance()) { map = mapGeneratorScript.GenerateMap(seed, export, exportPath); } else { map = mapGeneratorScript.GenerateMap(); } } if (assembleMap) { // Assemble the map. mapAssemblerScript.AssembleMap(map, mapGeneratorScript.GetWallChar(), mapGeneratorScript.GetRoomChar()); // Displace the objects. objectDisplacerScript.DisplaceObjects(map, mapAssemblerScript.GetSquareSize(), mapAssemblerScript.GetWallHeight()); } }
protected void GenerateObjectsRainShared(MapObject o, char[,] restrictedMap) { char[,] supportMap = restrictedMap.Clone() as char[, ]; // Restrict again if there are object that need a further restriction. if (!o.placeAnywhere && objectToWallDistance > 1) { for (int i = 1; i < objectToWallDistance; i++) { MapEdit.ErodeMap(supportMap, wallChar); } } List <Coord> roomTiles = MapInfo.GetFreeTiles(supportMap, roomChar); for (int i = 0; i < o.numObjPerMap; i++) { if (roomTiles.Count > 0) { int selected = pseudoRandomGen.Next(0, roomTiles.Count); map[roomTiles[selected].tileX, roomTiles[selected].tileY] = o.objectChar; MapEdit.DrawCircle(roomTiles[selected].tileX, roomTiles[selected].tileY, (o.placeAnywhere) ? 1 : objectToObjectDistance, supportMap, wallChar); roomTiles = MapInfo.GetFreeTiles(supportMap, roomChar); } else { ManageError(Error.SOFT_ERROR, "Error while populating the map, no more free " + "tiles are availabe."); return; } } }
public override char[,] GenerateMap() { InitializePseudoRandomGenerator(); width = 0; height = 0; ParseGenome(); InitializeMap(); ProcessMap(); map = MapEdit.AddBorders(map, borderSize, wallChar); width += borderSize * 2; height += borderSize * 2; if (createTextFile) { seed = seed.GetHashCode().ToString(); SaveMapAsText(); } return(map); }
/* OBJECT GENERATION */ // Erodes the map once, scans custom objects and adds them to the map using the rigth method. protected void PopulateMap() { if (mapObjects.Length > 0) { char[,] restrictedMap = map.Clone() as char[, ]; if (objectToWallDistance > 0) { MapEdit.ErodeMap(restrictedMap, wallChar); } // Place the objects. foreach (MapObject o in mapObjects) { switch (o.positioningMethod) { case ObjectPositioningMethod.Rain: GenerateObjectsRain(o, restrictedMap); break; case ObjectPositioningMethod.RainDistanced: GenerateObjectsRainDistanced(o, restrictedMap); break; case ObjectPositioningMethod.RainShared: GenerateObjectsRainShared(o, restrictedMap); break; } } } }
public static void showWindow() { editor = EditorWindow.GetWindow <MapEdit>(); editor.Show(); EditorApplication.hierarchyChanged += OnHierarchyChanged; SceneView.duringSceneGui += OnScene; }
// Creates a passage between two rooms. private void CreatePassage(Room roomA, Room roomB, Coord tileA, Coord tileB) { Room.ConnectRooms(roomA, roomB); List <Coord> line = GetLine(tileA, tileB); foreach (Coord c in line) { MapEdit.DrawCircle(c.tileX, c.tileY, passageWidth, map, roomChar); } }
public bool UpdateMap(MapEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Maps.Single(e => e.ID == model.MapID && e.OwnerID == _userID); entity.Name = model.Name; entity.Description = model.Description; return(ctx.SaveChanges() == 1); } }
public void OnSceneGUI() { MapEdit t = target as MapEdit; if (Event.current.type == EventType.mouseDown) { edit = !edit; } if (edit && Event.current.type == EventType.MouseMove) { t.Raycast(HandleUtility.GUIPointToWorldRay(Event.current.mousePosition)); } }
// GET: Map/Edit/5 public ActionResult Edit(int id) { var detail = _mSvc.Value.GetMapByID(id); var model = new MapEdit { MapID = detail.MapModel.MapID, Name = detail.MapModel.Name, Description = detail.MapModel.Description, BlockIDs = detail.MapModel.BlockIDs }; return(View(model)); }
void init() { if (Application.isPlaying) { gameObject.SetActive(false); return; } mapEdit = gameObject.GetComponent <MapEdit>(); if (mapEdit == null) { mapEdit = gameObject.AddComponent <MapEdit>(); } m_CellArray = mapEdit.GetArray(); }
public override char[,] GenerateMap() { map = new char[width, height]; InitializePseudoRandomGenerator(); MapEdit.FillMap(map, wallChar); rooms = new List <Room>(); placedRooms = new List <Room>(); if (createTextFile || prepareABExport) { ABRooms = new List <ABRoom>(); ABCorridors = new List <ABRoom>(); ABTiles = new List <ABTile>(); } if (width > height) { DivideRoom(0, 0, width, height, true, 0); } else { DivideRoom(0, 0, width, height, false, 0); } ProcessRooms(); ProcessMap(); map = MapEdit.AddBorders(map, borderSize, wallChar); width = map.GetLength(0); height = map.GetLength(1); if (createTextFile || prepareABExport) { PopulateABRooms(); PopulateABObjects(); AddBorderToAB(borderSize); } if (createTextFile) { SaveMapAsText(); SaveMapAsAB(); } return(map); }
// Generates a map. public override char[,] GenerateMap() { map = GetVoidMap(); // Parse the genome if needed. if (useABGeneration) { ParseGenome(); } if (tiles != null && tiles.Count > 0) { stairProbability = 0; } ValidateProbabilities(); InitializePseudoRandomGenerator(); MapEdit.FillMap(map, wallChar); DigMap(); if (tiles != null && tiles.Count > 0) { foreach (ABTile t in tiles) { if (MapInfo.IsInMapRange(t.x, t.y, width, height)) { map[t.x, t.y] = t.value; } } } else { PopulateMap(); } map = MapEdit.AddBorders(map, borderSize, wallChar); width = map.GetLength(0); height = map.GetLength(1); if (createTextFile && !useABGeneration) { SaveMapAsText(); } return(map); }
public ActionResult Edit(int id, MapEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.MapID != id) { ModelState.AddModelError("", "ID Mismatch"); return(View(model)); } if (_mSvc.Value.UpdateMap(model)) { TempData["SaveResult"] = "The map was updated succesfully."; return(RedirectToAction("MyMaps")); } ModelState.AddModelError("", "Your map could not be updated."); return(View(model)); }
// Initialize systems void Preload(KCModHelper helper) { TerraformWitchSpells.helper = helper; Zat.Shared.Debugging.Helper = helper; Application.logMessageReceived += OnLogMessageReceived; //Log(LocalizationManager.CurrentLanguageCode); util = gameObject.AddComponent <Util>(); queryForCriteria = gameObject.AddComponent <QueryForCriteria>(); mapEdit = new MapEdit(); var harmony = HarmonyInstance.Create("harmony"); harmony.PatchAll(Assembly.GetExecutingAssembly()); SetSpells(); Assembly assembly = Assembly.GetAssembly(typeof(Water)); System.Type type = assembly.GetType("Assets.Code.KeyboardControl"); MethodInfo methodInfoA = type.GetMethod("UpdatePlaymodeKeys", BindingFlags.NonPublic | BindingFlags.Instance); MethodInfo methodInfoB = typeof(QueryForCriteria.KeyboardControlUpdatePlaymodeKeys).GetMethod("Prefix", BindingFlags.NonPublic | BindingFlags.Static); harmony.Patch(methodInfoA.GetBaseDefinition(), new HarmonyMethod(methodInfoB), null, null); }
void OnGUI() { string temp; GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("宽度"); temp = GUILayout.TextField(width.ToString(), GUILayout.MinWidth(100)); width = int.Parse(temp); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("高度"); temp = GUILayout.TextField(height.ToString(), GUILayout.MinWidth(100)); height = int.Parse(temp); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("格子宽度"); temp = GUILayout.TextField(cellwidth.ToString(), GUILayout.MinWidth(100)); float.TryParse(temp, out cellwidth); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("格子高度"); temp = GUILayout.TextField(cellheight.ToString(), GUILayout.MinWidth(100)); float.TryParse(temp, out cellheight); GUILayout.EndHorizontal(); if (width * height * cellheight * cellwidth > 0 && GUILayout.Button("创建")) { GameObject g = new GameObject(); g.transform.position = Vector3.zero; me = g.AddComponent <MapEdit>(); me.width = width; me.height = height; me.cell_height = cellheight; me.cell_width = cellwidth; me.Generate(); } if (GUILayout.Button("Create Buiding")) { GameObject g = new GameObject("Building"); var mapItemBe = g.AddComponent <MapItemBehaviour>(); mapItemBe.MapItem = new MapBuildingItem(); } if (GUILayout.Button("生成地图信息")) { var items = GameObject.FindObjectsOfType <MapItemBehaviour>(); Dictionary <int, MapItem> mapDic = new Dictionary <int, MapItem>(); foreach (var mapItemBehaviour in items) { if (mapItemBehaviour.MapItem == null) { continue; } var count = mapDic.Count + 1; mapItemBehaviour.MapItem.Id = count; mapDic.Add(count, mapItemBehaviour.MapItem); } var str = Newtonsoft.Json.JsonConvert.SerializeObject(mapDic, Formatting.Indented, SkillUtility.settings); var scene = SceneManager.GetActiveScene(); File.WriteAllText(Application.streamingAssetsPath + "/Map/" + scene.name + ".bytes", str); } GUILayout.EndVertical(); }
void Start() { game = FindObjectOfType <GamePlay>(); cam = Camera.main.GetComponent <CamFollow>(); map = GetComponent <MapEdit>(); }
public static void showWindow() { editor = EditorWindow.GetWindow <MapEdit>(); editor.Show(); }
public override void ManageMap(bool assembleMap) { if (loadMapFromFile) { // Load the map. LoadMapFromText(); // Flip the map if needed. if (flip && !isNumeric) { map = MapEdit.FlipMap(map); } } else { // Generate the map. if (ParameterManager.HasInstance()) { map = mapGeneratorScript.GenerateMap(seed, export, exportPath); } else { map = mapGeneratorScript.GenerateMap(); } } if (assembleMap) { if (!isNumeric) { // Assemble the map. mapAssemblerScript.AssembleMap(map, mapGeneratorScript.GetWallChar(), mapGeneratorScript.GetRoomChar()); // Displace the objects. objectDisplacerScript.DisplaceObjects(map, mapAssemblerScript.GetSquareSize(), mapAssemblerScript.GetWallHeight()); } else { //Assemble the map mapAssemblerScript.AssembleMap(numeric_map, mapGeneratorScript.GetWallNumb(), mapGeneratorScript.GetRoomNumb()); // Displace the objects objectDisplacerScript.DisplaceObjects(numeric_map, mapAssemblerScript.GetSquareSize(), mapAssemblerScript.GetWallHeight()); } } float floorSize = mapAssemblerScript.GetSquareSize(); if (robot != null) { if (!isNumeric) { robot.SetMap(map, floorSize); } else { robot.SetMap(numeric_map, floorSize); } } if (player) { player.SetSquareSize(floorSize); } }
void Start() { map = FindObjectOfType <MapEdit>(); angle = transform.localEulerAngles; }