public void ReadData() { BinaryFormatter bf = new BinaryFormatter(); FileStream stream = new FileStream(Application.persistentDataPath + "/data.sav", FileMode.Open); SavingData oldData = bf.Deserialize(stream) as SavingData; data = oldData; stream.Close(); }
public void WriteData() { BinaryFormatter bf = new BinaryFormatter(); FileStream stream = new FileStream(Application.persistentDataPath + "/data.sav", FileMode.Create); SavingData newData = new SavingData(data); bf.Serialize(stream, newData); stream.Close(); }
protected void Button1_Click(object sender, EventArgs e) { string Username = UserName.Text; string Email = EmailId.Text; string Password1 = Password.Text; SavingData sd = new SavingData(); sd.GetData(Username, Email, Password1); Response.Redirect("LoginPage.aspx"); }
public static void SaveGame(Player player, bool[] chestsArray, bool[] flArray, bool[] wbArray, bool[] enArray, int sceneIndex) { BinaryFormatter formatter = new BinaryFormatter(); string path = dir.FullName; FileStream stream = new FileStream(path, FileMode.Create); SavingData data = new SavingData(player, chestsArray, flArray, wbArray, enArray, sceneIndex); formatter.Serialize(stream, data); stream.Close(); }
public static void Save(string slotKey, SavingData data) { PlayerPrefs.SetInt(slotKey + "_level", data.level); PlayerPrefs.SetFloat(slotKey + "_positionX", data.positionX); PlayerPrefs.SetFloat(slotKey + "_positionY", data.positionY); PlayerPrefs.SetInt(slotKey + "_score", data.score); PlayerPrefs.SetFloat(slotKey + "_time", data.timeElapsed); PlayerPrefs.SetString(slotKey + "_playerName", data.playerName); PlayerPrefs.Save(); }
public static void Save(SaveSlot slotKey, SavingData data) { PlayerPrefs.SetInt("Current", (int)slotKey); var timePassedSinceLastSave = Time.unscaledTime - internalTime; Debug.Log($"timePassedSinceLastSave: {timePassedSinceLastSave}"); data.timeElapsed = timePassedSinceLastSave; internalTime = Time.unscaledTime; PlayerPrefs.SetString($"{SaveKey}{slotKey.ToString()}", JsonUtility.ToJson(data)); Debug.Log($"Saved Data: {JsonUtility.ToJson(data, true)} {data.positionX}"); PlayerPrefs.Save(); }
private void Awake() { DontDestroyOnLoad(this.gameObject); if (runtimeSaving == null) { runtimeSaving = new Stack <SavingData>(); SavingData first = new SavingData(SpawnPoint.transform.position); save(first); } GameObject g = Instantiate(PlayerPrefab, runtimeSaving.Peek().PlayerTransform, Quaternion.identity); cvc.Follow = g.GetComponent <Player2D>().cameraTarget; }
public static void Save(string slotKey, SavingData data) { //Save into PlayerPrefs for each data item within the SavingData structure PlayerPrefs.SetInt(slotKey + "_level", data.level); PlayerPrefs.SetFloat(slotKey + "_positionX", data.positionX); PlayerPrefs.SetFloat(slotKey + "_positionY", data.positionY); PlayerPrefs.SetInt(slotKey + "_score", data.score); PlayerPrefs.SetFloat(slotKey + "_time", data.timeElapsed); PlayerPrefs.SetString(slotKey + "_playerName", data.playerName); //Save into permanent memory PlayerPrefs.Save(); }
public void LoadGame() { SavingData data = SavingSystem.LoadGame(); player.numberOfHearts = data.playerHearts; player.souls = data.playerSouls; player.currentHealth = data.playerHealth; player.maxHealth = data.maxHealth; player.numberOfKeys = data.numberOfKeys; player.numberOfSouls = data.numberOfSouls; player.positions[0] = data.position[0]; player.positions[1] = data.position[1]; player.positions[2] = data.position[2]; if (chestArray.Count > 0) { for (int i = 0; i < data.chests.Length; i++) { chestArray[i].SetOpen(data.chests[i]); } } if (flArray.Count > 0) { for (int i = 0; i < data.firelighters.Length; i++) { flArray[i].SetStatus(data.firelighters[i]); } } if (wbArray.Count > 0) { for (int i = 0; i < data.woodblocks.Length; i++) { wbArray[i].SetStatus(data.woodblocks[i]); } } if (enArray.Count > 0) { for (int i = 0; i < data.enemies.Length; i++) { enArray[i].SetStatus(data.enemies[i]); } } playerMO.transform.position = new Vector3(player.positions[0], player.positions[1], player.positions[2]); }
public static SavingData[] GetAllSlots() { var savesSlots = (SaveSlot[])Enum.GetValues(typeof(SaveSlot)); var savingDatas = new SavingData[savesSlots.Length]; for (int i = 0; i < savesSlots.Length; i++) { var slot = savesSlots[i]; savingDatas[i] = HasSlot(slot) ? JsonUtility.FromJson <SavingData>(PlayerPrefs.GetString($"{SaveKey}{slot.ToString()}")) : null; } return(savingDatas); }
public static SavingData Load(string slotKey) { var data = new SavingData { level = PlayerPrefs.GetInt(slotKey + "_level"), positionX = PlayerPrefs.GetFloat(slotKey + "_positionX"), positionY = PlayerPrefs.GetFloat(slotKey + "_positionY"), score = PlayerPrefs.GetInt(slotKey + "_score"), timeElapsed = PlayerPrefs.GetFloat(slotKey + "_time"), playerName = PlayerPrefs.GetString(slotKey + "_playerName") }; return(data); }
public static SavingData Load(string slotKey) { //Create a new SavingData structure SavingData data = new SavingData(); //Load from memory each item to fill up the data structure data.level = PlayerPrefs.GetInt(slotKey + "_level"); data.positionX = PlayerPrefs.GetFloat(slotKey + "_positionX"); data.positionY = PlayerPrefs.GetFloat(slotKey + "_positionY"); data.score = PlayerPrefs.GetInt(slotKey + "_score"); data.timeElapsed = PlayerPrefs.GetFloat(slotKey + "_time"); data.playerName = PlayerPrefs.GetString(slotKey + "_playerName"); //return the data structure return(data); }
// TO DO load catalogues for connection public void LoadCataloguesForUser(int connectionId) { TDSettings.ConnectionRow connection = _appSettings.GetConnectionById(connectionId); if (String.IsNullOrEmpty(connection.Charset)) { IUtilities utilities = (IUtilities)BLControllerFactory.GetRegisteredConcreteFactory(connectionId); connection.Charset = utilities.GetBugzillaCharset(connection.URL); _appSettings.EditConnection(connection); } SavingData data = new SavingData(OperationType.EditConnection, connection); this.LoadCataloguesForUser(data); }
public void SetStartButton() { SetButtons(startButtons, (position) => { var slot = (SaveSlot)position; SaveLoadSystem.Load(slot); var data = new SavingData { level = 1, playerName = playerNameInput.text, score = 0, timeElapsed = 0 }; SaveLoadSystem.Save(slot, data); SceneManager.LoadScene($"Level{data.level.ToString()}"); }); }
public void Local_SaveGame() { directorys = Application.persistentDataPath + "/ghost_Saving_data"; Debug.Log("saving"); obj = new SavingData(); if (!Directory.Exists(directorys)) { Directory.CreateDirectory(directorys); } BinaryFormatter formatter = new BinaryFormatter(); FileStream file = File.Create(directorys + "/data.txt"); var json = JsonUtility.ToJson(obj); formatter.Serialize(file, json); file.Close(); }
public static SavingData LoadGame() { string path = dir.FullName; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); SavingData data = formatter.Deserialize(stream) as SavingData; stream.Close(); return(data); } else { Debug.Log("Save File not found in " + path); return(null); } }
protected void Button1_Click(object sender, EventArgs e) { string firstname = FirstName.Text; string lastname = LastName.Text; string phonenumber = (PhoneNumber.Text); string emailid = lblmsg.Text; string address = Address.Text; string city = City.Text; string state = State.Text; string country = Country.Text; string department = Department.Text; string gender = Gender.Text; string thenthboard = TenthBoard.Text; int tenthmarks = Convert.ToInt32(TenthMarks.Text); string twelfthboard = TwelfthBoard.Text; int twelthmarks = Convert.ToInt32(TwelfthMarks.Text); char flag = 'N'; SavingData sd = new SavingData(); sd.DataStore(firstname, lastname, phonenumber, emailid, address, city, state, country, department, gender, thenthboard, tenthmarks, twelfthboard, twelthmarks, flag); Response.Redirect("ViewOrUpdate.aspx"); }
private void LoadCataloguesForUser(SavingData data) { // check if the catalogues collection has loaded. bool isLoaded = false; for (int i = 0; i < globalCataloguesCollection.Count; i++) { if (globalCataloguesCollection[i].ConnectionId == data.ConnectionRow.ConnectionId) { isLoaded = true; } } if (!isLoaded) { TDSettings.ConnectionRow connection = _appSettings.GetConnectionById(data.ConnectionRow.ConnectionId); BackgroundWorker bwCatalogues = new BackgroundWorker(); bwCatalogues.DoWork += new DoWorkEventHandler(bkgCatalogues_DoWork); bwCatalogues.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bkgCatalogues_RunWorkerCompleted); bwCatalogues.ProgressChanged += new ProgressChangedEventHandler(bkgCatalogues_ProgressChanged); bwCatalogues.WorkerReportsProgress = true; bwCatalogues.WorkerSupportsCancellation = true; ArrayList al = new ArrayList(); al.Add(connection); al.Add(data); bwCatalogues.RunWorkerAsync(al); } }
void bkgCatalogues_DoWork(object sender, DoWorkEventArgs e) { SavingData sp = null; BackgroundWorker backgroundWorker = sender as BackgroundWorker; ArrayList result = new ArrayList(); try { ArrayList al = e.Argument as ArrayList; TDSettings.ConnectionRow currentConnection = al[0] as TDSettings.ConnectionRow; sp = al[1] as SavingData; Catalogues cataloguesPerUser = CatalogueManager.GetCataloguesForUser(currentConnection, backgroundWorker); result.Add(cataloguesPerUser); result.Add(sp); e.Result = result; } catch (Exception ex) { sp.ErrorMessage = ex.Message; sp.Operation = OperationType.LogOnFailed; MyLogger.Write(ex, "bkgCatalogues_DoWork", LoggingCategory.Exception); SplashManager.Close(); // just in case backgroundWorker.ReportProgress(100); throw new CustomException(sp, String.Empty, ex); } }
public void Restart() { SavingData.AddTheNumberOfCoins(GameSetups.Coins); SceneManager.LoadScene("Game", LoadSceneMode.Single); }
void bkgCatalogues_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { CustomException ex = (CustomException)e.Error; string errorMessage; if (ex != null) { if (this.CatalogueEvent != null) { SavingData sp = ex.CustomData; if (sp.Operation == OperationType.LogOnFailed) { // no code here. } else { sp.Operation = OperationType.AddConnectionThrowsError; } if (this.CatalogueEvent != null) { this.CatalogueEvent(this, new MyZillaSettingsEventArgs(sp)); } } errorMessage = Messages.ErrLoadingCatalogues + Environment.NewLine + ex.InnerException.Message; } else { errorMessage = Messages.ErrLoadingCatalogues + Environment.NewLine + e.Error.Message; } if (!string.IsNullOrEmpty(errorMessage)) { MyLogger.Write(errorMessage, "bkgCatalogues_RunWorkerCompleted", LoggingCategory.Exception); } } // status OK if (!e.Cancelled && e.Error == null) { ArrayList result = e.Result as ArrayList; Catalogues cataloguesPerUser = result[0] as Catalogues; SavingData sp = result[1] as SavingData; if (result[0] != null) { // check if catalogues exist bool areLoaded = this.AreCataloguesLoaded(cataloguesPerUser.ConnectionId); if (areLoaded) { // remove if exist this.RemoveCataloguesForConnection(cataloguesPerUser.ConnectionId); } // add catalogues per user globalCataloguesCollection.Add(cataloguesPerUser); if (this.CatalogueEvent != null) { this.CatalogueEvent(this, new MyZillaSettingsEventArgs(sp)); } } else { if (this.CatalogueEvent != null) { TDSettings.ConnectionRow connectionRow = sp.ConnectionRow; SavingData spWhenNullCatalogues = new SavingData(OperationType.AddConnectionThrowsError, connectionRow); this.CatalogueEvent(this, new MyZillaSettingsEventArgs(spWhenNullCatalogues)); } } } }
public SavingData(SavingData newData) { maxScore = newData.maxScore; pieces = newData.pieces; resurection = newData.resurection; }
public static void Runtime_LoadGame() { obj = GameManager.runtimeSaving.Peek(); SceneManager.LoadScene(obj.sceneName); GameObject.FindObjectOfType <Player2D>().transform.position = obj.PlayerTransform; }
public static void Runtime_SaveGame() { obj = new SavingData(); GameManager.save(obj); }
void LoadData() { savingData = JsonUtility.FromJson <SavingData>(PlayerPrefs.GetString("Saves")); PlayerInfo.PI.Health = savingData.healthCount; PlayerInfo.PI.Money = savingData.money; }
public void ExitToMenu() { SavingData.AddTheNumberOfCoins(GameSetups.Coins); SceneManager.LoadScene("Menu", LoadSceneMode.Single); }
public static void save(SavingData sd) { runtimeSaving.Push(sd); }