Exemple #1
0
    public static void Prepare(string section, string action, Dictionary <String, String> postdata, out string url, out WWWForm post)
    {
        var r = new System.Random();

        url = URL + "&r=" + r.Next(10000000) + "Z";
        var timestamp = (DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0))).TotalSeconds.ToString();
        var nonce     = Playtomic_Encode.MD5(timestamp + Playtomic.SourceUrl + Playtomic.GameGuid);

        var pd = new ArrayList();

        pd.Add("nonce=" + nonce);
        pd.Add("timestamp=" + timestamp);

        if (postdata != null)
        {
            foreach (string key in postdata.Keys)
            {
                pd.Add(key + "=" + Escape(postdata[key]));
            }
        }

        GenerateKey("section", section, ref pd);
        GenerateKey("action", action, ref pd);
        GenerateKey("signature", nonce + timestamp + section + action + url + Playtomic.GameGuid, ref pd);

        var joined = "";

        foreach (var item in pd)
        {
            joined += (joined == "" ? "" : "&") + item;
        }

        post = new WWWForm();
        post.AddField("data", Escape(Playtomic_Encode.Base64(joined)));
    }
 internal static void Initialise(string apikey)
 {
     SECTION = Playtomic_Encode.MD5("parse-" + apikey);
     SAVE    = Playtomic_Encode.MD5("parse-save-" + apikey);
     DELETE  = Playtomic_Encode.MD5("parse-delete-" + apikey);
     LOAD    = Playtomic_Encode.MD5("parse-load-" + apikey);
     FIND    = Playtomic_Encode.MD5("parse-find-" + apikey);
 }
Exemple #3
0
 internal static void Initialise(string apikey)
 {
     SECTION = Playtomic_Encode.MD5("playerlevels-" + apikey);
     RATE    = Playtomic_Encode.MD5("playerlevels-rate-" + apikey);
     LIST    = Playtomic_Encode.MD5("playerlevels-list-" + apikey);
     SAVE    = Playtomic_Encode.MD5("playerlevels-save-" + apikey);
     LOAD    = Playtomic_Encode.MD5("playerlevels-load-" + apikey);
 }
 internal static void Initialise(string apikey)
 {
     SECTION = Playtomic_Encode.MD5("leaderboards-" + apikey);
     CREATEPRIVATELEADERBOARD = Playtomic_Encode.MD5("leaderboards-createprivateleaderboard-" + apikey);
     LOADPRIVATELEADERBOARD   = Playtomic_Encode.MD5("leaderboards-loadprivateleaderboard-" + apikey);
     SAVEANDLIST = Playtomic_Encode.MD5("leaderboards-saveandlist-" + apikey);
     SAVE        = Playtomic_Encode.MD5("leaderboards-save-" + apikey);
     LIST        = Playtomic_Encode.MD5("leaderboards-list-" + apikey);
 }
Exemple #5
0
 internal static void Initialise(string apikey)
 {
     SECTION            = Playtomic_Encode.MD5("data-" + apikey);
     VIEWS              = Playtomic_Encode.MD5("data-views-" + apikey);
     PLAYS              = Playtomic_Encode.MD5("data-plays-" + apikey);
     PLAYTIME           = Playtomic_Encode.MD5("data-playtime-" + apikey);
     CUSTOMMETRIC       = Playtomic_Encode.MD5("data-custommetric-" + apikey);
     LEVELCOUNTERMETRIC = Playtomic_Encode.MD5("data-levelcountermetric-" + apikey);
     LEVELAVERAGEMETRIC = Playtomic_Encode.MD5("data-levelaveragemetric-" + apikey);
     LEVELRANGEDMETRIC  = Playtomic_Encode.MD5("data-levelrangedmetric-" + apikey);
 }
Exemple #6
0
    private static void GenerateKey(string name, string key, ref ArrayList arr)
    {
        var strarray = (string[])arr.ToArray(typeof(string));

        Array.Sort(strarray);

        var joined = "";

        foreach (var item in strarray)
        {
            joined += (joined == "" ? "" : "&") + item;
        }

        arr.Add(name + "=" + Playtomic_Encode.MD5(joined + key));
    }
    public IEnumerator Save(string table, Playtomic_PlayerScore score, bool highest, bool allowduplicates, bool facebook)
    {
        var postdata = new Dictionary <String, String>();

        postdata.Add("table", table);
        postdata.Add("highest", highest ? "y" : "n");
        postdata.Add("name", score.Name);
        postdata.Add("points", score.Points.ToString());
        postdata.Add("allowduplicates", allowduplicates ? "y" : "n");
        postdata.Add("auth", Playtomic_Encode.MD5(Playtomic.SourceUrl + score.Points));
        postdata.Add("customfields", score.CustomData.Count.ToString());
        postdata.Add("fbuserid", string.IsNullOrEmpty(score.FBUserId) ? "" : score.FBUserId);
        postdata.Add("fb", facebook ? "y" : "n");
        postdata.Add("url", Playtomic.SourceUrl);

        var n = 0;

        foreach (var key in score.CustomData.Keys)
        {
            postdata.Add("ckey" + n, key);
            postdata.Add("cdata" + n, score.CustomData[key]);
            n++;
        }

        string  url;
        WWWForm post;

        Playtomic_Request.Prepare(SECTION, SAVE, postdata, out url, out post);

        WWW www = new WWW(url, post);

        yield return(www);

        var response = Playtomic_Request.Process(www);

        SetResponse(response, "Save");
    }
    public IEnumerator SaveAndList(string table, Playtomic_PlayerScore score, bool highest, string mode, int perpage, bool isglobal, bool allowduplicates, bool facebook, Dictionary <String, String> customfilters)
    {
        var postdata = new Dictionary <String, String>();

        // common data
        postdata.Add("table", table);
        postdata.Add("highest", highest ? "y" : "n");
        postdata.Add("fb", facebook ? "y" : "n");

        // save data
        postdata.Add("name", score.Name);
        postdata.Add("points", score.Points.ToString());
        postdata.Add("allowduplicates", allowduplicates ? "y" : "n");
        postdata.Add("auth", Playtomic_Encode.MD5(Playtomic.SourceUrl + score.Points));
        postdata.Add("numfields", score.CustomData.Count.ToString());
        postdata.Add("fbuserid", string.IsNullOrEmpty(score.FBUserId) ? "" : score.FBUserId);
        postdata.Add("url", Playtomic.SourceUrl);

        var n = 0;

        foreach (var key in score.CustomData.Keys)
        {
            postdata.Add("ckey" + n, key);
            postdata.Add("cdata" + n, score.CustomData[key]);
            n++;
        }

        // list data
        var numfilters = customfilters == null ? 0 : customfilters.Count;

        postdata.Add("global", isglobal ? "y" : "n");
        postdata.Add("perpage", perpage.ToString());
        postdata.Add("mode", mode);
        postdata.Add("numfilters", numfilters.ToString());

        var fieldnumber = 0;

        if (numfilters > 0)
        {
            foreach (var key in customfilters.Keys)
            {
                postdata.Add("lkey" + fieldnumber, key);
                postdata.Add("ldata" + fieldnumber, customfilters[key]);
                fieldnumber++;
            }
        }

        string  url;
        WWWForm post;

        Playtomic_Request.Prepare(SECTION, SAVEANDLIST, postdata, out url, out post);

        WWW www = new WWW(url, post);

        yield return(www);

        var response = Playtomic_Request.Process(www);

        if (response.Success)
        {
            var data   = (Hashtable)response.JSON;
            var scores = (ArrayList)data["Scores"];
            var len    = scores.Count;

            response.NumItems = (int)(double)data["NumScores"];
            response.Scores   = new List <Playtomic_PlayerScore>();

            for (var i = 0; i < len; i++)
            {
                Hashtable item = (Hashtable)scores[i];

                var sscore = new Playtomic_PlayerScore();
                sscore.Name   = WWW.UnEscapeURL((string)item["Name"]);
                sscore.Points = (int)(double)item["Points"];
                sscore.SDate  = DateTime.Parse((string)item["SDate"]);
                sscore.RDate  = WWW.UnEscapeURL((string)item["RDate"]);
                sscore.Rank   = (long)(double)item["Rank"];

                if (item.ContainsKey("SubmittedOrBest"))
                {
                    sscore.SubmittedOrBest = item["SubmittedOrBest"].ToString() == "true";
                }

                if (item.ContainsKey("CustomData"))
                {
                    Hashtable customdata = (Hashtable)item["CustomData"];

                    foreach (var key in customdata.Keys)
                    {
                        sscore.CustomData.Add((string)key, WWW.UnEscapeURL((string)customdata[key]));
                    }
                }

                response.Scores.Add(sscore);
            }
        }

        SetResponse(response, "SaveAndList");
    }
Exemple #9
0
 internal static void Initialise(string apikey)
 {
     SECTION = Playtomic_Encode.MD5("gamevars-" + apikey);
     LOAD    = Playtomic_Encode.MD5("gamevars-load-" + apikey);
 }
 internal static void Initialise(string apikey)
 {
     SECTION = Playtomic_Encode.MD5("geoip-" + apikey);
     LOOKUP  = Playtomic_Encode.MD5("geoip-lookup-" + apikey);
 }