private void Awake() { if (instance == null) { instance = this; } else { Destroy(this); return; } uiTileBlock = GameObject.Find("Canvas").transform.Find("UiTileBlock").gameObject; activeTile = tiles[0]; for (int i = 0; i < tiles.Count; i++) { GameObject newTile = Instantiate(uiTileObject, uiTileBlock.transform); newTile.transform.position = new Vector3(100 * i, 50); newTile.GetComponent <UiTile>().represents = tiles[i]; } if (File.Exists(path)) { try { currentRoom = JsonUtility.FromJson <Room>(path); } catch (System.Exception e) { Debug.LogWarning(e.ToString()); } } }
private void newRoomBt_Click(object sender, EventArgs e) { RoomEditor childForm = new RoomEditor(); childForm.MdiParent = this; childForm.Text = "Room"; childForm.Show(); }
public void SetRoomEditor(RoomEditor room_editor) { this.room_editor = room_editor; size_x = room_editor.edited_room.size.x; size_y = room_editor.edited_room.size.y; SetLevelSet(room_editor.current_level_set); ReloadRoomSet(); }
public void MakeRoom_Test(string name, int width, int length) { //TODO Assert.Inconclusive("Deze test werkt niet!"); Room room = Room.FromDimensions(name, width, length); RoomEditor revm = new RoomEditor(); Assert.NotNull(revm.MakeRoom(room)); Assert.AreEqual(revm.MakeRoom(room), room.Positions); }
void Start() { allRooms = new List <List <Room> >(); cabins = new List <Room>(); bathhouses = new List <Room>(); editor = GameObject.Find("RoomEditor").GetComponent <RoomEditor>(); allRooms.Add(cabins); allRooms.Add(bathhouses); }
private void DrawNode(int id) { if (nodes.Count > 0) { nodes[id].room = (RoomConfig)EditorGUILayout.ObjectField("Room", nodes[id].room, typeof(RoomConfig), false); nodes[id].secretRoom = EditorGUILayout.Toggle("Secret Room: ", nodes[id].secretRoom); if (GUI.Button(new Rect(100, 90, 90, 20), "Assign")) { nodes[id].room = currentScriptable; nodes[id].prefab = currentPrefab; } if (nodes[id].room != null) { if (GUI.Button(new Rect(100, 60, 90, 20), "Edit Level")) { RoomConfigEditor.sizeImage.x = nodes[id].room.width; RoomConfigEditor.sizeImage.y = nodes[id].room.height; RoomEditor roomEditorWindow = (RoomEditor)GetWindow <RoomEditor>(); roomEditorWindow.wantsMouseMove = true; roomEditorWindow.zoom = 30; roomEditorWindow.myStyle = new GUIStyle(); roomEditorWindow.myStyle.fontSize = 50; roomEditorWindow.myStyle.normal.textColor = Color.yellow; roomEditorWindow.myStyle.alignment = TextAnchor.MiddleCenter; roomEditorWindow.re = roomEditorWindow; roomEditorWindow.Show(); roomEditorWindow.roomScriptable = nodes[id].room; RoomEditor.layers = nodes[id].room.layers; roomEditorWindow.texturesLayers = nodes[id].room.texturesLayers; roomEditorWindow.spritesCreateLayers = nodes[id].room.spritesCreateLayers; roomEditorWindow.centerTextures = nodes[id].room.centerTextures; roomEditorWindow.setDefaultTexture = true; roomEditorWindow.roomTextures = nodes[id].room.roomTextures; roomEditorWindow.colors = new Color[(int)RoomConfigEditor.sizeImage.x, (int)RoomConfigEditor.sizeImage.y]; if (!RoomConfigEditor.load) { for (int x = 0; x < (int)RoomConfigEditor.sizeImage.x; x++) { for (int y = 0; y < (int)RoomConfigEditor.sizeImage.y; y++) { roomEditorWindow.colors[x, y] = Color.gray; } } } } Texture2D currentTexture = AssetPreview.GetAssetPreview(Resources.Load <GameObject>("Prefabs/Rooms/" + nodes[id].room.name)); GUI.DrawTexture(new Rect(10, 60, 80, 80), currentTexture); } } }
public int GetTotalFurnituresPlaced() { int num = 0; foreach (FurniturePosition furniturePosition in this._furniturePositions) { Furniture furniture = RoomEditor.GetFurniture((int)furniturePosition.id); if (furniture != null && furniture.type != FurnitureType.Theme && furniture.type != FurnitureType.Font) { ++num; } } return(num); }
public static List <Furniture> GetRandomFurniture( int minRarity, int num, float rarityMult = 1f, bool gacha = false, int numDupes = 0) { List <Furniture> furnitureList = new List <Furniture>(); IOrderedEnumerable <Furniture> source = RoomEditor.AllFurnis().Where <Furniture>((Func <Furniture, bool>)(x => x.rarity >= minRarity)).OrderBy <Furniture, int>((Func <Furniture, int>)(x => Rando.Int(999999))); for (int index = 0; index < num; ++index) { Furniture winner = (Furniture)null; Furniture furniture1 = (Furniture)null; List <int> intList = new List <int>(); foreach (Furniture furniture2 in (IEnumerable <Furniture>)source) { if (!gacha || furniture2.canGetInGacha) { if (furniture1 == null) { furniture1 = furniture2; } bool flag = Profiles.experienceProfile.GetNumFurnitures((int)furniture2.index) > 0; int _max = 35; if (furniture2.rarity >= Rarity.VeryRare) { _max = 10; } if (furniture2.rarity >= Rarity.SuperRare) { _max = 6; } if ((!flag || furniture2.type == FurnitureType.Prop && (Rando.Int(_max) == 0 || numDupes > 0)) && !intList.Contains(furniture2.rarity)) { if (Profiles.experienceProfile.GetNumFurnitures((int)furniture2.index) <= 0 || Rando.Int(2) == 0) { intList.Add(furniture2.rarity); } if (furniture1 == null || furniture2.rarity < furniture1.rarity) { furniture1 = furniture2; } if ((winner == null || furniture2.rarity > winner.rarity) && (furniture2.rarity == Rarity.Common || Rando.Int((int)((double)furniture2.rarity * (double)rarityMult)) == 0)) { winner = furniture2; } } } } if (winner == null) { winner = furniture1; } if (Profiles.experienceProfile.GetNumFurnitures((int)winner.index) > 0) { --numDupes; } furnitureList.Add(winner); if (index != num - 1) { source = source.Where <Furniture>((Func <Furniture, bool>)(x => x != winner)).OrderBy <Furniture, int>((Func <Furniture, int>)(x => Rando.Int(999999))); } } return(furnitureList); }
private void OnEnable() { room_editor = (RoomEditor)serializedObject.targetObject; }
static void Init() { RoomEditor window = (RoomEditor)CreateInstance(typeof(RoomEditor)); window.Show(); }
public static void ShowWindow(RoomEditor room_editor) { (GetWindow(typeof(RoomEditorWindow)) as RoomEditorWindow).SetRoomEditor(room_editor); }
private void OnGUI() { EditorGUILayout.Space(); EditorGUILayout.Space(); nameRoom = EditorGUILayout.TextField("Room Name", nameRoom); sizeImage = EditorGUILayout.Vector2Field("Room Size", sizeImage); sizeImage = new Vector2((int)Mathf.Clamp(sizeImage.x, 0, int.MaxValue), (int)Mathf.Clamp(sizeImage.y, 0, int.MaxValue)); Change = EditorGUILayout.Toggle("Change Percents", Change); if (Change) { EditorGUI.DrawRect(new Rect(8, 88, position.width - 15, position.height - 127), new Color(0, 0, 0.8f, 1)); EditorGUI.DrawRect(new Rect(14, 94, position.width - 26, position.height - 139), Color.blue); } else { EditorGUI.DrawRect(new Rect(8, 88, position.width - 15, position.height - 127), new Color(0.8f, 0.8f, 0.8f, 1)); EditorGUI.DrawRect(new Rect(14, 94, position.width - 26, position.height - 139), Color.gray); } GUILayout.BeginArea(new Rect(18, 98, position.width - 34, position.height - 143)); if (Change) { traps = EditorGUILayout.FloatField("Traps", traps); normal = EditorGUILayout.FloatField("Normal Tiles", normal); enemies = EditorGUILayout.FloatField("Enemies", enemies); difficulty = EditorGUILayout.FloatField("Enemies Difficulty", difficulty); } else { GUI.Label(new Rect(0, 0, 200, 100), "Traps"); EditorGUI.DelayedFloatField(new Rect(150, 0, 122, 16), traps); GUI.Label(new Rect(0, 17.5f, 200, 100), "Normal Tiles"); EditorGUI.DelayedFloatField(new Rect(150, 17.5f, 122, 16), normal); GUI.Label(new Rect(0, 35.5f, 200, 100), "Enemies"); EditorGUI.DelayedFloatField(new Rect(150, 35.5f, 122, 16), enemies); GUI.Label(new Rect(0, 53.5f, 200, 100), "Enemies Difficulty"); EditorGUI.DelayedFloatField(new Rect(150, 53.5f, 122, 16), difficulty); } int randomClamp = 0; randomClamp = UnityEngine.Random.Range(1, 5); switch (randomClamp) { case 1: traps = Mathf.Clamp(traps, 0, 100 - (normal + enemies + difficulty)); break; case 2: normal = Mathf.Clamp(normal, 0, 100 - (traps + enemies + difficulty)); break; case 3: enemies = Mathf.Clamp(enemies, 0, 100 - (normal + traps + difficulty)); break; case 4: difficulty = Mathf.Clamp(difficulty, 0, 100 - (normal + enemies + traps)); break; } traps = Mathf.Clamp(traps, 0, 100); normal = Mathf.Clamp(normal, 0, 100); enemies = Mathf.Clamp(enemies, 0, 100); difficulty = Mathf.Clamp(difficulty, 0, 100); GUILayout.EndArea(); if (sizeImage.x > 0 || sizeImage.y > 0) { errorSize = false; } GUILayout.BeginArea(new Rect(6, 190, position.width - 12, position.height - 143)); EditorGUILayout.BeginHorizontal(); bool open = GUILayout.Button("Create Room"); if (open) { /* * RAMIRO AGREGANDO CODIGO PARA GUARDAR EL SCRIPTABLE OBJECT CON LOS VALORES PASADOS EN LA VENTANA */ if (sizeImage.x > 2 || sizeImage.y > 2) { //Creo el scriptable del tipo room y guardo en cada una de sus variables la información correspondiente. RoomConfig roomScriptable = ScriptableObject.CreateInstance <RoomConfig>(); roomScriptable.roomName = nameRoom; roomScriptable.width = (int)sizeImage.x; roomScriptable.height = (int)sizeImage.y; roomScriptable.traps = traps; roomScriptable.normalTiles = normal; roomScriptable.enemys = enemies; roomScriptable.enemysDif = difficulty; roomScriptable.sizeImage = sizeImage; //Indico el path en donde voy a querer que se guarde el nuevo scriptable. string path = "Assets/Resources/Rooms/" + roomScriptable.roomName + ".asset"; //Le digo que el path sea unico, asi no corremos el riesgo de pisar una habitacion creada previamente con el mismo nombre. path = AssetDatabase.GenerateUniqueAssetPath(path); //Creo el asset del scriptable en el path final. AssetDatabase.CreateAsset(roomScriptable, path); //Guardamos los assets en disco AssetDatabase.SaveAssets(); //Importa / recarga los archivos nuevos, modificados, para que puedan verse en el editor de unity. AssetDatabase.Refresh(); EditorUtility.SetDirty(roomScriptable); /* * FIN */ RoomEditor roomCreator = (RoomEditor)GetWindow(typeof(RoomEditor)); roomCreator.wantsMouseMove = true; roomCreator.Show(); roomCreator.zoom = 30; roomCreator.myStyle = new GUIStyle(); roomCreator.myStyle.fontSize = 50; roomCreator.myStyle.normal.textColor = Color.yellow; roomCreator.myStyle.alignment = TextAnchor.MiddleCenter; roomCreator.re = roomCreator; path = path.Split(new string[2] { "Resources/", ".asset" }, 3, StringSplitOptions.RemoveEmptyEntries)[1]; roomCreator.roomScriptable = Resources.Load <RoomConfig>(path); roomCreator.colors = new Color[(int)sizeImage.x, (int)sizeImage.y]; if (variant) { roomCreator.roomScriptable.texturesLayers = roomScriptableV.texturesLayers; roomCreator.roomScriptable.spritesCreateLayers = roomScriptableV.spritesCreateLayers; roomCreator.roomScriptable.centerTextures = roomScriptableV.centerTextures; roomCreator.roomScriptable.roomTextures = roomScriptableV.roomTextures; roomCreator.roomScriptable.layers = roomScriptableV.layers; roomCreator.roomScriptable.layersString = roomScriptableV.layersString; RoomEditor.layers = roomScriptableV.layers; } if (!load) { for (int x = 0; x < (int)sizeImage.x; x++) { for (int y = 0; y < (int)sizeImage.y; y++) { roomCreator.colors[x, y] = Color.gray; } } } } else if (sizeImage.x <= 0 && sizeImage.y <= 0) { errorSize = true; } } bool random = GUILayout.Button("Randomize Values"); if (random) { traps = UnityEngine.Random.Range(0, 101); normal = UnityEngine.Random.Range(0, 100 - (traps + 1)); enemies = UnityEngine.Random.Range(0, 100 - (normal + 1)); difficulty = UnityEngine.Random.Range(0, 100 - (enemies + 1)); } EditorGUILayout.EndHorizontal(); GUILayout.EndArea(); if (errorSize) { EditorGUILayout.HelpBox("Increase the size of the grid", MessageType.Error); } minSize = new Vector2(305, 210); maxSize = minSize; }
private void OnGUI() { EditorGUILayout.Space(); roomScriptable = (RoomConfig)EditorGUILayout.ObjectField("Room", roomScriptable, typeof(RoomConfig), false); if (roomScriptable != null) { EditorUtility.SetDirty(roomScriptable); } bool variant = GUI.Button(new Rect(0, 80, position.width / 2, position.height - 92), "MakeVariant"); if (variant) { if (roomScriptable != null) { RoomConfigEditor RCE = (RoomConfigEditor)GetWindow(typeof(RoomConfigEditor)); RCE.wantsMouseMove = true; RCE.Show(); RCE.nameRoom = roomScriptable.roomName; RCE.normal = roomScriptable.normalTiles; RCE.traps = roomScriptable.traps; RCE.enemies = roomScriptable.enemys; RCE.difficulty = roomScriptable.enemysDif; RCE.roomScriptableV = roomScriptable; RCE.variant = true; RoomConfigEditor.sizeImage = new Vector2(roomScriptable.width, roomScriptable.height); } else { error = true; } } bool edit = GUI.Button(new Rect(position.width / 2, 80, position.width / 2, position.height - 92), "Edit"); if (edit) { if (roomScriptable != null) { RoomConfigEditor.sizeImage.x = roomScriptable.width; RoomConfigEditor.sizeImage.y = roomScriptable.height; RoomEditor roomEditorWindow = (RoomEditor)GetWindow <RoomEditor>(); roomEditorWindow.wantsMouseMove = true; roomEditorWindow.zoom = 30; roomEditorWindow.myStyle = new GUIStyle(); roomEditorWindow.myStyle.fontSize = 50; roomEditorWindow.myStyle.normal.textColor = Color.yellow; roomEditorWindow.myStyle.alignment = TextAnchor.MiddleCenter; roomEditorWindow.re = roomEditorWindow; roomEditorWindow.Show(); roomEditorWindow.roomScriptable = roomScriptable; RoomEditor.layers = roomScriptable.layers; roomEditorWindow.texturesLayers = roomScriptable.texturesLayers; roomEditorWindow.spritesCreateLayers = roomScriptable.spritesCreateLayers; roomEditorWindow.centerTextures = roomScriptable.centerTextures; roomEditorWindow.setDefaultTexture = true; roomEditorWindow.roomTextures = roomScriptable.roomTextures; roomEditorWindow.colors = new Color[(int)RoomConfigEditor.sizeImage.x, (int)RoomConfigEditor.sizeImage.y]; if (!RoomConfigEditor.load) { for (int x = 0; x < (int)RoomConfigEditor.sizeImage.x; x++) { for (int y = 0; y < (int)RoomConfigEditor.sizeImage.y; y++) { roomEditorWindow.colors[x, y] = Color.gray; } } } } else { error = true; } } if (error) { EditorGUILayout.HelpBox("Add Room", MessageType.Error); } minSize = new Vector2(300, 150); maxSize = minSize; }