/// <summary> /// Saves a level using the given name and filepath within the assest folder /// Note that this is a relative filepath from the assests folder, not the absolute filepath /// </summary> public void saveLevel() { //Debug.Log("WTF, is this not being called?"); getCurrentMap(); // make sure map reference is current LevelEditor_2.cleanUpMap(currentMap); // clean up the map, removing deleted or invalid tiles if (File.Exists(Application.dataPath + levelPath + "/room_" + levelName + ".json")) // if it already exists, check wether the person intends to overwrite it { if (overwriteLevel) { LevelMap.Save(currentMap, Application.dataPath + levelPath + "/room_" + levelName + ".json"); Debug.Log("Overwriting level at: \"" + Application.dataPath + levelPath + "/room_" + levelName + ".json\""); overwriteLevel = false; } else { // If the overwriteLevel boolean is not set, do not overwrite the level Debug.Log("Are you sure you want to overwrite the level at: \"" + Application.dataPath + levelPath + "/room_" + levelName + ".json\" ?"); } } else { // if it doesn't already exit, don't need to make any checks. Debug.Log("Saving level at: \"" + Application.dataPath + levelPath + "/room_" + levelName + ".json\""); LevelMap.Save(currentMap, Application.dataPath + levelPath + "/room_" + levelName + ".json"); } }
/// <summary> /// Deletes the tile that is at the direction given by methodDirection. /// Can be used to screw up a map, so don't do that /// </summary> public void deleteTile() { //Debug.Log("deleteTile() does not do anything right now"); getCurrentNode(); // make sure node copy is current getCurrentMap(); // make sure map reference is current int tempIndex = currentNode[(int)methodDirection]; // get the node that this one connects to in that direction if (tempIndex >= 0) // can only delete that node if it exists { LevelEditor_2.deleteTile(currentMap, tempIndex); LevelEditor_2.cleanUpMap(currentMap); // clean up the node array inside map, so that it doesn't have gaps in the array. } else { Debug.Log("Error: There is no node the " + methodDirection.ToString() + "-ern direction"); } getCurrentNode(); // node copy now out of date, update it GameManager.gameplay.nonEuclidRenderer.HandleRender(GameManager.Direction.East, currentNode, false); // draw changes to map }