Esempio n. 1
0
    /**
     * this method gets the custom stage data from database
     * @param id - id of the custom stage requested
     */
    private IEnumerator getCustomStageFromFirebase(string id)
    {
        var DBTask = DBreference.Child("customStage").Child(id).GetValueAsync();

        yield return(new WaitUntil(predicate: () => DBTask.IsCompleted));

        if (DBTask.Exception != null)
        {
            Debug.LogWarning(message: $"Failed to register task with {DBTask.Exception}");
        }
        else
        {
            DataSnapshot snapshot = DBTask.Result;
            if (snapshot.Value == null)
            {
                if (errorMessage != null)
                {
                    errorMessage.SetActive(true);
                }
            }
            else
            {
                if (errorMessage != null)
                {
                    errorMessage.SetActive(false);
                }
                string     json        = snapshot.GetRawJsonValue();
                GameObject dataManager = GameObject.FindGameObjectWithTag("DataManager");
                customStage      = CustomStage.CreateFromJSON(json);
                customStageCheck = true;
                Debug.Log(customStage.questions[0]);
                SceneManager.LoadScene("test");
            }
        }
    }
Esempio n. 2
0
    /**
     * this method gets the custom stage data from database - this method is for testing only
     * @param id - id of the custom stage requested
     */
    private IEnumerator getCustomStageFromFirebase(string id)
    {
        var DBTask = DBreference.Child("customStage").Child(id).GetValueAsync();

        yield return(new WaitUntil(predicate: () => DBTask.IsCompleted));

        if (DBTask.Exception != null)
        {
            Debug.LogWarning(message: $"Failed to register task with {DBTask.Exception}");
        }
        else
        {
            DataSnapshot snapshot    = DBTask.Result;
            string       json        = snapshot.GetRawJsonValue();
            CustomStage  customStage = CustomStage.CreateFromJSON(json);
            Debug.Log(customStage.questions[0]);
        }
    }