Example #1
0
    // Use this for initialization

    void OnClick()
    {
        UIInput     inputfield = GameObject.Find("Input").GetComponentInChildren <UIInput> ();
        string      str        = inputfield.value;
        ParseObject RESPONSE   = new ParseObject("RESPONSE");

        RESPONSE ["R_Content"] = inputfield.value;
        RESPONSE ["Post_Id"]   = Post_Id;
        RESPONSE ["User"]      = ParseUser.CurrentUser.Username;
        RESPONSE ["Like"]      = initialamount;
        RESPONSE ["DisLike"]   = initialamount;

        RESPONSE.SaveAsync().ContinueWith(t =>
        {
            Loom.QueueOnMainThread(() => {
                Res_ID = RESPONSE.ObjectId;
                Debug.Log("res:" + RESPONSE.ObjectId);
                UIScrollView scrollview = GameObject.Find("Scroll View_Res").GetComponent <UIScrollView> ();
                GameObject [] items     = GameObject.FindGameObjectsWithTag("PandR");
                GameObject o            = (GameObject)Instantiate(Resources.Load("Response"));
                //为每个预设设置一个独一无二的名称
                o.name = "Response" + items.Length;

                o.transform.parent = GameObject.Find("Scroll View_Res").transform;

                UILabel label_R = o.GetComponentInChildren <UILabel> ();
                label_R.text    = str;

                AddLike_R Like_R   = o.GetComponentInChildren <AddLike_R> ();
                Like_R.Response_Id = Res_ID;

                AddDislike_R DisLike_R = o.GetComponentInChildren <AddDislike_R>();
                DisLike_R.Response_Id  = Res_ID;

                GetPoster Poster   = o.GetComponentInChildren <GetPoster>();
                Poster.UserAccount = ParseUser.CurrentUser.Username;

                Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                userphoto.UserAccount  = ParseUser.CurrentUser.Username;

                //下面这段代码是因为创建预设时 会自动修改旋转缩放的系数,
                int i           = items.Length - 1;
                Vector3 temp    = new Vector3(0, -0.29f * i, 0);
                GameObject item = GameObject.Find(o.name);
                item.transform.localPosition = new Vector3(0, 140, 0);
                item.transform.localScale    = new Vector3(1, 1, 1);
                //列表添加后用于刷新listView
                item.transform.position += temp;

                scrollview.ResetPosition();
            });
        });

        inputfield.value = "";
    }
Example #2
0
    void OnClick()
    {
        lbl = GetComponentInChildren <UILabel>();
        string tag = lbl.text;

        Debug.Log(tag);
        scrollview = GameObject.Find("search_view 1").GetComponent <UIScrollView>();

        GameObject [] items = GameObject.FindGameObjectsWithTag("Player");
        for (var i = 0; i < items.Length; i++)
        {
            Destroy(items [i]);
        }

        scrollview.ResetPosition();

        Loom.RunAsync(() => {
            ArrayList post_Id = new ArrayList();


            var query = ParseObject.GetQuery("POST").WhereEqualTo("Tag1", tag);
            query.FindAsync().ContinueWith(t =>
            {
                IEnumerable <ParseObject> results = t.Result;
                foreach (var objs in results)
                {
                    string id = objs.ObjectId;
                    Debug.Log("資料庫TAG:" + id);
                    post_Id.Add(id);
                }

                var queryT = ParseObject.GetQuery("POST").WhereEqualTo("Tag2", tag);

                queryT.FindAsync().ContinueWith(t2 =>
                {
                    IEnumerable <ParseObject> result2 = t2.Result;

                    foreach (var obj in result2)
                    {
                        string id2 = obj.ObjectId;



                        post_Id.Add(id2);
                    }

                    var queryY = ParseObject.GetQuery("POST").WhereEqualTo("Tag3", tag);

                    queryT.FindAsync().ContinueWith(t4 =>
                    {
                        IEnumerable <ParseObject> result4 = t4.Result;

                        foreach (var ob in result2)
                        {
                            string id3 = ob.ObjectId;



                            post_Id.Add(id3);
                        }

                        for (int ii = 0; ii < post_Id.Count; ii++)
                        {
                            for (int jj = ii + 1; jj < post_Id.Count; jj++)
                            {
                                if (post_Id[ii].Equals(post_Id[jj]))
                                {
                                    Debug.Log("del" + post_Id[jj]);
                                    post_Id.RemoveAt(jj);
                                    jj--;
                                    //由于刚刚删除了一个,所以jj要后退一个
                                }
                            }
                        }


                        ArrayList label_time = new ArrayList();
                        ArrayList label_list = new ArrayList();
                        ArrayList post_id    = new ArrayList();
                        ArrayList photo_e    = new ArrayList();
                        ArrayList user       = new ArrayList();
                        ArrayList posttype   = new ArrayList();
                        ArrayList placein    = new ArrayList();
                        var arraypostid      = (String[])post_Id.ToArray(typeof(string));

                        var queryC = ParseObject.GetQuery("POST").WhereContainedIn("objectId", arraypostid);

                        var queryTask = queryC.FindAsync();


                        IEnumerable <ParseObject> post = queryTask.Result;
                        foreach (var obj1 in post)
                        {
                            string id          = obj1.ObjectId;
                            string text1       = obj1["postfield"].ToString();
                            string post_type   = obj1["foo"].ToString();
                            string usr         = obj1["User"].ToString();
                            string place       = obj1["Location"].ToString();
                            DateTime?updatedAt = obj1.CreatedAt;



                            var imagefile = obj1.Get <ParseFile> ("file");
                            if (imagefile.Name.Contains("none"))
                            {
                                Debug.Log("none");
                                photo_e.Add("0");
                            }
                            else
                            {
                                Debug.Log("have");
                                photo_e.Add("1");
                            }

                            string time = updatedAt.ToString();
                            label_time.Add(time);
                            post_Id.Add(id);
                            label_list.Add(text1);
                            user.Add(usr);
                            posttype.Add(post_type);
                            placein.Add(place);
                            //Debug.Log (updatedAt);
                        }
                        String[] label_text = (String[])label_list.ToArray(typeof(string));
                        String[] labeltime  = (String[])label_time.ToArray(typeof(string));
                        String[] postId     = (String[])post_Id.ToArray(typeof(string));
                        String[] photo      = (String[])photo_e.ToArray(typeof(string));
                        String[] userId     = (String[])user.ToArray(typeof(string));
                        String[] Posttype   = (String[])posttype.ToArray(typeof(string));
                        String[] place_in   = (String[])placein.ToArray(typeof(string));
                        Loom.QueueOnMainThread(() => {
                            for (i = 0; i < photo.Length; i++)
                            {
                                string type = Posttype[i];
                                string big  = "big_" + type;
                                Debug.Log(big);
                                if (place_in[i] != null)
                                {
                                    if (place_in[i] == "Kaohsiung")
                                    {
                                        place_in[i] = "高雄文";
                                    }
                                    else if (place_in[i] == "Taichung")
                                    {
                                        place_in[i] = "臺中文";
                                    }
                                    else if (place_in[i] == "Taipei")
                                    {
                                        place_in[i] = "臺北文";
                                    }
                                    else if (place_in[i] == "NewTaipei")
                                    {
                                        place_in[i] = "新北文";
                                    }
                                    else if (place_in[i] == "Tainan")
                                    {
                                        place_in[i] = "臺南文";
                                    }
                                    else if (place_in[i] == "Taoyuan")
                                    {
                                        place_in[i] = "桃園文";
                                    }
                                }

                                if (photo[i] == "1")
                                {
                                    GameObject o = (GameObject)Instantiate(Resources.Load(big));
                                    //为每个预设设置一个独一无二的名称
                                    o.name = "all" + count;

                                    //将新预设放在Panel对象下面
                                    o.transform.parent = GameObject.Find("search_view 1").transform;

                                    UILabel post_text = GameObject.Find("search_view 1/" + o.name + "/PostContent").GetComponent <UILabel>();

                                    //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>();

                                    test1 postid   = GameObject.Find("search_view 1/" + o.name + "/photo").GetComponent <test1>();
                                    postid.postid  = postId[i];
                                    post_text.text = label_text[i];


                                    UILabel postplace = GameObject.Find("search_view 1/" + o.name + "/post_place").GetComponent <UILabel>();
                                    postplace.text    = place_in[i];

                                    AddLike Like = o.GetComponentInChildren <AddLike> ();
                                    Like.Post_Id = postId[i];

                                    AddDislike DisLike = o.GetComponentInChildren <AddDislike>();
                                    DisLike.Post_Id    = postId[i];

                                    RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>();
                                    Tags.Post_Id      = postId[i];

                                    PostIdSender Sender = o.GetComponentInChildren <PostIdSender>();
                                    Sender.Post_Id      = postId[i];

                                    ParameterSender PSender = o.GetComponentInChildren <ParameterSender>();
                                    PSender.Post_Id         = postId[i];

                                    GetPoster poster   = o.GetComponentInChildren <GetPoster>();
                                    poster.UserAccount = userId[i];

                                    Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                                    userphoto.UserAccount  = userId[i];
                                    if (i > 0)
                                    {
                                        if (photo[i - 1] == "0")
                                        {
                                            Vector3 temp    = new Vector3(0, -0.6f, 0);
                                            GameObject item = GameObject.Find(o.name);
                                            int ex_position = count - 1;
                                            //o.name="Q_list"+ex_position;
                                            GameObject ex_item = GameObject.Find("all" + ex_position);
                                            Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);

                                            item.transform.localPosition = new Vector3(0, 0, 0);
                                            item.transform.localScale    = new Vector3(1, 1, 1);
                                            //列表添加后用于刷新listView
                                            item.transform.position = ex_item.transform.position + temp;
                                            //item.transform.position += temp;
                                            //	Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                            scrollview.ResetPosition();
                                            count++;
                                        }
                                        else
                                        {
                                            Vector3 temp    = new Vector3(0, -1.3f, 0);
                                            GameObject item = GameObject.Find(o.name);
                                            int ex_position = count - 1;

                                            GameObject ex_item = GameObject.Find("all" + ex_position);
                                            Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);

                                            item.transform.localPosition = new Vector3(0, 0, 0);
                                            item.transform.localScale    = new Vector3(1, 1, 1);
                                            //列表添加后用于刷新listView
                                            item.transform.position = ex_item.transform.position + temp;
                                            //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                            scrollview.ResetPosition();
                                            count++;
                                        }
                                    }
                                    else if (i == 0)
                                    {
                                        Vector3 temp    = new Vector3(0, 0, 0);
                                        GameObject item = GameObject.Find(o.name);

                                        item.transform.localPosition = new Vector3(0, 0, 0);
                                        item.transform.localScale    = new Vector3(1, 1, 1);
                                        //列表添加后用于刷新listView
                                        //item.transform.position += temp;

                                        scrollview.ResetPosition();
                                        count++;
                                    }
                                }
                                else
                                {
                                    GameObject o = (GameObject)Instantiate(Resources.Load(type));
                                    //为每个预设设置一个独一无二的名称
                                    o.name = "all" + count;

                                    //将新预设放在Panel对象下面
                                    o.transform.parent = GameObject.Find("search_view 1").transform;

                                    UILabel post_text = GameObject.Find("search_view 1/" + o.name + "/PostContent").GetComponent <UILabel>();
                                    UILabel postplace = GameObject.Find("search_view 1/" + o.name + "/post_place").GetComponent <UILabel>();
                                    postplace.text    = place_in[i];

                                    //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>();

                                    //test1 postid = GameObject.Find("list View/"+o.name+"/photo").GetComponent<test1>();
                                    //postid.postid =postId[i];
                                    post_text.text = label_text[i];

                                    AddLike Like = o.GetComponentInChildren <AddLike> ();
                                    Like.Post_Id = postId[i];

                                    AddDislike DisLike = o.GetComponentInChildren <AddDislike>();
                                    DisLike.Post_Id    = postId[i];

                                    RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>();
                                    Tags.Post_Id      = postId[i];

                                    PostIdSender Sender = o.GetComponentInChildren <PostIdSender>();
                                    Sender.Post_Id      = postId[i];

                                    ParameterSender PSender = o.GetComponentInChildren <ParameterSender>();
                                    PSender.Post_Id         = postId[i];

                                    GetPoster poster   = o.GetComponentInChildren <GetPoster>();
                                    poster.UserAccount = userId[i];

                                    Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                                    userphoto.UserAccount  = userId[i];
                                    if (i > 0)
                                    {
                                        if (photo[i - 1] == "0")
                                        {
                                            Vector3 temp    = new Vector3(0, -0.57f, 0);
                                            GameObject item = GameObject.Find(o.name);


                                            int ex_position = count - 1;
                                            //o.name="Q_list"+ex_position;
                                            GameObject ex_item = GameObject.Find("all" + ex_position);
                                            Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);
                                            item.transform.localPosition = new Vector3(0, 0, 0);
                                            item.transform.localScale    = new Vector3(1, 1, 1);
                                            //列表添加后用于刷新listView
                                            item.transform.position = ex_item.transform.position + temp;

                                            scrollview.ResetPosition();
                                            //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                            count++;
                                        }
                                        else
                                        {
                                            Vector3 temp    = new Vector3(0, -1.3f, 0);
                                            GameObject item = GameObject.Find(o.name);

                                            int ex_position = count - 1;
                                            //o.name="Q_list"+ex_position;
                                            GameObject ex_item = GameObject.Find("all" + ex_position);
                                            Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);

                                            item.transform.localPosition = new Vector3(0, 0, 0);
                                            item.transform.localScale    = new Vector3(1, 1, 1);
                                            //列表添加后用于刷新listView
                                            item.transform.position = ex_item.transform.position + temp;

                                            scrollview.ResetPosition();
                                            //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                            count++;
                                        }
                                    }
                                    else if (i == 0)
                                    {
                                        Vector3 temp    = new Vector3(0, 0, 0);
                                        GameObject item = GameObject.Find(o.name);
                                        item.transform.localPosition = new Vector3(0, 0, 0);
                                        item.transform.localScale    = new Vector3(1, 1, 1);
                                        //列表添加后用于刷新listView
                                        item.transform.position += temp;
                                        //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                        scrollview.ResetPosition();
                                        count++;
                                    }
                                }
                            }
                        });
                    });
                });
            });
        });
        //});
    }
Example #3
0
    // Update is called once per frame
    void OnClick()
    {
        if (city != null)
        {
            if (city == "Kaohsiung")
            {
                city_ch = "高雄文";
            }
            else if (city == "Taichung")
            {
                city_ch = "臺中文";
            }
            else if (city == "Taipei")
            {
                city_ch = "臺北文";
            }
            else if (city == "NewTaipei")
            {
                city_ch = "新北文";
            }
            else if (city == "Tainan")
            {
                city_ch = "臺南文";
            }
            else if (city == "Taoyuan")
            {
                city_ch = "桃園文";
            }
        }
        GameObject loca = GameObject.Find("place(Clone)");

        Destroy(loca);



        //通过标签名称找到多有对象,前提是给预设起一个tag,这里我叫它player
        GameObject [] items = GameObject.FindGameObjectsWithTag("Player");
        //当预设数量大于 0时

        //删除列表的item
        for (var i = 0; i < items.Length; i++)
        {
            Destroy(items[i]);
        }
        if (exist == "exist")
        {
            GameObject location = (GameObject)Instantiate(Resources.Load("place"));
            location.transform.parent        = GameObject.Find("location").transform;
            location.transform.localPosition = new Vector3(0, 0, 0);
            location.transform.localScale    = new Vector3(1, 1, 1);
            location.AddComponent <allpost_loca>();
            //xml_test geo = GameObject.Find("city_now").GetComponent<xml_test>();

            allpost_loca PostType1 = location.GetComponent <allpost_loca> ();
            PostType1.city = city;
        }

        scrollview.ResetPosition();


        Loom.RunAsync(() => {
            ArrayList label_time = new ArrayList();
            ArrayList label_list = new ArrayList();
            ArrayList post_Id    = new ArrayList();
            ArrayList photo_e    = new ArrayList();
            ArrayList user       = new ArrayList();
            ArrayList posttype   = new ArrayList();


            var query = ParseObject.GetQuery("POST").WhereEqualTo("Location", city).WhereDoesNotExist("Post_Geo").OrderByDescending("Sum");

            //query = query.Limit(limit);
            var queryTask = query.FindAsync();


            IEnumerable <ParseObject> post = queryTask.Result;
            foreach (var obj in post)
            {
                string id          = obj.ObjectId;
                string text        = obj ["postfield"].ToString();
                string post_type   = obj ["foo"].ToString();
                string usr         = obj["User"].ToString();
                DateTime?updatedAt = obj.CreatedAt;
                int sum            = obj.Get <int> ("Sum");

                Debug.Log("資料庫TAG:" + sum);
                var imagefile = obj.Get <ParseFile> ("file");
                if (imagefile.Name.Contains("none"))
                {
                    Debug.Log("none");
                    photo_e.Add("0");
                }
                else
                {
                    Debug.Log("have");
                    photo_e.Add("1");
                }

                string time = updatedAt.ToString();
                label_time.Add(time);
                post_Id.Add(id);
                label_list.Add(text);
                user.Add(usr);
                posttype.Add(post_type);
                //Debug.Log (updatedAt);
                Debug.Log("資料庫傳回:" + text);
            }
            String[] label_text = (String[])label_list.ToArray(typeof(string));
            String[] labeltime  = (String[])label_time.ToArray(typeof(string));
            String[] postId     = (String[])post_Id.ToArray(typeof(string));
            String[] photo      = (String[])photo_e.ToArray(typeof(string));
            String[] userId     = (String[])user.ToArray(typeof(string));
            String[] Posttype   = (String[])posttype.ToArray(typeof(string));

            Loom.QueueOnMainThread(() => {
                for (i = 0; i < photo.Length; i++)
                {
                    string type = Posttype[i];
                    string big  = "big_" + type;
                    Debug.Log(big);


                    if (photo[i] == "1")
                    {
                        GameObject o = (GameObject)Instantiate(Resources.Load(big));
                        //为每个预设设置一个独一无二的名称
                        o.name = "all" + count;

                        //将新预设放在Panel对象下面
                        o.transform.parent = GameObject.Find("list View").transform;

                        UILabel post_text = GameObject.Find("list View/" + o.name + "/PostContent").GetComponent <UILabel>();

                        //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>();

                        test1 postid   = GameObject.Find("list View/" + o.name + "/photo").GetComponent <test1>();
                        postid.postid  = postId[i];
                        post_text.text = label_text[i];


                        UILabel postplace = GameObject.Find("list View/" + o.name + "/post_place").GetComponent <UILabel>();
                        postplace.text    = city_ch;

                        AddLike Like = o.GetComponentInChildren <AddLike> ();
                        Like.Post_Id = postId[i];

                        AddDislike DisLike = o.GetComponentInChildren <AddDislike>();
                        DisLike.Post_Id    = postId[i];

                        RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>();
                        Tags.Post_Id      = postId[i];

                        PostIdSender Sender = o.GetComponentInChildren <PostIdSender>();
                        Sender.Post_Id      = postId[i];

                        ParameterSender PSender = o.GetComponentInChildren <ParameterSender>();
                        PSender.Post_Id         = postId[i];

                        GetPoster poster   = o.GetComponentInChildren <GetPoster>();
                        poster.UserAccount = userId[i];

                        Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                        userphoto.UserAccount  = userId[i];
                        if (i > 0)
                        {
                            if (photo[i - 1] == "0")
                            {
                                Vector3 temp    = new Vector3(0, -0.95f, 0);
                                GameObject item = GameObject.Find(o.name);
                                int ex_position = count - 1;
                                //o.name="Q_list"+ex_position;
                                GameObject ex_item = GameObject.Find("all" + ex_position);
                                Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);

                                item.transform.localPosition = new Vector3(0, 0, 0);
                                item.transform.localScale    = new Vector3(1, 1, 1);
                                //列表添加后用于刷新listView
                                item.transform.position = ex_item.transform.position + temp;
                                //item.transform.position += temp;
                                //	Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                scrollview.ResetPosition();
                                count++;
                            }
                            else
                            {
                                Vector3 temp    = new Vector3(0, -1.3f, 0);
                                GameObject item = GameObject.Find(o.name);
                                int ex_position = count - 1;

                                GameObject ex_item = GameObject.Find("all" + ex_position);
                                Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);

                                item.transform.localPosition = new Vector3(0, 0, 0);
                                item.transform.localScale    = new Vector3(1, 1, 1);
                                //列表添加后用于刷新listView
                                item.transform.position = ex_item.transform.position + temp;
                                //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                scrollview.ResetPosition();
                                count++;
                            }
                        }
                        else if (i == 0)
                        {
                            Vector3 temp    = new Vector3(0, 0, 0);
                            GameObject item = GameObject.Find(o.name);

                            item.transform.localPosition = new Vector3(0, 0, 0);
                            item.transform.localScale    = new Vector3(1, 1, 1);
                            //列表添加后用于刷新listView
                            //item.transform.position += temp;

                            scrollview.ResetPosition();
                            count++;
                        }
                    }
                    else
                    {
                        GameObject o = (GameObject)Instantiate(Resources.Load(type));
                        //为每个预设设置一个独一无二的名称
                        o.name = "all" + count;

                        //将新预设放在Panel对象下面
                        o.transform.parent = GameObject.Find("list View").transform;

                        UILabel post_text = GameObject.Find("list View/" + o.name + "/PostContent").GetComponent <UILabel>();
                        UILabel postplace = GameObject.Find("list View/" + o.name + "/post_place").GetComponent <UILabel>();
                        postplace.text    = city_ch;

                        //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>();

                        //test1 postid = GameObject.Find("list View/"+o.name+"/photo").GetComponent<test1>();
                        //postid.postid =postId[i];
                        post_text.text = label_text[i];

                        AddLike Like = o.GetComponentInChildren <AddLike> ();
                        Like.Post_Id = postId[i];

                        AddDislike DisLike = o.GetComponentInChildren <AddDislike>();
                        DisLike.Post_Id    = postId[i];

                        RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>();
                        Tags.Post_Id      = postId[i];

                        PostIdSender Sender = o.GetComponentInChildren <PostIdSender>();
                        Sender.Post_Id      = postId[i];

                        ParameterSender PSender = o.GetComponentInChildren <ParameterSender>();
                        PSender.Post_Id         = postId[i];

                        GetPoster poster   = o.GetComponentInChildren <GetPoster>();
                        poster.UserAccount = userId[i];

                        Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                        userphoto.UserAccount  = userId[i];
                        if (i > 0)
                        {
                            if (photo[i - 1] == "0")
                            {
                                Vector3 temp    = new Vector3(0, -0.57f, 0);
                                GameObject item = GameObject.Find(o.name);


                                int ex_position = count - 1;
                                //o.name="Q_list"+ex_position;
                                GameObject ex_item = GameObject.Find("all" + ex_position);
                                Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);
                                item.transform.localPosition = new Vector3(0, 0, 0);
                                item.transform.localScale    = new Vector3(1, 1, 1);
                                //列表添加后用于刷新listView
                                item.transform.position = ex_item.transform.position + temp;

                                scrollview.ResetPosition();
                                //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                count++;
                            }
                            else
                            {
                                Vector3 temp    = new Vector3(0, -0.95f, 0);
                                GameObject item = GameObject.Find(o.name);

                                int ex_position = count - 1;
                                //o.name="Q_list"+ex_position;
                                GameObject ex_item = GameObject.Find("all" + ex_position);
                                Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);

                                item.transform.localPosition = new Vector3(0, 0, 0);
                                item.transform.localScale    = new Vector3(1, 1, 1);
                                //列表添加后用于刷新listView
                                item.transform.position = ex_item.transform.position + temp;

                                scrollview.ResetPosition();
                                //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                count++;
                            }
                        }
                        else if (i == 0)
                        {
                            Vector3 temp    = new Vector3(0, 0, 0);
                            GameObject item = GameObject.Find(o.name);
                            item.transform.localPosition = new Vector3(0, 0, 0);
                            item.transform.localScale    = new Vector3(1, 1, 1);
                            //列表添加后用于刷新listView
                            item.transform.position += temp;
                            //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                            scrollview.ResetPosition();
                            count++;
                        }
                    }
                }
            });
        });
    }
Example #4
0
    void Run()
    {
        UIScrollView scrollview = GameObject.Find("Post_view").GetComponent <UIScrollView>();

        Loom.RunAsync(() => {
            ArrayList post_content = new ArrayList();
            ArrayList post_type    = new ArrayList();
            ArrayList postID       = new ArrayList();
            ArrayList user         = new ArrayList();
            var query = ParseObject.GetQuery("POST").WhereEqualTo("User", ParseUser.CurrentUser.Username).OrderByDescending("creatAt").Limit(5);

            query.FindAsync().ContinueWith(t =>
            {
                IEnumerable <ParseObject> result = t.Result;

                foreach (var ob in result)
                {
                    string id        = ob.ObjectId;
                    string post_text = ob ["postfield"].ToString();
                    string type      = ob ["foo"].ToString();
                    string usr       = ob["User"].ToString();
                    post_content.Add(post_text);
                    post_type.Add(type);
                    postID.Add(id);
                    user.Add(usr);
                }
                String[] postcontent = (String[])post_content.ToArray(typeof(string));
                String[] posttype    = (String[])post_type.ToArray(typeof(string));
                String[] postId      = (String[])postID.ToArray(typeof(string));
                String[] userId      = (String[])user.ToArray(typeof(string));
                Loom.QueueOnMainThread(() => {
                    for (int i = 0; i < posttype.Length; i++)
                    {
                        if (posttype [i] == "q")
                        {
                            GameObject o = (GameObject)Instantiate(Resources.Load("q"));
                            //为每个预设设置一个独一无二的名称
                            o.name = "q" + count;
                            //将新预设放在Panel对象下面
                            o.transform.parent = GameObject.Find("Post_view").transform;
                            GameObject res     = o.transform.FindChild("response").gameObject;
                            res.SetActive(false);
                            //得到文字对象
                            UILabel postplace = GameObject.Find("Post_view/" + o.name + "/post_place").GetComponent <UILabel>();
                            postplace.text    = city_ch;
                            UILabel label     = o.GetComponentInChildren <UILabel> ();
                            //修改文字内容
                            label.text = postcontent [i];

                            AddLike Like = o.GetComponentInChildren <AddLike> ();
                            Like.Post_Id = postId[i];

                            AddDislike DisLike = o.GetComponentInChildren <AddDislike>();
                            DisLike.Post_Id    = postId[i];

                            RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>();
                            Tags.Post_Id      = postId[i];

                            PostIdSender Sender = o.GetComponentInChildren <PostIdSender>();
                            Sender.Post_Id      = postId[i];

                            //ParameterSender PSender=o.GetComponentInChildren<ParameterSender>();
                            //PSender.Post_Id=postId[i];

                            GetPoster poster   = o.GetComponentInChildren <GetPoster>();
                            poster.UserAccount = userId[i];

                            Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                            userphoto.UserAccount  = userId[i];

                            Vector3 temp    = new Vector3(0, -0.46f * count, 0);
                            GameObject item = GameObject.Find(o.name);
                            item.transform.localPosition = new Vector3(0, 300, 0);
                            item.transform.localScale    = new Vector3(0.925f, 0.925f, 1);
                            //列表添加后用于刷新listView
                            item.transform.position += temp;

                            scrollview.ResetPosition();
                            count++;
                        }
                        else if (posttype [i] == "angel")
                        {
                            GameObject o = (GameObject)Instantiate(Resources.Load("angel"));
                            //为每个预设设置一个独一无二的名称
                            o.name = "angel" + count;
                            //将新预设放在Panel对象下面
                            o.transform.parent = GameObject.Find("Post_view").transform;

                            //得到文字对象
                            UILabel post_text = GameObject.Find("Post_view/" + o.name + "/PostContent").GetComponent <UILabel>();

                            //修改文字内容
                            post_text.text = postcontent [i];
                            GameObject res = o.transform.FindChild("response").gameObject;
                            res.SetActive(false);
                            UILabel postplace = GameObject.Find("Post_view/" + o.name + "/post_place").GetComponent <UILabel>();
                            postplace.text    = city_ch;
                            AddLike Like      = o.GetComponentInChildren <AddLike> ();
                            Like.Post_Id      = postId[i];

                            AddDislike DisLike = o.GetComponentInChildren <AddDislike>();
                            DisLike.Post_Id    = postId[i];

                            RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>();
                            Tags.Post_Id      = postId[i];

                            PostIdSender Sender = o.GetComponentInChildren <PostIdSender>();
                            Sender.Post_Id      = postId[i];

                            //ParameterSender PSender=o.GetComponentInChildren<ParameterSender>();
                            //PSender.Post_Id=postId[i];

                            Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                            userphoto.UserAccount  = userId[i];

                            GetPoster poster   = o.GetComponentInChildren <GetPoster>();
                            poster.UserAccount = userId[i];

                            Getuserphoto userphoto1 = o.GetComponentInChildren <Getuserphoto>();
                            userphoto1.UserAccount  = userId[i];

                            Vector3 temp    = new Vector3(0, -0.46f * count, 0);
                            GameObject item = GameObject.Find(o.name);
                            item.transform.localPosition = new Vector3(0, 300, 0);
                            item.transform.localScale    = new Vector3(0.925f, 0.925f, 1);
                            //列表添加后用于刷新listView
                            item.transform.position += temp;

                            scrollview.ResetPosition();
                            count++;
                        }
                        else if (posttype [i] == "devil")
                        {
                            GameObject o = (GameObject)Instantiate(Resources.Load("devil"));
                            //为每个预设设置一个独一无二的名称
                            o.name = "devil" + count;
                            //将新预设放在Panel对象下面
                            o.transform.parent = GameObject.Find("Post_view").transform;

                            //得到文字对象
                            UILabel label = o.GetComponentInChildren <UILabel> ();
                            //修改文字内容
                            label.text     = postcontent [i];
                            GameObject res = o.transform.FindChild("response").gameObject;
                            res.SetActive(false);
                            UILabel postplace = GameObject.Find("Post_view/" + o.name + "/post_place").GetComponent <UILabel>();
                            postplace.text    = city_ch;

                            AddLike Like = o.GetComponentInChildren <AddLike> ();
                            Like.Post_Id = postId[i];

                            AddDislike DisLike = o.GetComponentInChildren <AddDislike>();
                            DisLike.Post_Id    = postId[i];

                            RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>();
                            Tags.Post_Id      = postId[i];

                            PostIdSender Sender = o.GetComponentInChildren <PostIdSender>();
                            Sender.Post_Id      = postId[i];

                            //ParameterSender PSender=o.GetComponentInChildren<ParameterSender>();
                            //PSender.Post_Id=postId[i];

                            GetPoster poster   = o.GetComponentInChildren <GetPoster>();
                            poster.UserAccount = userId[i];

                            Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                            userphoto.UserAccount  = userId[i];

                            Vector3 temp    = new Vector3(0, -0.46f * count, 0);
                            GameObject item = GameObject.Find(o.name);
                            item.transform.localPosition = new Vector3(0, 300, 0);
                            item.transform.localScale    = new Vector3(0.925f, 0.925f, 1);
                            //列表添加后用于刷新listView
                            item.transform.position += temp;

                            scrollview.ResetPosition();
                            count++;
                        }
                        else
                        {
                            Debug.Log("error");
                        }
                    }
                });
            });
        });
    }
Example #5
0
    public void OnSubmit()
    {
        Debug.Log("2");
        // It's a good idea to strip out all symbols as we don't want user input to alter colors, add new lines, etc
        string text = NGUIText.StripSymbols(mInput.value);

        if (!string.IsNullOrEmpty(text))
        {
            GameObject [] items = GameObject.FindGameObjectsWithTag("Player");
            //当预设数量大于 0时

            //删除列表的item
            for (var i = 0; i < items.Length; i++)
            {
                Destroy(items [i]);
            }
            //刷新UI
            scrollview.ResetPosition();


            Debug.Log(text);
            Loom.RunAsync(() => {
                ArrayList label_time = new ArrayList();
                ArrayList label_list = new ArrayList();
                ArrayList post_Id    = new ArrayList();
                ArrayList photo_e    = new ArrayList();
                ArrayList user       = new ArrayList();
                ArrayList posttype   = new ArrayList();
                ArrayList placein    = new ArrayList();
                var query            = ParseObject.GetQuery("POST").WhereContains("postfield", text).OrderByDescending("createdAt");

                var queryTask = query.FindAsync();


                IEnumerable <ParseObject> post = queryTask.Result;
                foreach (var obj in post)
                {
                    string id          = obj.ObjectId;
                    string text1       = obj ["postfield"].ToString();
                    string post_type   = obj ["foo"].ToString();
                    string usr         = obj["User"].ToString();
                    string place       = obj["Location"].ToString();
                    DateTime?updatedAt = obj.CreatedAt;



                    var imagefile = obj.Get <ParseFile> ("file");
                    if (imagefile.Name.Contains("none"))
                    {
                        Debug.Log("none");
                        photo_e.Add("0");
                    }
                    else
                    {
                        Debug.Log("have");
                        photo_e.Add("1");
                    }

                    string time = updatedAt.ToString();
                    label_time.Add(time);
                    post_Id.Add(id);
                    label_list.Add(text1);
                    user.Add(usr);
                    posttype.Add(post_type);
                    placein.Add(place);
                    //Debug.Log (updatedAt);
                    Debug.Log("資料庫傳回:" + text);
                }

                String[] label_text = (String[])label_list.ToArray(typeof(string));
                String[] labeltime  = (String[])label_time.ToArray(typeof(string));
                String[] postId     = (String[])post_Id.ToArray(typeof(string));
                String[] photo      = (String[])photo_e.ToArray(typeof(string));
                String[] userId     = (String[])user.ToArray(typeof(string));
                String[] Posttype   = (String[])posttype.ToArray(typeof(string));
                String[] place_in   = (String[])placein.ToArray(typeof(string));
                Loom.QueueOnMainThread(() => {
                    for (i = 0; i < photo.Length; i++)
                    {
                        string type = Posttype[i];
                        string big  = "big_" + type;
                        Debug.Log(big);
                        if (place_in[i] != null)
                        {
                            if (place_in[i] == "Kaohsiung")
                            {
                                place_in[i] = "高雄文";
                            }
                            else if (place_in[i] == "Taichung")
                            {
                                place_in[i] = "臺中文";
                            }
                            else if (place_in[i] == "Taipei")
                            {
                                place_in[i] = "臺北文";
                            }
                            else if (place_in[i] == "NewTaipei")
                            {
                                place_in[i] = "新北文";
                            }
                            else if (place_in[i] == "Tainan")
                            {
                                place_in[i] = "臺南文";
                            }
                            else if (place_in[i] == "Taoyuan")
                            {
                                place_in[i] = "桃園文";
                            }
                        }

                        if (photo[i] == "1")
                        {
                            GameObject o = (GameObject)Instantiate(Resources.Load(big));
                            //为每个预设设置一个独一无二的名称
                            o.name = "all" + count;

                            //将新预设放在Panel对象下面
                            o.transform.parent = GameObject.Find("search_view").transform;

                            UILabel post_text = GameObject.Find("search_view/" + o.name + "/PostContent").GetComponent <UILabel>();

                            //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>();

                            test1 postid   = GameObject.Find("search_view/" + o.name + "/photo").GetComponent <test1>();
                            postid.postid  = postId[i];
                            post_text.text = label_text[i];


                            UILabel postplace = GameObject.Find("search_view/" + o.name + "/post_place").GetComponent <UILabel>();
                            postplace.text    = place_in[i];

                            AddLike Like = o.GetComponentInChildren <AddLike> ();
                            Like.Post_Id = postId[i];

                            AddDislike DisLike = o.GetComponentInChildren <AddDislike>();
                            DisLike.Post_Id    = postId[i];

                            RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>();
                            Tags.Post_Id      = postId[i];

                            PostIdSender Sender = o.GetComponentInChildren <PostIdSender>();
                            Sender.Post_Id      = postId[i];

                            ParameterSender PSender = o.GetComponentInChildren <ParameterSender>();
                            PSender.Post_Id         = postId[i];

                            GetPoster poster   = o.GetComponentInChildren <GetPoster>();
                            poster.UserAccount = userId[i];

                            Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                            userphoto.UserAccount  = userId[i];
                            if (i > 0)
                            {
                                if (photo[i - 1] == "0")
                                {
                                    Vector3 temp    = new Vector3(0, -0.6f, 0);
                                    GameObject item = GameObject.Find(o.name);
                                    int ex_position = count - 1;
                                    //o.name="Q_list"+ex_position;
                                    GameObject ex_item = GameObject.Find("all" + ex_position);
                                    Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);

                                    item.transform.localPosition = new Vector3(0, 0, 0);
                                    item.transform.localScale    = new Vector3(1, 1, 1);
                                    //列表添加后用于刷新listView
                                    item.transform.position = ex_item.transform.position + temp;
                                    //item.transform.position += temp;
                                    //	Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                    scrollview.ResetPosition();
                                    count++;
                                }
                                else
                                {
                                    Vector3 temp    = new Vector3(0, -1.3f, 0);
                                    GameObject item = GameObject.Find(o.name);
                                    int ex_position = count - 1;

                                    GameObject ex_item = GameObject.Find("all" + ex_position);
                                    Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);

                                    item.transform.localPosition = new Vector3(0, 0, 0);
                                    item.transform.localScale    = new Vector3(1, 1, 1);
                                    //列表添加后用于刷新listView
                                    item.transform.position = ex_item.transform.position + temp;
                                    //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                    scrollview.ResetPosition();
                                    count++;
                                }
                            }
                            else if (i == 0)
                            {
                                Vector3 temp    = new Vector3(0, 0, 0);
                                GameObject item = GameObject.Find(o.name);

                                item.transform.localPosition = new Vector3(0, 0, 0);
                                item.transform.localScale    = new Vector3(1, 1, 1);
                                //列表添加后用于刷新listView
                                //item.transform.position += temp;

                                scrollview.ResetPosition();
                                count++;
                            }
                        }
                        else
                        {
                            GameObject o = (GameObject)Instantiate(Resources.Load(type));
                            //为每个预设设置一个独一无二的名称
                            o.name = "all" + count;

                            //将新预设放在Panel对象下面
                            o.transform.parent = GameObject.Find("search_view").transform;

                            UILabel post_text = GameObject.Find("search_view/" + o.name + "/PostContent").GetComponent <UILabel>();
                            UILabel postplace = GameObject.Find("search_view/" + o.name + "/post_place").GetComponent <UILabel>();
                            postplace.text    = place_in[i];

                            //picture = GameObject.Find("list View/"+o.name+"/photo").GetComponent<UITexture>();

                            //test1 postid = GameObject.Find("list View/"+o.name+"/photo").GetComponent<test1>();
                            //postid.postid =postId[i];
                            post_text.text = label_text[i];

                            AddLike Like = o.GetComponentInChildren <AddLike> ();
                            Like.Post_Id = postId[i];

                            AddDislike DisLike = o.GetComponentInChildren <AddDislike>();
                            DisLike.Post_Id    = postId[i];

                            RetrieveTags Tags = o.GetComponentInChildren <RetrieveTags>();
                            Tags.Post_Id      = postId[i];

                            PostIdSender Sender = o.GetComponentInChildren <PostIdSender>();
                            Sender.Post_Id      = postId[i];

                            ParameterSender PSender = o.GetComponentInChildren <ParameterSender>();
                            PSender.Post_Id         = postId[i];

                            GetPoster poster   = o.GetComponentInChildren <GetPoster>();
                            poster.UserAccount = userId[i];

                            Getuserphoto userphoto = o.GetComponentInChildren <Getuserphoto>();
                            userphoto.UserAccount  = userId[i];
                            if (i > 0)
                            {
                                if (photo[i - 1] == "0")
                                {
                                    Vector3 temp    = new Vector3(0, -0.57f, 0);
                                    GameObject item = GameObject.Find(o.name);


                                    int ex_position = count - 1;
                                    //o.name="Q_list"+ex_position;
                                    GameObject ex_item = GameObject.Find("all" + ex_position);
                                    Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);
                                    item.transform.localPosition = new Vector3(0, 0, 0);
                                    item.transform.localScale    = new Vector3(1, 1, 1);
                                    //列表添加后用于刷新listView
                                    item.transform.position = ex_item.transform.position + temp;

                                    scrollview.ResetPosition();
                                    //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                    count++;
                                }
                                else
                                {
                                    Vector3 temp    = new Vector3(0, -1.3f, 0);
                                    GameObject item = GameObject.Find(o.name);

                                    int ex_position = count - 1;
                                    //o.name="Q_list"+ex_position;
                                    GameObject ex_item = GameObject.Find("all" + ex_position);
                                    Debug.Log(ex_item.transform.position.x + "," + ex_item.transform.position.y);

                                    item.transform.localPosition = new Vector3(0, 0, 0);
                                    item.transform.localScale    = new Vector3(1, 1, 1);
                                    //列表添加后用于刷新listView
                                    item.transform.position = ex_item.transform.position + temp;

                                    scrollview.ResetPosition();
                                    //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                    count++;
                                }
                            }
                            else if (i == 0)
                            {
                                Vector3 temp    = new Vector3(0, 0, 0);
                                GameObject item = GameObject.Find(o.name);
                                item.transform.localPosition = new Vector3(0, 0, 0);
                                item.transform.localScale    = new Vector3(1, 1, 1);
                                //列表添加后用于刷新listView
                                item.transform.position += temp;
                                //Debug.Log(item.transform.position.x+","+item.transform.position.y);
                                scrollview.ResetPosition();
                                count++;
                            }
                        }
                    }
                });
            });
            //});
            //mInput.value = "";
            mInput.isSelected = false;
        }
    }