Ejemplo n.º 1
0
        public void PostScores(string userName,
                               string tspName,
                               double algoScore,
                               int algoBestIteration,
                               string algoTour,
                               double userScore,
                               int userBestIteration,
                               string userTour,
                               int timeInMillis,
                               Guid guid,
                               string platform
                               )
        {
            string url        = AddScoreURL.TrimEnd('?');
            var    postValues = new Dictionary <string, string>();

            postValues["name"]    = userName;
            postValues["tspname"] = tspName;

            postValues["algoscore"]         = algoScore.ToString();
            postValues["algobestiteration"] = algoBestIteration.ToString();
            postValues["algotour"]          = algoTour;

            postValues["userscore"]         = userScore.ToString();
            postValues["userbestiteration"] = userBestIteration.ToString();
            postValues["usertour"]          = userTour;
            postValues["time"]     = timeInMillis.ToString();
            postValues["ID"]       = guid.ToString();
            postValues["platform"] = platform.ToString();

            postValues["hash"] = Hash(SecretKey);

#if UNITY_STANDALONE_WIN
            var hsPost = WebFunctions.Post(url, postValues);

            print("HSPOST " + hsPost.url);

            if (!string.IsNullOrEmpty(hsPost.error))
            {
                print("There was an error posting the high score: " + hsPost.error);
            }
#endif

#if UNITY_WEBGL || UNITY_IOS || UNITY_ANDROID || UNITY_WP8 || UNITY_IPHONE
            StartCoroutine(PostScoresAsync(guid, userName, tspName, algoScore, algoBestIteration, algoTour, userScore, userBestIteration, userTour, timeInMillis, platform));
#endif
        }