Exemplo n.º 1
0
    IEnumerator Upload()
    {
        string  url  = StaticMembers.GetRootUrlWithSlash() + "joingroupbus.php";
        WWWForm form = new WWWForm();

        form.AddField("username", username);
        form.AddField("groupid", groupid);
        form.AddField("groupkey", groupkey);

        /*
         * Debug.Log(url);
         * Debug.Log(username);
         * Debug.Log(groupid);
         * Debug.Log(groupkey);
         */

        using (UnityWebRequest www = UnityWebRequest.Post(url, form))
        {
            www.timeout = 30;
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                text.text = www.error;
            }
            else
            {
                gotResult(www.downloadHandler.text);
            }
        }
    }
Exemplo n.º 2
0
    IEnumerator Upload()
    {
        string groupid = PlayerPrefs.GetString("group_id", null);
        string teamid  = i_teamid.text;
        string userid  = PlayerPrefs.GetString("user_id", null);

        string  url  = StaticMembers.GetRootUrlWithSlash() + "jointeam.php";
        WWWForm form = new WWWForm();

        form.AddField("groupid", groupid);
        form.AddField("teamid", teamid);
        form.AddField("userid", userid);

        using (UnityWebRequest www = UnityWebRequest.Post(url, form))
        {
            www.timeout = 30;
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                text.text = www.error;
            }
            else
            {
                gotResult(www.downloadHandler.text);
            }
        }
    }
Exemplo n.º 3
0
 private void Initialize()
 {
     InstanceMembers.Add("toString",
                         new NativeMethod <bool>((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new StringObject(t ? "true" : "false"));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     }));
     InstanceMembers.Add("equals",
                         new NativeMethod <bool>((t, args) =>
     {
         if (args.Count == 1)
         {
             var boo = args[0] as BooleanObject;
             return(new BooleanObject(boo != null && t == boo.Value));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     }));
     StaticMembers.Add("parse",
                       new NativeMethod((t, args) =>
     {
         if (args.Count == 1)
         {
             var str = args[0] as IStringObject;
             if (str != null)
             {
                 return(new BooleanObject(bool.Parse(str.Value)));
             }
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     }));
 }
Exemplo n.º 4
0
    IEnumerator Upload()
    {
        string  url  = StaticMembers.GetRootUrlWithSlash() + "updatepos.php";
        WWWForm form = new WWWForm();

        form.AddField("userid", userid);
        form.AddField("groupid", groupid);
        form.AddField("x", Player.transform.position.x.ToString());
        form.AddField("y", Player.transform.position.y.ToString());
        form.AddField("level", level);

        using (UnityWebRequest www = UnityWebRequest.Post(url, form))
        {
            www.timeout = 30;
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                //text.text = www.error;
                Debug.Log(www.error);
            }
            else
            {
                gotResult(www.downloadHandler.text);
            }
        }

        //yield return new WaitForSeconds(0.05f);
        UpdatePos();
    }
Exemplo n.º 5
0
    IEnumerator Upload()
    {
        string url = remote ? StaticMembers.GetUrlWithSlash() : inputfield.text + "/"; //This does not use the static method becouse it is used when the settings are not saved jet;

        url += "port/port/app/checkconn.php";
        WWWForm form = new WWWForm();

        form.AddField("test", "TahaYasinTest1");

        using (UnityWebRequest www = UnityWebRequest.Post(url, form))
        {
            www.timeout = 5;
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
                Result res = new Result();
                res.success = false;
                res.message = www.error;
                gotResult(JsonUtility.ToJson(res));
            }
            else
            {
                gotResult(www.downloadHandler.text);
            }
        }
    }
        public void StaticField()
        {
            var input = new StaticMembers();

            var result = Get(input, "StaticField");

            Assert.Null(result);
        }
        public void StaticProperty()
        {
            var input = new StaticMembers();

            var result = Get(input, "StaticProperty");

            Assert.Null(result);
        }
 /// <summary>
 /// Resets the IronPython engine scope, clears any imported modules and .NET types.
 /// </summary>
 public void Reset()
 {
     ScriptScope = _scriptEngine.CreateScope();
     _typeLoader.Reset();
     _autocompleter.Reset();
     InstanceMembers.Clear();
     StaticMembers.Clear();
     Instances.Clear();
     Statics.Clear();
     InstancesAndStaticsDirty = true;
     RunScript("import clr");
     RunScript("from System import Array");
 }
Exemplo n.º 9
0
    IEnumerator CheckGroup(string s_groupid)
    {
        string  url  = StaticMembers.GetRootUrlWithSlash() + "checkifgroupexcits.php";
        WWWForm form = new WWWForm();

        form.AddField("groupid", s_groupid);

        using (UnityWebRequest www = UnityWebRequest.Post(url, form))
        {
            www.timeout = 5;
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                text.text = www.error;
            }
            else
            {
                gotresultcheck(www.downloadHandler.text);
            }
        }
    }
Exemplo n.º 10
0
 private void Initialize()
 {
     InstanceMembers.Add("toString",
                         new NativeMethod <double>((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new StringObject(t.ToString()));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     }));
     InstanceMembers.Add("equals",
                         new NativeMethod <double>((t, args) =>
     {
         if (args.Count == 1)
         {
             var num = args[0] as INumberObject;
             return(new BooleanObject(num != null && t == num.Value));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     }));
     InstanceMembers.Add(ClassHelper.RenamePropertyGetter("isInfinity"), new PropertyGetter(
                             new NativeMethod <double>((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new BooleanObject(double.IsInfinity(t)));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     })));
     InstanceMembers.Add(ClassHelper.RenamePropertyGetter("isNaN"), new PropertyGetter(
                             new NativeMethod <double>((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new BooleanObject(double.IsNaN(t)));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     })));
     InstanceMembers.Add(ClassHelper.RenamePropertyGetter("isPosInf"), new PropertyGetter(
                             new NativeMethod <double>((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new BooleanObject(double.IsPositiveInfinity(t)));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     })));
     InstanceMembers.Add(ClassHelper.RenamePropertyGetter("isNegInf"), new PropertyGetter(
                             new NativeMethod <double>((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new BooleanObject(double.IsNegativeInfinity(t)));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     })));
     StaticMembers.Add(ClassHelper.RenamePropertyGetter("PosInf"), new PropertyGetter(
                           new NativeMethod((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new NumberObject(double.PositiveInfinity));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     })));
     StaticMembers.Add(ClassHelper.RenamePropertyGetter("NegInf"), new PropertyGetter(
                           new NativeMethod((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new NumberObject(double.NegativeInfinity));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     })));
     StaticMembers.Add(ClassHelper.RenamePropertyGetter("NaN"), new PropertyGetter(
                           new NativeMethod((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new NumberObject(double.NaN));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     })));
     StaticMembers.Add(ClassHelper.RenamePropertyGetter("MaxValue"), new PropertyGetter(
                           new NativeMethod((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new NumberObject(double.MaxValue));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     })));
     StaticMembers.Add(ClassHelper.RenamePropertyGetter("MinValue"), new PropertyGetter(
                           new NativeMethod((t, args) =>
     {
         if (args.Count == 0)
         {
             return(new NumberObject(double.MinValue));
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     })));
     StaticMembers.Add("parse",
                       new NativeMethod((t, args) =>
     {
         if (args.Count == 1)
         {
             var str = args[0] as IStringObject;
             if (str != null)
             {
                 return(new NumberObject(double.Parse(str.Value)));
             }
         }
         throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
     }));
 }
Exemplo n.º 11
0
        private void Initialize()
        {
            InstanceMembers.Add("toString",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 0)
                {
                    return(new StringObject(t.ToString()));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("equals",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 1)
                {
                    var num = args[0] as IStringObject;
                    return(new BooleanObject(num != null && t == num.Value));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add(ClassHelper.RenamePropertyGetter("length"), new PropertyGetter(
                                    new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 0)
                {
                    return(new NumberObject(t.Length));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            })));
            InstanceMembers.Add(ClassHelper.RenameIndexerGetter, new IndexerGetter(
                                    new NativeMethod <List <IScriptObject> >((t, args) =>
            {
                if (args.Count == 1)
                {
                    var idx = args[0] as INumberObject;
                    if (idx != null)
                    {
                        var dbl = idx.Value;
                        if (dbl >= 0 && dbl <= int.MaxValue)
                        {
                            var i = (int)dbl;
                            if (dbl == i)
                            {
                                return(t[i]);
                            }
                        }
                    }
                }
                throw new ArgumentOutOfRangeException(ExceptionResource.ArrayIndexMustBePosInteger, innerException: null);
            })));
            InstanceMembers.Add("contains",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 1)
                {
                    return(new BooleanObject(t.Contains(args[0].ToString())));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("endsWith",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 1)
                {
                    return(new BooleanObject(t.EndsWith(args[0].ToString())));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("indexOf",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 1)
                {
                    var s = args[0] as IStringObject;
                    if (s != null)
                    {
                        return(new NumberObject(t.IndexOf(s.Value)));
                    }
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("insert",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 2)
                {
                    var idx = args[0] as INumberObject;
                    if (idx != null)
                    {
                        var dbl = idx.Value;
                        if (dbl >= 0 && dbl <= int.MaxValue)
                        {
                            var i = (int)dbl;
                            if (dbl == i)
                            {
                                return(new StringObject(
                                           t.Insert(i, args[1].ToString())));
                            }
                        }
                    }
                    throw new ArgumentException();
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("replace",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 2)
                {
                    return(new StringObject(
                               t.Replace(args[0].ToString(), args[1].ToString())));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("split",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 1)
                {
                    return(new ArrayObject(
                               t.Split(args[0].ToString().ToCharArray())
                               .Cast <StringObject>()));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("startsWith",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 1)
                {
                    return(new BooleanObject(t.StartsWith(args[0].ToString())));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("substring",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 1)
                {
                    var idx = args[0] as INumberObject;
                    if (idx != null)
                    {
                        var dbl = idx.Value;
                        if (dbl >= 0 && dbl <= int.MaxValue)
                        {
                            var i = (int)dbl;
                            if (dbl == i)
                            {
                                return(new StringObject(
                                           t.Substring(i)));
                            }
                        }
                    }
                    throw new ArgumentException();
                }
                if (args.Count == 2)
                {
                    var idx0 = args[0] as INumberObject;
                    var idx1 = args[1] as INumberObject;
                    if (idx0 != null && idx1 != null)
                    {
                        var dbl0 = idx0.Value;
                        var dbl1 = idx1.Value;
                        if (dbl0 >= 0 && dbl0 <= int.MaxValue &&
                            dbl1 >= 0 && dbl1 <= int.MaxValue)
                        {
                            var i0 = (int)dbl0;
                            var i1 = (int)dbl1;
                            if (dbl0 == i0 && dbl1 == i1)
                            {
                                return(new StringObject(
                                           t.Substring(i0, i1)));
                            }
                        }
                    }
                    throw new ArgumentException();
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("toCharArray",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 0)
                {
                    return(new ArrayObject(
                               t.ToCharArray()
                               .Cast <StringObject>()));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("toLower",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 0)
                {
                    return(new StringObject(
                               t.ToLower()));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("toUpper",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 0)
                {
                    return(new StringObject(
                               t.ToUpper()));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("trim",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 0)
                {
                    return(new StringObject(
                               t.Trim()));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("trimStart",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 0)
                {
                    return(new StringObject(
                               t.TrimStart()));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("trimEnd",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 0)
                {
                    return(new StringObject(
                               t.TrimEnd()));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("padLeft",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 1)
                {
                    var idx = args[0] as INumberObject;
                    if (idx != null)
                    {
                        var dbl = idx.Value;
                        if (dbl >= 0 && dbl <= int.MaxValue)
                        {
                            var i = (int)dbl;
                            if (dbl == i)
                            {
                                return(new StringObject(
                                           t.PadLeft(i)));
                            }
                        }
                    }
                    throw new ArgumentException();
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            InstanceMembers.Add("padRight",
                                new NativeMethod <string>((t, args) =>
            {
                if (args.Count == 1)
                {
                    var idx = args[0] as INumberObject;
                    if (idx != null)
                    {
                        var dbl = idx.Value;
                        if (dbl >= 0 && dbl <= int.MaxValue)
                        {
                            var i = (int)dbl;
                            if (dbl == i)
                            {
                                return(new StringObject(
                                           t.PadRight(i)));
                            }
                        }
                    }
                    throw new ArgumentException();
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));

            StaticMembers.Add(ClassHelper.RenamePropertyGetter("empty"), new PropertyGetter(
                                  new NativeMethod((t, args) =>
            {
                if (args.Count == 0)
                {
                    return(new StringObject(string.Empty));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            })));
            StaticMembers.Add("compare",
                              new NativeMethod((t, args) =>
            {
                if (args.Count == 2)
                {
                    return(new NumberObject(
                               string.Compare(args[0].ToString(), args[1].ToString())));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
            StaticMembers.Add("concat",
                              new NativeMethod((t, args) =>
            {
                var sb = new StringBuilder();
                foreach (var arg in args)
                {
                    sb.Append(arg.ToString());
                }
                return(new StringObject(sb.ToString()));
            }));
            StaticMembers.Add("format",
                              new NativeMethod((t, args) =>
            {
                if (args.Count >= 1)
                {
                    var s = args[0];
                    args.RemoveAt(0);
                    var array = args.ToArray();
                    return(new StringObject(string.Format(s.ToString(), array)));
                }
                throw new ArgumentException(ExceptionResource.ParemetersNotMatch);
            }));
        }