Exemplo n.º 1
0
 private void GSConnection_OnMessageReceived(String message)
 {
     try{
         if (_gSPlatform.ApiSecret.Contains(":"))
         {
             message = Decrypt(message);
             if (SessionId != null)
             {
                 IDictionary <string, object> parsed = (IDictionary <string, object>)GSJson.From(message);
                 GSData secureResponse = new GSData(parsed);
                 string json           = secureResponse.GetString("json");
                 if (secureResponse.GetString("hmac").Equals(_gs.GSPlatform.MakeHmac(json, GS.GSPlatform.ApiSecret + "-" + SessionId)))
                 {
                     _gs.AddRequestedAction(() => {
                         _gs.OnMessageReceived(json, this);
                     });
                 }
                 else
                 {
                     if (_gs.TraceMessages)
                     {
                         _gSPlatform.DebugMsg("SOCKET-TAMPERED:" + secureResponse.JSON);
                     }
                 }
                 return;
             }
         }
         _gs.AddRequestedAction(() => {
             _gs.OnMessageReceived(message, this);
         });
     }catch {
         //on WP8 if the app goes out of score for some reason the gs is null, so ignore this
     }
 }
Exemplo n.º 2
0
    public void SetScroll(GameSparks.Core.GSData data, long time_now)
    {
        for (int i = 0; i < 4; i++)
        {
            string scroll_type_num = "scroll" + i + "_type";
            scroll_type_num = data.GetString(scroll_type_num);
            if (scroll_type_num == "r_null")
            {
                scroll_rarity[i] = rarity.r_null;
                scroll_go[i].SetActive(false);
            }
            else
            {
                if (scroll_type_num == "r_common")
                {
                    scroll_rarity[i] = rarity.r_common;
                }
                else if (scroll_type_num == "r_uncommon")
                {
                    scroll_rarity[i] = rarity.r_uncommon;
                }
                else if (scroll_type_num == "r_rare")
                {
                    scroll_rarity[i] = rarity.r_rare;
                }

                string scroll_finish = "scroll" + i + "_finish";
                string scroll_start  = "scroll" + i + "_start";

                long time_finish = (long)data.GetLong(scroll_finish);
                long time_start  = (long)data.GetLong(scroll_start);

                active_scroll_index = (int)data.GetInt("active_scroll");

                if (i == active_scroll_index)
                {
                    if (time_finish - time_now <= 0)
                    {
                        timer[i]          = 0;
                        timer_txt[i].text = "Ready";
                    }
                    else
                    {
                        timer[i] = (time_finish - time_now) / 1000;
                    }
                }
                else
                {
                    //if (time_finish != 0)
                    //{
                    //    if (time_finish - time_now <= 0)
                    //    {
                    //        timer[i] = 0;
                    //        timer_txt[i].text = "Ready";
                    //    }
                    //}
                    //else
                    //{
                    switch (scroll_rarity[i])
                    {
                    case rarity.r_common:
                        timer[i] = 3600 * 2;
                        break;

                    case rarity.r_uncommon:
                        timer[i] = 3600 * 6;
                        break;

                    case rarity.r_rare:
                        timer[i] = 3600 * 24;
                        break;
                    }
                    //}
                }

                scroll_go[i].SetActive(true);
            }
            Debug.Log("/n Rarity: " + scroll_type_num);
        }
    }