Beispiel #1
0
        public void GetAchievement(String achievementCode)
        {
            if (!ApiReady() || !IsLoggedIn())
            {
                return;
            }

            string url = _baseURL + "/achievement?code=" + achievementCode;

            QGCNio.CreateSubmitWWW(url, null, _authToken, CategoryType.QGC_GetAchievemnt);
        }
Beispiel #2
0
        public void GetAllAchievements()
        {
            if (!ApiReady() || !IsLoggedIn())
            {
                return;
            }

            string url = _baseURL + "/achievements?game=" + _gameKey;

            QGCNio.CreateSubmitWWW(url, null, _authToken, CategoryType.QGC_GetAllAchievements);
        }
Beispiel #3
0
        public void GetPlayerScore()
        {
            if (!ApiReady() || !IsLoggedIn())
            {
                return;
            }

            string url = _baseURL + "/score?leaderboard=" + _leaderboardKey;

            QGCNio.CreateSubmitWWW(url, null, _authToken, CategoryType.QGC_GetPlayerScore);
        }
Beispiel #4
0
        public void GetAllScores(int page, int size)
        {
            if (!ApiReady() || !IsLoggedIn())
            {
                return;
            }

            string url = _baseURL + "/scores?leaderboard=" + _leaderboardKey + "&page=" + page + "&size=" + size;

            QGCNio.CreateSubmitWWW(url, null, _authToken, CategoryType.QGC_GetAllScores);
        }
Beispiel #5
0
        public void SilentLogin()
        {
            if (!ApiReady() && PlayerPrefs.HasKey("_authToken"))
            {
                return;
            }

            string url = _baseURL + "/player";

            _authToken = PlayerPrefs.GetString("_authToken");
            QGCNio.CreateSubmitWWW(url, null, _authToken, CategoryType.QGC_Login);
        }
Beispiel #6
0
        public void UnlockAchievement(String achievementCode)
        {
            if (!ApiReady() || !IsLoggedIn())
            {
                return;
            }

            string url = _baseURL + "/unlockachievement";

            QGCAchievementUnlockSend pls = new QGCAchievementUnlockSend();

            pls.AchievementCode = achievementCode;
            string userObj = JsonConvert.SerializeObject(pls);

            QGCNio.CreateSubmitWWW(url, userObj, _authToken, CategoryType.QGC_UnlockAchievement);
        }
Beispiel #7
0
        public void Login(string username, string password)
        {
            if (!ApiReady())
            {
                return;
            }
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                API.LogWarning("Username/Pass must not be empty");
                return;
            }
            string url = _baseURL + "/player";

            _authToken = encodeAuth(username + ":" + password);
            QGCNio.CreateSubmitWWW(url, null, _authToken, CategoryType.QGC_Login);
        }
Beispiel #8
0
        public void UpdateProfile(QGCPlayerSend pls)
        {
            if (!ApiReady())
            {
                return;
            }
            if (string.IsNullOrEmpty(pls.PlayerDisplayName))
            {
                API.LogWarning("Mandatory fields must be completed");
                return;
            }
            string url = _baseURL + "/update";

            string userObj = JsonConvert.SerializeObject(pls);

            QGCNio.CreateSubmitWWW(url, userObj, _authToken, CategoryType.QGC_UpdateProfile);
        }
Beispiel #9
0
        public void Register(QGCPlayerSend pls)
        {
            if (!ApiReady())
            {
                return;
            }
            if (string.IsNullOrEmpty(pls.PlayerUsername) || string.IsNullOrEmpty(pls.PlayerPassword) || string.IsNullOrEmpty(pls.PlayerDisplayName))
            {
                API.LogWarning("Mandatory fields must be completed");
                return;
            }
            string url = _baseURL + "/register";

            pls.PlayerPlatform = QGCUtils.GetSystem();
            string userObj = JsonConvert.SerializeObject(pls);

            _authToken = encodeAuth(pls.PlayerUsername + ":" + pls.PlayerPassword);

            QGCNio.CreateSubmitWWW(url, userObj, CategoryType.QGC_Register);
        }
Beispiel #10
0
        public void SubmitScore(int score)
        {
            if (!ApiReady() || !IsLoggedIn())
            {
                return;
            }
            if (score < 0)
            {
                API.LogWarning("Score must not be negative");
                return;
            }

            string             url = _baseURL + "/score";
            QGCPlayerScoreSend pls = new QGCPlayerScoreSend();

            pls.LeaderboardId = _leaderboardKey;
            pls.PlayerScore   = score;
            string userObj = JsonConvert.SerializeObject(pls);

            QGCNio.CreateSubmitWWW(url, userObj, _authToken, CategoryType.QGC_SubmitScore);
        }