public void LoadLevelFromDropdown() { Dropdown cbx = GameObject.Find("drpLoad").GetComponent <Dropdown>(); currentLevel.Destroy(); currentLevel = SerializedGameLevels.getLevel(cbx.options[cbx.value].text); }
// Use this for initialization void Start() { Game.game.Initialize(); Init(); currentLevel = SerializedGameLevels.getLevel("testlevel"); }
static public void Serialize(SerializedGameLevels sz, string filename) { XmlSerializer serializer = new XmlSerializer(typeof(SerializedGameLevels)); TextWriter textWriter = new StreamWriter(filename); serializer.Serialize(textWriter, sz); textWriter.Close(); }
public void SaveAll() { SerializedGameLevels.Serialize(SerializedGameLevels.gameLevels, Application.dataPath + "/8BD/Resources/" + Constants.GameLevelsXML + ".xml"); Debug.Log("Saving : " + currentLevel.sz.mapName); Map2D.Save(currentLevel.map, currentLevel.sz.mapName); UnityEditor.AssetDatabase.Refresh(); PopulateLoad(); }
public void Initialize() { Screen.orientation = ScreenOrientation.LandscapeLeft; SerializedEntities.se = SerializedEntities.DeSerialize(Constants.EntitiesXML); SerializedScenes.szScenes = SerializedScenes.DeSerialize(Constants.ScenesXML); SerializedMapCategories.mapCategories = SerializedMapCategories.DeSerialize(Constants.CategoriesXML); SerializedGameLevels.gameLevels = SerializedGameLevels.DeSerialize(Constants.GameLevelsXML); }
public static SerializedGameLevels DeSerialize(string filename) { XmlSerializer deserializer = new XmlSerializer(typeof(SerializedGameLevels)); TextAsset textAsset = (TextAsset)Resources.Load(filename); TextReader textReader = new StringReader(textAsset.text); SerializedGameLevels sz = (SerializedGameLevels)deserializer.Deserialize(textReader); foreach (SerializedGameLevel sgl in sz.levels) { foreach (SerializedCharacterInstance sci in sgl.characters) { sci.Initialize(); } } textReader.Close(); return(sz); }
public void CreateNew() { SerializedGameLevel gl = new SerializedGameLevel(); gl.crtSettings_id = "crt"; gl.mapName = GameObject.Find("inpMapName").GetComponent <InputField>().text; gl.name = GameObject.Find("inpNewName").GetComponent <InputField>().text; Map2D map = new Map2D(); int x = int.Parse(GameObject.Find("inpX").GetComponent <InputField>().text); int y = int.Parse(GameObject.Find("inpY").GetComponent <InputField>().text); map.Create(x, y); Map2D.Save(map, gl.mapName); SerializedGameLevels.gameLevels.levels.Add(gl); SaveAll(); currentLevel.Destroy(); currentLevel = SerializedGameLevels.getLevel(gl.name); }