/* Used for reading Eddystone format from DB */ void ReadFromDB() { DataSnapshot snapshot; Debug.Log("------Start Read------"); FirebaseDatabase.DefaultInstance.GetReference("KidsClubLog").Child("165068935866").GetValueAsync().ContinueWith(task => { if (task.IsFaulted) { // Handle the error... Debug.LogError("Error reading from db"); } else if (task.IsCompleted) { snapshot = task.Result; Debug.Log("My Value: " + snapshot.GetRawJsonValue()); var read = snapshot.Child("Read").Value.ToString(); Debug.Log("*****" + read); if (read == "1") { readCompleteDBWrite("165068935866"); sceneFlow.FadeSceneIn(childNum); //parentProfilePic.gameObject.SetActive(true); } Debug.Log("Read Success!"); } //Debug.Log("------End Read------"); }); }
void SceneChange() { //Debug.Log("Scene change: " + sceneNum); if (fadeScene && !fadeOutScene && !slideSceneOut) { sceneFlow.FadeSceneIn(sceneNum); } if (!fadeScene && !fadeOutScene && !slideSceneOut) { sceneFlow.SlideSceneIn(sceneNum); } if (!fadeScene && fadeOutScene && !slideSceneOut) { sceneFlow.FadeSceneOut(sceneNum); sceneFlow.currentPage = backSceneNum; } if (!fadeScene && !fadeOutScene && slideSceneOut) { sceneFlow.SlideSceneOut(sceneNum); sceneFlow.currentPage = backSceneNum; } //everytime we change screen, we update the current screen to database, so the RPI will know which page we are on firebase.updateScreenPage(sceneFlow.currentPage); }
void SceneChange() { switch (transition) { case Transition.FadeInScene: sceneFlow.FadeSceneIn(sceneNum); break; case Transition.FadeOutScene: sceneFlow.FadeSceneOut(sceneNum); break; case Transition.SlideSceneIn: sceneFlow.SlideSceneIn(sceneNum, vertical); break; case Transition.SlideSceneOut: sceneFlow.SlideSceneOut(sceneNum, vertical); break; case Transition.BackSceneOut: sceneFlow.KillCard(sceneNum); break; case Transition.MultiSceneBackOut: foreach (int num in multiSceneNum) { sceneFlow.KillCard(num); } break; case Transition.MultiSceneBackOutFade: foreach (int num in multiSceneNum) { sceneFlow.FadeSceneOut(num); } break; case Transition.MultiSceneBackOutSlide: foreach (int num in multiSceneNum) { sceneFlow.SlideSceneOut(num, vertical); } break; default: break; } // //everytime we change screen, we update the current screen to database, so the RPI will know which page we are on // if (firebaseE != null){ // firebaseE.updateScreenPage(sceneFlow.currentPage); // } // else { // firebaseR.updateScreenPage(sceneFlow.currentPage); // } }
void HandleValueChanged(object sender, ValueChangedEventArgs args) { if (args.DatabaseError != null) { Debug.LogError(args.DatabaseError.Message); return; } // only check if user at page 0 in the app if (sceneFlow.currentPage == 0) { if (args.Snapshot != null && args.Snapshot.ChildrenCount > 0) { foreach (var childSnapshot in args.Snapshot.Children) { if (childSnapshot.Child("RegistrationRead") == null || childSnapshot.Child("RegistrationRead").Value == null) { Debug.LogError("Bad data in sample. Did you forget to call SetEditorDatabaseUrl with your project id?"); break; } else { // If read value = 1, a new RFID just scanned from the RPI if (childSnapshot.Child("RegistrationRead").Value.ToString() == "1") { // REGISTRATION APP // 1011973426216 if (childSnapshot.Key == "1011973426216" && sceneFlow.currentPage == 0) { // Debug.Log("Switch to page 1"); RunOnMainThread <int>(() => { sceneFlow.FadeSceneIn(1); // updateScreenPage(1); return(0); }); } //update child read back to 0 after the app use it resetReadValue(childSnapshot.Key); } } } } }// end if checking currentPage }
void HandleValueChanged(object sender, ValueChangedEventArgs args) { if (args.DatabaseError != null) { Debug.LogError(args.DatabaseError.Message); return; } // Debug.Log("Current Page: " + sceneFlow.currentPage); // Debug.Log(args.Snapshot.GetRawJsonValue()); // if (sceneFlow.currentPage == 30 || // sceneFlow.currentPage == 31 || // sceneFlow.currentPage == 1 || // sceneFlow.currentPage == 18 || // sceneFlow.currentPage == 17 // ) //only check if user at page 1.1, 2.1, 2.2, 3.2, 3.3 if (sceneFlow.currentPage == 0 || sceneFlow.currentPage == 8) { if (args.Snapshot != null && args.Snapshot.ChildrenCount > 0) { foreach (var childSnapshot in args.Snapshot.Children) { if (childSnapshot.Child("Read") == null || childSnapshot.Child("Read").Value == null) { Debug.LogError("Bad data in sample. Did you forget to call SetEditorDatabaseUrl with your project id?"); break; } else { // If read value = 1, a new RFID just scanned from the RPI if (childSnapshot.Child("Read").Value.ToString() == "1") { if (sceneFlow.currentPage == 0) { Debug.Log("Switch to page 5"); RunOnMainThread <int>(() => { // sceneFlow.FadeSceneIn(5); // sceneFlow.FadeSceneOut(0); sceneFlow.SlideSceneIn(5, false); updateScreenPage(5); return(0); }); } else if (sceneFlow.currentPage == 8) { Debug.Log("Switch to page 6"); RunOnMainThread <int>(() => { sceneFlow.FadeSceneIn(6); sceneFlow.FadeSceneOut(8); // sceneFlow.SlideSceneIn(6, false); updateScreenPage(6); return(0); }); } //update child read back to 0 after the app use it, also set correctCard true or false updateChild(childSnapshot.Key); } } } } }// end if checking currentPage }
void HandleValueChanged(object sender, ValueChangedEventArgs args) { if (args.DatabaseError != null) { Debug.LogError(args.DatabaseError.Message); return; } Debug.Log("Current Page: " + sceneFlow.currentPage); Debug.Log(args.Snapshot.GetRawJsonValue()); if (sceneFlow.currentPage == 30 || sceneFlow.currentPage == 31 || sceneFlow.currentPage == 1 || sceneFlow.currentPage == 18 || sceneFlow.currentPage == 17 ) //only check if user at page 1.1, 2.1, 2.2, 3.2, 3.3 { if (args.Snapshot != null && args.Snapshot.ChildrenCount > 0) { foreach (var childSnapshot in args.Snapshot.Children) { if (childSnapshot.Child("Read") == null || childSnapshot.Child("Read").Value == null) { Debug.LogError("Bad data in sample. Did you forget to call SetEditorDatabaseUrl with your project id?"); break; } else { // If read value = 1, a new RFID just scanned from the RPI if (childSnapshot.Child("Read").Value.ToString() == "1") { // 165068935866: CHILD CHECKIN // 853040429192: CHILD CHECKOUT //225111446012: EMPLOYEE //225094668797: PARENT Debug.Log(childSnapshot.Key); Debug.Log(childSnapshot.GetRawJsonValue()); //Debug.Log(childSnapshot.Child("Parent").Value.ToString()); //Debug.Log(childSnapshot.Child("Child").Value.ToString()); //Debug.Log(childSnapshot.Child("Read").Value.ToString()); //do something here, for example set active for gameobject //Figure out how to launch different scenes based on values, one for child, one for parent. The methods are below // if this is child card, from 3.2 navigate to 3.1.1 screen if (childSnapshot.Key == "165068935866" && sceneFlow.currentPage == 30) { Debug.Log("switch to page 28"); RunOnMainThread <int>(() => { sceneFlow.FadeSceneOut(30); sceneFlow.FadeSceneIn(28); updateScreenPage(28); return(0); }); } // if this is child card, from 3.3 navigate to 3.1.2 screen if (childSnapshot.Key == "853040429192" && sceneFlow.currentPage == 31) { Debug.Log("switch to page 29"); RunOnMainThread <int>(() => { sceneFlow.FadeSceneOut(31); sceneFlow.FadeSceneIn(29); updateScreenPage(29); return(0); }); } // if this is parent card, from 1.1 navigate to 1.3 screen if (childSnapshot.Key == "225094668797" && sceneFlow.currentPage == 1) { Debug.Log("Switch to page 2"); RunOnMainThread <int>(() => { sceneFlow.FadeSceneIn(2); updateScreenPage(2); return(0); }); } // if this is parent card, from 2.2 navigate to 3.1 screen if (childSnapshot.Key == "225094668797" && sceneFlow.currentPage == 18) { Debug.Log("Switch to page 27"); RunOnMainThread <int>(() => { sceneFlow.FadeSceneIn(27); updateScreenPage(27); return(0); }); } // if this is employee card, from 2.1 navigate to 2.2 screen if (childSnapshot.Key == "225111446012" && sceneFlow.currentPage == 17) { Debug.Log("Switch to page 18"); RunOnMainThread <int>(() => { sceneFlow.FadeSceneIn(18); updateScreenPage(18); return(0); }); } //update child read back to 0 after the app use it, also set correctCard true or false updateChild(childSnapshot.Key); } } } } }// end if checking currentPage }
void HandleValueChanged(object sender, ValueChangedEventArgs args) { if (args.DatabaseError != null) { Debug.LogError(args.DatabaseError.Message); return; } // Debug.Log("Current Page: " + sceneFlow.currentPage); // Debug.Log(args.Snapshot.GetRawJsonValue()); // only check if user at page 0, 8, 9 in the app if (sceneFlow.currentPage == 0 || sceneFlow.currentPage == 8 || sceneFlow.currentPage == 9) { if (args.Snapshot != null && args.Snapshot.ChildrenCount > 0) { foreach (var childSnapshot in args.Snapshot.Children) { if (childSnapshot.Child("EmployeeRead") == null || childSnapshot.Child("EmployeeRead").Value == null) { Debug.LogError("Bad data in sample. Did you forget to call SetEditorDatabaseUrl with your project id?"); break; } else { // If read value = 1, a new RFID just scanned from the RPI if (childSnapshot.Child("EmployeeRead").Value.ToString() == "1") { // EMPLOYEE APP // 225094668797 -> Parent Card // 225111446012 -> Employee Card // 165068935866 -> Child Card (Check In) // 584189768852 -> Wildband (Check In AND Check Out) // 584196215187 -> Wildband 2 (Check In AND Check Out) if (childSnapshot.Key == "225094668797" || childSnapshot.Key == "225111446012" || childSnapshot.Key == "165068935866" || childSnapshot.Key == "584189768852" || childSnapshot.Key == "584196215187") { if (sceneFlow.currentPage == 0) { Debug.Log("Switch to page 5"); RunOnMainThread <int>(() => { // sceneFlow.FadeSceneIn(5); // sceneFlow.FadeSceneOut(0); sceneFlow.SlideSceneIn(5, false); // updateScreenPage(5); return(0); }); } else if (sceneFlow.currentPage == 8) { Debug.Log("Switch to page 6"); RunOnMainThread <int>(() => { sceneFlow.FadeSceneIn(6); sceneFlow.FadeSceneOut(8); // updateScreenPage(6); return(0); }); } else if (sceneFlow.currentPage == 9) { Debug.Log("Switch to page 7"); RunOnMainThread <int>(() => { sceneFlow.FadeSceneIn(7); sceneFlow.FadeSceneOut(9); // updateScreenPage(7); return(0); }); } } //update child read back to 0 after the app use it, also set correctCard true or false resetReadValue(childSnapshot.Key); } } } } }// end if checking currentPage }