Пример #1
0
 // 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();
     }
 }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            phoneData phoneData = db.phoneData.Find(id);

            db.phoneData.Remove(phoneData);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
 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));
 }
Пример #4
0
    public void Savephone(phoneData saveData)
    {
        FileStream dataStream = new FileStream(filePath, FileMode.Create);

        BinaryFormatter converter = new BinaryFormatter();

        converter.Serialize(dataStream, saveData);

        dataStream.Close();
    }
Пример #5
0
        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));
        }
Пример #6
0
        // 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));
        }
Пример #7
0
    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);
        }
    }