예제 #1
0
        public override IEnumerator LoadImageIntoTexture(string file)
        {
            string    url     = String.Concat(SpeedClickHelpers.GetImagesURL(), file);
            Texture2D texture = new Texture2D(1, 1, TextureFormat.ETC2_RGBA8, false);

            using (WWW www = new WWW(url))
            {
                yield return(www);

                www.LoadImageIntoTexture(texture);

                this.response = new ResponseData();
                if (!String.IsNullOrEmpty(www.error))
                {
                    this.response.Message = "Não foi possível acessar a imagem!";
                    yield break;
                }
                if (www.size <= 2)
                {
                    yield break;
                }
                else
                {
                    //SpeedClickHelpers.MakeTextureMultipleOfFour(texture);
                    this.response.DownloadedSprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                    this.response.Message          = "";
                    this.response.Success          = true;
                }
            }
        }
 public static Connection getConn(ConnectionType connType)
 {
     if (!SpeedClickHelpers.IsInternetConnectionAvailable())
     {
         return(conns[(int)ConnectionType.LocalConn]);
     }
     return(conns[(int)connType]);
 }
예제 #3
0
    public IEnumerator SendScore()
    {
        this.score.Platform = SpeedClickHelpers.ConvertPlatformType(Application.platform);
        this.Ranking.text   = "Submetendo pontuação...";
        yield return(StartCoroutine(server.SendScore(this.score))); // Wait for a response from server...

        this.PreencheRanking();
    }
    public static JSONObject ToJson(this Dictionary <string, object> d)
    {
        JSONObject obj = new JSONObject();

        foreach (KeyValuePair <string, object> pair in d)
        {
            obj.Add(pair.Key, SpeedClickHelpers.BuildJSONValue(pair.Value));
        }
        return(obj);
    }
예제 #5
0
 void LoadTarget()
 {
     this.ComboText.text = String.Format("x {0}", this.Combo);
     this.LeftTurnSecs   = this.scene.TurnLength; // Reset turn timer...
     if (this.TurnCount > 0)
     {
         this.Accuracy = (float)(this.TurnCount - this.MissCount) / this.TurnCount * 100f;
     }
     this.TurnCount++;
     this.TargetImage.sprite = SpeedClickHelpers.GetRandom <Sprite>(scene.TargetImages);
     this.CurrentTargetIndex = SpeedClickHelpers.LastRandomIndex;
     this.AccuracyText.text  = String.Format(Constants.ACCURACY_FORMAT, this.Accuracy);
     this.SpeedText.text     = String.Format(Constants.SPEED_FORMAT, this.Speed);
 }
예제 #6
0
        public override IEnumerator SendRequest(string controller, HttpMethodType t, Dictionary <string, object> p)
        {
            string url = String.Concat(SpeedClickHelpers.GetApiURL(), controller);
            WWW    www = null;

            if (p != null)
            {
                if (t == HttpMethodType.Post)
                {
                    WWWForm form = new WWWForm();
                    foreach (KeyValuePair <string, object> pair in p)
                    {
                        form.AddField(pair.Key, pair.Value.ToString());
                    }
                    www = new WWW(url, form);
                }
                else if (t == HttpMethodType.Get)
                {
                    url += "?";
                    url += SpeedClickHelpers.BuildURLParam(p);
                }
            }
            if (www == null)
            {
                www = new WWW(url);
            }
            yield return(www);

            this.response = new ResponseData();
            if (!String.IsNullOrEmpty(www.error))
            {
                this.response.Message = www.text;
                yield break;
            }
            if (www.size <= 2)
            {
                yield break;
            }
            else
            {
                JSONObject json = JSONObject.Parse(www.text);
                this.response.Data      = json.GetValue("Data");
                this.response.DataType  = this.response.Data.Type;
                this.response.DataArray = json.GetArray("Data");
                this.response.Message   = json.GetString("Message");
                this.response.Success   = json.GetBoolean("Success");
            }
            www.Dispose();
        }
예제 #7
0
        public JSONObject ToJson()
        {
            JSONObject obj = new JSONObject();
            Type       t   = this.GetType();

            FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (FieldInfo field in fields)
            {
                if (field.GetValue(this) != null)
                {
                    obj.Add(field.Name, SpeedClickHelpers.BuildJSONValue(field.GetValue(this)));
                }
            }
            return(obj);
        }