// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.UpArrow)) { saveData.AddScore(1); PrintScore(); } if (Input.GetKeyDown(KeyCode.DownArrow)) { saveData.AddScore(-1); PrintScore(); } if (Input.GetKeyDown(KeyCode.S)) { PhoneSaveSystem.instance.Savephone(saveData); Debug.Log("Saved data."); } if (Input.GetKeyDown(KeyCode.L)) { saveData = PhoneSaveSystem.instance.Loadphone(); Debug.Log("Loaded data."); PrintScore(); } if (Input.GetKeyDown(KeyCode.X)) { saveData.ResetData(); PrintScore(); } }
public ActionResult DeleteConfirmed(int id) { phoneData phoneData = db.phoneData.Find(id); db.phoneData.Remove(phoneData); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Brand,ownerFirstName,timestamp")] phoneData phoneData) { if (ModelState.IsValid) { db.Entry(phoneData).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(phoneData)); }
public void Savephone(phoneData saveData) { FileStream dataStream = new FileStream(filePath, FileMode.Create); BinaryFormatter converter = new BinaryFormatter(); converter.Serialize(dataStream, saveData); dataStream.Close(); }
public ActionResult Create([Bind(Include = "ID,Brand,ownerFirstName,timestamp")] phoneData phoneData) { if (ModelState.IsValid) { db.phoneData.Add(phoneData); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(phoneData)); }
// GET: phoneDatas/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } phoneData phoneData = db.phoneData.Find(id); if (phoneData == null) { return(HttpNotFound()); } return(View(phoneData)); }
public phoneData Loadphone() { if (File.Exists(filePath)) { // File exists FileStream dataStream = new FileStream(filePath, FileMode.Open); BinaryFormatter converter = new BinaryFormatter(); phoneData saveData = converter.Deserialize(dataStream) as phoneData; dataStream.Close(); return(saveData); } else { // File does not exist Debug.LogError("Save file not found in " + filePath); return(null); } }