コード例 #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);
         * });*/
    }
コード例 #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.
         }
     });
 }
コード例 #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);
	}
コード例 #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;
                }
            });
        }
コード例 #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;
            }
        });
    }
コード例 #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;
    }
コード例 #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));
    }
コード例 #8
0
    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.
            }
        });
    }
コード例 #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);
        }
コード例 #10
0
        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);
                }
            });
        }
コード例 #11
0
ファイル: GameManager.cs プロジェクト: lsoyul/ProjectJK
    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);
            }
        });
    }
コード例 #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();
                    }
                }
            }
        }
コード例 #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);
        }
コード例 #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.
            }
        });
    }
コード例 #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.
            }
        });
    }
コード例 #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;
 }
コード例 #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;
    }
コード例 #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();
    }
コード例 #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);
        }
コード例 #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();
        }
コード例 #21
0
        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;
        }
コード例 #22
0
ファイル: Data.cs プロジェクト: pontura/matematica
    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);
        }
    }
コード例 #23
0
        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++;
                }
            }
        }
コード例 #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));
         }
     });
 }
コード例 #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));
         }
     });
 }
コード例 #26
0
        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();
        }
コード例 #27
0
ファイル: Database.cs プロジェクト: m4gni2de/DefenderRPG
    //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.
            }
        });
    }
コード例 #28
0
        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);
        }
コード例 #29
0
        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;
                }
            });
        }
コード例 #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));
                    }
                }
            }
        }