Exemple #1
0
 // Update is called once per frame
 void Update()
 {
     // if its time to fetch info
     // FetchInfo();
     currentTimeLeft    -= Time.deltaTime;
     currentVisTimeLeft -= Time.deltaTime;
     if (currentTimeLeft < 0)
     {
         //Debug.Log ("checking text");
         StartCoroutine(FetchInfo());
         currentTimeLeft = timeLeft;
     }
     if (currentVisTimeLeft < 0 && lastVisitorCount > 0)
     {
         //Debug.Log ("Vistime rand out:" + currentVisTimeLeft);
         Texture2D snap = null;
         visGen.AddEntry(snap, "", currentDate, currentTime, lastVisitorCount);
         currentVisTimeLeft = visTime;
         //Debug.Log ("Setting  currentVisTimeLeft to: " + currentVisTimeLeft);
         GuestEntryData guestData = dataManager.LocalCopyOfData;
         guestData.guestAvatar.Add(new byte[] {  });                   // 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
         guestData.time.Add(currentTime);
         guestData.date.Add(currentDate);
         guestData.count.Add(lastVisitorCount);
         //Debug.Log ("lastVisitorCount: " + lastVisitorCount.ToString());
         guestData.text.Add("");
         lastVisitorCount = 0;
         dataManager.SaveData(guestData);
     }
 }
Exemple #2
0
    public void LoadData()
    {
        //if (!Directory.Exists ("Saves")) {
        //	Directory.CreateDirectory ("Saves");
        //}

        if (!File.Exists(Application.persistentDataPath + "save.binary"))
        {
            File.Create(Application.persistentDataPath + "save.binary");
        }

        BinaryFormatter formatter = new BinaryFormatter();
        FileStream      saveFile  = File.Open(Application.persistentDataPath + "save.binary", FileMode.Open);

        try {
            LocalCopyOfData = (GuestEntryData)formatter.Deserialize(saveFile);
        }
        catch (System.Exception e) {
            LocalCopyOfData = new GuestEntryData {
            };
            LocalCopyOfData.init();
            return;
        }
        finally {
            saveFile.Close();
        }
        return;
    }
Exemple #3
0
    public void SaveData(GuestEntryData data)
    {
        //if (!Directory.Exists ("Saves")) {
        //	Directory.CreateDirectory ("Saves");
        //}

        BinaryFormatter formatter = new BinaryFormatter();
        FileStream      saveFile  = File.Create(Application.persistentDataPath + "save.binary");

        LocalCopyOfData = data;

        formatter.Serialize(saveFile, LocalCopyOfData);

        saveFile.Close();
    }
Exemple #4
0
    public void sendData()
    {
        if (inputField.text == "" && camControl.snapshot == null)
        {
            return;
        }

        if (dataManager.LocalCopyOfData == null)
        {
            dataManager.LoadData();
        }

        guestData = dataManager.LocalCopyOfData;

        System.DateTime.Now.ToString("MMMM");
        string currentDate = System.DateTime.Now.ToString("dd");

        currentDate += GetDaySuffix(System.DateTime.Now.Day);
        currentDate += " " + System.DateTime.Now.ToString("MMMM");
        string currentTime = System.DateTime.Now.ToString("hh:mm tt");

        guestData.time.Add(currentTime);
        guestData.date.Add(currentDate);
        guestData.text.Add(inputField.text);
        guestData.count.Add(0);

        if (camControl.snapshot != null)
        {
            guestData.guestAvatar.Add(camControl.snapshot.EncodeToPNG());
        }
        else
        {
            guestData.guestAvatar.Add(new byte[] {  });
        }

        visGen.AddEntry(camControl.snapshot, inputField.text, currentDate, currentTime, 0);
        // call SaveData
        dataManager.SaveData(guestData);

        // reset guestbook
        inputField.text         = "";
        pictureAvatar.texture   = null;
        camControl.snapshot     = null;
        camControl.pictureTaken = false;
    }