Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        DynamicLinks.DynamicLinkReceived += OnDynamicLink;

        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(continuationAction: task =>
        {
            FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
        });
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                // Create and hold a reference to your FirebaseApp,
                // where app is a Firebase.FirebaseApp property of your application class.
                app = Firebase.FirebaseApp.DefaultInstance;

                // Set a flag here to indicate whether Firebase is ready to use by your app.
            }
            else
            {
                UnityEngine.Debug.LogError(System.String.Format(
                                               "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
            }
        });

        /*
         * FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(continuationAction: task =>
         * {
         *  FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
         * });*/
    }
Example #2
0
 public void Start()
 {
     Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
         var dependencyStatus = task.Result;
         if (dependencyStatus == Firebase.DependencyStatus.Available)
         {
             // Create and hold a reference to your FirebaseApp,
             // where app is a Firebase.FirebaseApp property of your application class.
             app = Firebase.FirebaseApp.DefaultInstance;
             Firebase.Messaging.FirebaseMessaging.SubscribeAsync("/topics/ar").ContinueWith(res =>
             {
                 Firebase.Messaging.FirebaseMessaging.TokenReceived   += OnTokenReceived;
                 Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
                 Debug.Log("Firebase initialized");
             });
             // Set a flag here to indicate whether Firebase is ready to use by your app.
         }
         else
         {
             UnityEngine.Debug.LogError(System.String.Format(
                                            "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
             // Firebase Unity SDK is not safe to use here.
         }
     });
 }
Example #3
0
	private void Start()
	{
		Time.timeScale = 1f;
		DontDestroyOnLoad(this);
		SoundManager.instance.Refresh();

		Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
			var dependencyStatus = task.Result;
			if (dependencyStatus == Firebase.DependencyStatus.Available)
			{
				// Create and hold a reference to your FirebaseApp,
				// where app is a Firebase.FirebaseApp property of your application class.
				app = Firebase.FirebaseApp.DefaultInstance;

				// Set a flag here to indicate whether Firebase is ready to use by your app.
			}
			else
			{
				UnityEngine.Debug.LogError(System.String.Format(
				  "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
				// Firebase Unity SDK is not safe to use here.
			}
		});

		InitAppsFlyer();
		//FBSDKInit();

		banner.SetActive(!playerData.purchasedNoAds);
	}
Example #4
0
        public void get_scores_from_database()
        {
            Debug.Log("Getting scores from database");

            // Get app
            app = CommonData.app;
            // Get database instance
            _prediction_database = Firebase.Database.FirebaseDatabase.GetInstance(app);
            // Get user from authentication
            auth = Firebase.Auth.FirebaseAuth.DefaultInstance;

            // Seee if data exists at query
            Query score_query = _prediction_database.RootReference.Child("user_scores").Child("premier_league").OrderByChild("score");

            score_query.GetValueAsync().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    // task faulted
                    Debug.Log("task faulted");
                }
                else if (task.IsCompleted)
                {
                    Debug.Log(" get scores task completed");
                    // Get snapshot from task
                    DataSnapshot snapshot = task.Result;
                    // Set snapshot
                    CommonData._database_scores = snapshot;
                    CommonData._loaded_scores   = true;
                }
            });
        }
Example #5
0
    /// <summary>
    /// The play services version must be up to date, so the Firebase features could work.
    /// This function checks the play services version.
    /// </summary>
    public void CheckPlayServicesVersion()
    {
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                // Create and hold a reference to your FirebaseApp, i.e.
                app           = Firebase.FirebaseApp.DefaultInstance;
                firebaseReady = true;

                // where app is a Firebase.FirebaseApp property of your application class.
                // Set a flag here indicating that Firebase is ready to use by your
                // application.
                InitializeFirebase();
#if UNITY_EDITOR
                SetEditorAuthValues();
#endif
                // Get the root reference location of the database.
                dbReference = FirebaseDatabase.DefaultInstance.RootReference;
                Debug.Log("Firebase dbReference: " + dbReference);
            }
            else
            {
                UnityEngine.Debug.LogError(System.String.Format(
                                               "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
                firebaseReady = false;
            }
        });
    }
Example #6
0
    void Awake()
    {
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                Debug.Log("Create and hold a reference to your FirebaseApp, 만들다 파이어 베이스 앱");
                // Create and hold a reference to your FirebaseApp,
                // where app is a Firebase.FirebaseApp property of your application class.
                app = Firebase.FirebaseApp.DefaultInstance;

                if (app == null)
                {
                    Debug.Log("널입니다");
                }
                // Set a flag here to indicate whether Firebase is ready to use by your app.
            }
            else
            {
                UnityEngine.Debug.LogError(System.String.Format(
                                               "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
            }
        });


        if (app == null)
        {
            Debug.Log("널입니다");
        }
        firebaseAuth = Firebase.Auth.FirebaseAuth.DefaultInstance;
    }
Example #7
0
    private IEnumerator FirebaseAppInitEnumerator()
    {
        bool hasFinished = false;

        // Initialize Firebase
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                // Create and hold a reference to your FirebaseApp,
                // where app is a Firebase.FirebaseApp property of your application class.
                // Crashlytics will use the DefaultInstance, as well;
                // this ensures that Crashlytics is initialized.
                Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;

                // Set a flag here for indicating that your project is ready to use Firebase.
            }
            else
            {
                UnityEngine.Debug.LogError(System.String.Format(
                                               "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
            }

            hasFinished = true;
        });

        yield return(new WaitUntil(() => hasFinished));
    }
    public void CheckIfReady()
    {
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            Firebase.DependencyStatus dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
                firebaseReady            = true;

                Debug.Log("Firebase is ready for use.");

                // Create and hold a reference to your FirebaseApp, i.e.
                //   app = Firebase.FirebaseApp.DefaultInstance;
                // where app is a Firebase.FirebaseApp property of your application class.

                // Set a flag here indicating that Firebase is ready to use by your
                // application.
            }
            else
            {
                firebaseReady = false;
                UnityEngine.Debug.LogError(System.String.Format(
                                               "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
            }
        });
    }
Example #9
0
        private bool check_if_user_name_in_use(string user_name)
        {
            bool is_user_name_taken = false;

            // Check realtime database for user name
            app = CommonData.app;
            Firebase.Database.FirebaseDatabase user_db = Firebase.Database.FirebaseDatabase.GetInstance(app);
            user_db.RootReference.Child("users").Child(user_name).GetValueAsync().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    // Handle the error...
                }
                else if (task.IsCompleted)
                {
                    DataSnapshot snapshot = task.Result;
                    foreach (DataSnapshot user in snapshot.Children)
                    {
                        if ((string)user.Value == user_name)
                        {
                            is_user_name_taken = true;
                            return;
                        }
                    }
                    return;
                }
            });
            return(is_user_name_taken);
        }
        private void get_global_position()
        {
            // Just find rank of total score for all users
            // Would be nice if this makes a table in future for all users
            app = CommonData.app;
            _prediction_database = Firebase.Database.FirebaseDatabase.GetInstance(app);
            string path = "user_scores";

            Query myquery = _prediction_database.RootReference.Child(path).Child("premier_league").OrderByChild("score");

            myquery.GetValueAsync().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Debug.Log("task faulted");
                }
                else if (task.IsCompleted)
                {
                    DataSnapshot snapshot = task.Result;
                    Debug.Log("SNAPSHOT value = " + snapshot.Value);
                    Debug.Log("SNAPSHOT key = " + snapshot.Key);
                    Debug.Log("SNAPSHOT reference = " + snapshot.Reference);
                    Debug.Log("top score? = " + snapshot.Child("score").Value);
                }
            });
        }
Example #11
0
    void InitializeFireBase()
    {
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                // Create and hold a reference to your FirebaseApp,
                // where app is a Firebase.FirebaseApp property of your application class.
                //   app = Firebase.FirebaseApp.DefaultInstance;
                FirebaseApp = Firebase.FirebaseApp.DefaultInstance;

                // Set a flag here to indicate whether Firebase is ready to use by your app.
                Firebase.Analytics.FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);


                Firebase.Messaging.FirebaseMessaging.TokenReceived   += OnTokenReceived;
                Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
            }
            else
            {
                UnityEngine.Debug.LogError(System.String.Format(
                                               "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
                Firebase.Analytics.FirebaseAnalytics.SetAnalyticsCollectionEnabled(false);
            }
        });
    }
Example #12
0
        void get_fixtures_from_database()
        {
            Debug.Log("In: get_fixtures_from_database");

            List <fixture_class> C_Fixtures = new List <fixture_class>(); // TODO: think of better name

            // Read from the database if user has set these scores before
            // (make them blue)
            app = CommonData.app;
            _prediction_database = Firebase.Database.FirebaseDatabase.GetInstance(app);
            // Get user from authentication
            auth = Firebase.Auth.FirebaseAuth.DefaultInstance;

            foreach (DataSnapshot child in CommonData._database_fixtures.Children)
            {
                //Debug.Log(child.Key);
                // Create temporary fixure class
                fixture_class fix_temp = new fixture_class();
                // Get match id
                fix_temp.match_id = child.Key;
                // Get home team
                //Debug.Log("home_team??? " + child.Child("home_team").Value);
                fix_temp.home_team = child.Child("home_team").Value.ToString();
                // Get away team
                //Debug.Log("away_team??? " + child.Child("away_team").Value);
                fix_temp.away_team = child.Child("away_team").Value.ToString();
                // Get date
                //Debug.Log("home_team??? " + child.Child("time").Value);
                string time = child.Child("time").Value.ToString();
                //Debug.Log("home_team??? " + child.Child("date").Value);
                string   date = child.Child("date").Value.ToString();
                DateTime fix_date;
                fix_date = new DateTime(Int32.Parse("20" + date.Substring(6, 2)), // year
                                        Int32.Parse(date.Substring(3, 2)),        // month
                                        Int32.Parse(date.Substring(0, 2)),        // day
                                        Int32.Parse(time.Substring(0, 2)),        // hour
                                        Int32.Parse(time.Substring(2, 2)),        // minute
                                        0);                                       // second
                // Convert to local user time
                //fix_date = ConvertTime_LondonToLocal(fix_date);

                fix_temp.fixture_date = fix_date;
                // Add fixture to list
                C_Fixtures.Add(fix_temp);
                // See if any fixtures within 7 days (includes past) TODO: link this value to a REMOTE CONFIG VALUE IN GOOGLE FIREBASE
                if (DateTime.Compare(DateTime.Now.AddDays(11), fix_date) > 0)
                {
                    // Check fixture is not in the past
                    if (DateTime.Compare(DateTime.Now, fix_date.AddMinutes(-30)) < 0)
                    {
                        // Create fixture UI
                        create_fixture_UI(fix_temp);
                        // If no fixtures going to be displayed then tell user
                        any_predictions_in_seven_days = true;
                        // In case error got displayed call again and it should be removed
                        check_for_error_message();
                    }
                }
            }
        }
Example #13
0
        private void submit_prediciton(string match_id, float home_pred, float away_pred)
        {
            //Debug.Log("Submitting prediction for match id:" + match_id);

            string match_id_str = "match_ID" + match_id;

            string user_id;
            string name_name;

            app = CommonData.app;
            _prediction_database = Firebase.Database.FirebaseDatabase.GetInstance(app);
            // Get user from authentication
            auth = Firebase.Auth.FirebaseAuth.DefaultInstance;

#if (UNITY_EDITOR)
            user_id   = "DESKTOP4";
            name_name = "DESKTOP4";
#else
            Debug.Log("in mobile");
            var user = auth.CurrentUser;
            user_id   = auth.CurrentUser.UserId;
            name_name = auth.CurrentUser.DisplayName;
#endif
            // Set the values in the database
            _prediction_database.RootReference.Child("predictions").Child(match_id_str).Child(user_id).Child("match_id").SetRawJsonValueAsync(match_id);
            _prediction_database.RootReference.Child("predictions").Child(match_id_str).Child(user_id).Child("home_prediction").SetValueAsync(home_pred);
            _prediction_database.RootReference.Child("predictions").Child(match_id_str).Child(user_id).Child("user_name").SetValueAsync(name_name);
            _prediction_database.RootReference.Child("predictions").Child(match_id_str).Child(user_id).Child("away_prediction").SetValueAsync(away_pred);
        }
Example #14
0
    // Start is called before the first frame update
    void Start()
    {
        //Initialize Firebase

        //Script coming from google's tutorial
        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                // Create and hold a reference to your FirebaseApp,
                // where app is a Firebase.FirebaseApp property of your application class.
                // Crashlytics will use the DefaultInstance, as well;
                // this ensures that Crashlytics is initialized.
                Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;

                // Set a flag here for indicating that your project is ready to use Firebase.
                Firebase.FirebaseApp.LogLevel = Firebase.LogLevel.Debug;
            }
            else
            {
                UnityEngine.Debug.LogError(System.String.Format(
                                               "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
            }
        });
    }
Example #15
0
    void Start()
    {
        DontDestroyOnLoad(gameObject);

        Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;
            if (dependencyStatus == Firebase.DependencyStatus.Available)
            {
                // Create and hold a reference to your FirebaseApp, i.e.
                //   app = Firebase.FirebaseApp.DefaultInstance;
                // where app is a Firebase.FirebaseApp property of your application class.

                app = Firebase.FirebaseApp.DefaultInstance;

                // Set a flag here indicating that Firebase is ready to use by your
                // application.
                ready = true;
            }
            else
            {
                UnityEngine.Debug.LogError(System.String.Format(
                                               "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
            }
        });
    }
Example #16
0
 public DBStruct(string name, Firebase.FirebaseApp app)
 {
     this.app   = app;
     database   = Firebase.Database.FirebaseDatabase.GetInstance(this.app);
     dbPathName = name;
     data       = new T();
     newData    = new T();
     database.GetReference(dbPathName).ValueChanged += OnDataChanged;
 }
Example #17
0
    private void initFirebase()
    {
        Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
        app.SetEditorDatabaseUrl("https://lazzybee3d-99751721.firebaseio.com/");

        mReference = FirebaseDatabase.DefaultInstance.RootReference;
        mDatabase  = FirebaseDatabase.DefaultInstance;

        mAuth = Firebase.Auth.FirebaseAuth.DefaultInstance;
    }
Example #18
0
    public DBTable(string name, Firebase.FirebaseApp app)
    {
        this.app       = app;
        tableName      = name;
        database       = Firebase.Database.FirebaseDatabase.GetInstance(this.app);
        data           = new Dictionary <string, DBObj <T> >();
        newData        = new Dictionary <string, T>();
        deletedEntries = new List <string>();

        addListeners();
    }
Example #19
0
        private void add_user_to_database(string user_name, string email_address)
        {
            Debug.Log("adding user to database");
            app            = CommonData.app;
            _user_database = Firebase.Database.FirebaseDatabase.GetInstance(app);

            var user = auth.CurrentUser;
            var uid  = user.UserId;

            _user_database.RootReference.Child("users").Child(uid).Child("user_name").SetRawJsonValueAsync(user_name);
            _user_database.RootReference.Child("users").Child(uid).Child("email").SetRawJsonValueAsync(email_address);
        }
Example #20
0
        // Use this for initialization
        void Start()
        {
            Debug.Log("STARTING PREDICTION");
            app = CommonData.app;
            _prediction_database = Firebase.Database.FirebaseDatabase.GetInstance(app);
            // Get user from authentication
            auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
            Debug.Log("app: " + app);

            // Starts the scene
            StartGame();
        }
        public static void Init(Android.Content.Context context)
        {
            var options = new FirebaseOptions.Builder()
                          .SetApplicationId("1:812309437328:android:25ce5624a3dfad6a55f115")
                          .SetApiKey("AIzaSyA8S9_ZKzmzRbebNsLOKxeBpI5r24-0D30")
                          .SetDatabaseUrl("https://authtrial-62711.firebaseio.com").SetProjectId("authtrial-62711").Build();

            app = Firebase.FirebaseApp.InitializeApp(context, options, AppName);
            FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
                                                 .SetPersistenceEnabled(true).Build();

            FirebaseFirestore.GetInstance(app).FirestoreSettings = settings;
        }
Example #22
0
    void Awake()
    {
        QualitySettings.vSyncCount = 1;
        app = null;

        if (!mInstance)
        {
            mInstance = this;
        }
        else
        {
            Destroy(this.gameObject);
            return;
        }
        if (isArcade)
        {
            Cursor.visible = false;
        }

        DontDestroyOnLoad(this.gameObject);

        settings       = GetComponent <Settings> ();
        modulesManager = GetComponent <ModulesManager> ();
        externalTexts  = GetComponent <ExternalTexts> ();
        playerData     = GetComponent <PlayerData> ();
        levelData      = GetComponent <LevelsData> ();
        interfaceSfx   = GetComponent <InterfaceSfx> ();
        users          = GetComponent <Users> ();

        if (resetData)
        {
            PlayerPrefs.DeleteAll();
        }

        int val = PlayerPrefs.GetInt("user");

        Debug.Log(val);

        if (val > 0)
        {
            Data.Instance.esAlumno = true;
        }


        if (esAlumno)
        {
            FBase_Login(false);
        }
    }
        void get_fixtures_from_database(List <fixture_class> fixture_class_list)
        {
            Debug.Log("Getting fixtures from database");

            // Get user home score prediction from database
            app = CommonData.app;
            _prediction_database = Firebase.Database.FirebaseDatabase.GetInstance(app);

            foreach (DataSnapshot child in CommonData._database_fixtures.Children)
            {
                fixture_class fix_temp = new fixture_class();

                // If match is in the future then dont bother and skip
                string   time = child.Child("time").Value.ToString();
                string   date = child.Child("date").Value.ToString();
                DateTime fix_date;
                fix_date = new DateTime(Int32.Parse("20" + date.Substring(6, 2)), // year
                                        Int32.Parse(date.Substring(3, 2)),        // month
                                        Int32.Parse(date.Substring(0, 2)),        // day
                                        Int32.Parse(time.Substring(0, 2)),        // hour
                                        Int32.Parse(time.Substring(2, 2)),        // minute
                                        0);                                       // second
                fix_temp.fixture_date = fix_date;
                if (DateTime.Compare(DateTime.Now, fix_date) < 0)
                {
                    continue;
                }

                fix_temp.match_id  = child.Key;
                fix_temp.home_team = child.Child("home_team").Value.ToString();
                fix_temp.away_team = child.Child("away_team").Value.ToString();

                fix_temp.home_result = int.Parse(child.Child("home_score").Value.ToString());
                fix_temp.away_result = int.Parse(child.Child("away_score").Value.ToString());

                fix_temp.matchday = int.Parse(child.Child("matchday").Value.ToString());

                //fixture_class_list.Add(fix_temp);
                if (fix_temp.home_result > -1 && fix_temp.away_result > -1)
                {
                    // NOW CHECK RESULTS
                    check_home_prediction(fix_temp);

                    // Add to total results to check
                    results_to_check++;
                }
            }
        }
Example #24
0
 private async void Start()
 {
     Firebase.FirebaseApp.CheckDependenciesAsync().ContinueWith(task =>
     {
         var dependencyStatus = task.Result;
         if (dependencyStatus == Firebase.DependencyStatus.Available)
         {
             Firebase.FirebaseApp app = Firebase.FirebaseApp.DefaultInstance;
         }
         else
         {
             Debug.LogError(System.String.Format(
                                "Could not resolve Firebase dependencies: {0}", dependencyStatus));
         }
     });
 }
Example #25
0
 private void DBConnect()
 {
     Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
     {
         var dependencyStatus = task.Result;
         if (dependencyStatus == Firebase.DependencyStatus.Available)
         {
             app    = Firebase.FirebaseApp.DefaultInstance;
             db_ref = FirebaseDatabase.DefaultInstance.RootReference;
             isDB   = true;
         }
         else
         {
             UnityEngine.Debug.LogError(System.String.Format(
                                            "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
         }
     });
 }
        private void add_score_to_db()
        {
            Debug.Log("ADDING SCORE TO DATABASE");

            app = CommonData.app;
            _prediction_database = Firebase.Database.FirebaseDatabase.GetInstance(app);
            // Get user from authentication
            auth = Firebase.Auth.FirebaseAuth.DefaultInstance;

            string display_name;
            string user_id;

#if (UNITY_EDITOR)
            user_id      = "DESKTOP4";
            display_name = "DESKTOP4";
#else
            Debug.Log("in mobile");
            var user = auth.CurrentUser;
            user_id      = auth.CurrentUser.UserId;
            display_name = auth.CurrentUser.DisplayName;
#endif
            // Set the values in the database
            //_prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).SetValueAsync(total_user_score);
            _prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).Child("name").SetValueAsync(display_name);
            // total_user_score
            _prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).Child("score").SetValueAsync(PlayerPrefs.GetInt("HighScore", 0));
            // User highest weekly score
            _prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).Child("highest_weekly_score").SetValueAsync(PlayerPrefs.GetInt("HighestWeeklyScore", 0));
            // The matchday on which the users highest weekly score occured
            _prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).Child("highest_weekly_score_matchday").SetValueAsync(PlayerPrefs.GetInt("HighestWeeklyScoreMatchday", 0));
            //
            _prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).Child("Prediction_SpotOn").SetValueAsync(PlayerPrefs.GetInt("Prediction_SpotOn", 0));
            _prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).Child("Prediction_Correct_result").SetValueAsync(PlayerPrefs.GetInt("Prediction_Correct_result", 0));
            _prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).Child("Prediction_Correct").SetValueAsync(PlayerPrefs.GetInt("Prediction_Correct", 0));
            _prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).Child("Prediction_Wrong").SetValueAsync(PlayerPrefs.GetInt("Prediction_Wrong", 0));
            _prediction_database.RootReference.Child("user_scores").Child("premier_league").Child(user_id).Child("Prediction_NotMade").SetValueAsync(PlayerPrefs.GetInt("Prediction_NotMade", 0));



            // Is this needed?
            get_global_position();
        }
Example #27
0
    //in order for a player to connect to the database, make sure this step happens first to set up the database instance
    public void CheckForDependencies()
    {
        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            var dependencyStatus = task.Result;
            //Checks to make sure Database is ready to go
            if (dependencyStatus == DependencyStatus.Available)
            {
                //Setting up the Default Instance for the Database
                app = FirebaseApp.DefaultInstance;
                app.SetEditorDatabaseUrl("https://monster-defender.firebaseio.com/");
                FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);

                Test();
            }
            else
            {
                Debug.LogError(string.Format(
                                   "Could not resolve all Firebase dependencies: {0}", dependencyStatus));
                // Firebase Unity SDK is not safe to use here.
            }
        });
    }
        public static FirebaseApp GetInstance(string name)
        {
            FirebaseApp.ThrowIfCheckDependenciesRunning();
            FirebaseApp firebaseApp = null;
            object      obj         = FirebaseApp.nameToProxy;
            FirebaseApp result;

            lock (obj)
            {
                WeakReference weakReference;
                if (FirebaseApp.nameToProxy.TryGetValue(name, out weakReference))
                {
                    firebaseApp = (FirebaseApp.WeakReferenceGetTarget(weakReference) as FirebaseApp);
                    if (firebaseApp == null)
                    {
                        FirebaseApp.nameToProxy.Remove(name);
                    }
                }
                result = firebaseApp;
            }
            return(result);
        }
        public static void InitialiseFirebase()
        {
            FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
            {
                var dependencyStatus = task.Result;

                if (dependencyStatus == DependencyStatus.Available)
                {
                    Debug.Log($"Firebase active.");
                    FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);

                    app = FirebaseApp.DefaultInstance;

                    fireBaseActive = true;
                }
                else
                {
                    Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}. Firebase inactive");
                    app            = null;
                    fireBaseActive = false;
                }
            });
        }
Example #30
0
        private static void PerformCleanup(IntPtr cleanupObjectCPtr, IntPtr notifyObjectCPtr, IntPtr context)
        {
            object obj = CleanupNotifier.cleanupIdToContext;

            lock (obj) {
                CleanupNotifier.ObjectCleanupContext objectCleanupContext;
                if (CleanupNotifier.cleanupIdToContext.TryGetValue((long)context, out objectCleanupContext))
                {
                    object notifyObject = objectCleanupContext.NotifyObject;
                    if (notifyObject != null)
                    {
                        FirebaseApp.LogMessage(LogLevel.Debug, string.Format("{0} (instance 0x{1:X}) will be disposed", objectCleanupContext.NotifyObjectType, (long)objectCleanupContext.NotifyObjectCPtr));
                        CleanupNotifierBridge.GetAndDestroyNotifiedFlag(notifyObjectCPtr);
                        objectCleanupContext.DisposeObject(notifyObject);
                    }
                    else
                    {
                        FirebaseApp.LogMessage(LogLevel.Debug, string.Format("{0} (instance 0x{1:X}) is being finalized, deleting object now", objectCleanupContext.NotifyObjectType, (long)objectCleanupContext.NotifyObjectCPtr));
                        objectCleanupContext.DeleteObject(new HandleRef(objectCleanupContext.NotifyObjectType, notifyObjectCPtr));
                    }
                }
            }
        }