Beispiel #1
0
    public void onBtnJoin()
    {
        string club_id = id.value;
        int    cid     = 0;

        if (club_id == "" || !int.TryParse(club_id, out cid))
        {
            GameAlert.Show("请填写俱乐部ID");
            reset();
            return;
        }

        NetMgr nm = NetMgr.GetInstance();

        nm.request_apis("apply_join_club", "club_id", cid, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                GameAlert.Show(ret.errmsg);
                reset();
                return;
            }

            GameAlert.Show("已成功申请,请等待管理员审核", () => {
                gameObject.SetActive(false);
                id.value = "";
            });
        });
    }
Beispiel #2
0
        /// <summary>
        /// 回传物流信息到平台
        /// </summary>
        /// <param name="modifyTrackingDto"></param>
        public void ModifyTracking(ModifyTrackingDto modifyTrackingDto)
        {
            string url = "https://china-merchant.wish.com/api/v2/order/modify-tracking?access_token={0}&format=json&id={1}&tracking_provider={2}&origin_country_code={3}&tracking_number={4}";

            url = string.Format(url, access_token, modifyTrackingDto.OrderID, modifyTrackingDto.TrackingName, modifyTrackingDto.CountryCode, modifyTrackingDto.TrackingNumber);
            using (var client = new WebClient())
            {
                try
                {
                    var          response       = client.DownloadData(url);
                    var          responseString = Encoding.UTF8.GetString(response);
                    NormalReturn entity         = new NormalReturn();
                    entity = JsonConvert.DeserializeObject <NormalReturn>(responseString);
                    if (entity.code != 0 && entity.code != 1014)
                    {
                        throw new Exception(entity.message);
                    }
                }
                catch (System.Net.WebException ex)
                {
                    var          re     = new StreamReader(ex.Response.GetResponseStream());
                    string       str    = re.ReadToEnd();
                    NormalReturn entity = new NormalReturn();
                    entity = JsonConvert.DeserializeObject <NormalReturn>(str);
                    if (entity.code != 0 && entity.code != 1014)
                    {
                        throw new Exception(entity.message);
                    }
                }
            }
        }
Beispiel #3
0
    public static void kick(int uid, int roomid, string room_tag, Action <bool> cb)
    {
        NetMgr nm = NetMgr.GetInstance();

        JsonObject ob = new JsonObject();

        ob["uid"]      = uid;
        ob["roomid"]   = roomid;
        ob["room_tag"] = room_tag;

        nm.request_connector("kick", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("kick fail");
                if (cb != null)
                {
                    cb(false);
                }
                return;
            }

            if (cb != null)
            {
                cb(true);
            }
        });
    }
Beispiel #4
0
    public void onBtnOK()
    {
        int score = int.Parse(getInput(mEditor, "ip_score"));
        int limit = int.Parse(getInput(mEditor, "ip_limit"));

        if (limit < 0)
        {
            GameAlert.Show("活力值必须小于或者等于0");
            return;
        }

        limit = 0 - limit;

        JsonObject ob = new JsonObject();

        ob["club_id"] = mClubID;
        ob["user_id"] = mEditMember.id;
        ob["score"]   = score;
        ob["limit"]   = limit;

        NetMgr.GetInstance().request_apis("setup_club_member", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("setup_club_member fail");
                return;
            }

            mEditor.gameObject.SetActive(false);
            refresh();
        });
    }
Beispiel #5
0
    public static void destroy_club_room(int id, string room_tag, int club_id, Action <bool> cb)
    {
        NetMgr nm = NetMgr.GetInstance();

        JsonObject ob = new JsonObject();

        ob["roomid"]   = id;
        ob["room_tag"] = room_tag;
        ob["club_id"]  = club_id;

        nm.request_apis("destroy_club_room", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("destroy club room fail");
                if (cb != null)
                {
                    cb(false);
                }
                return;
            }

            if (cb != null)
            {
                cb(true);
            }
        });
    }
Beispiel #6
0
    public void onBtnSubmit()
    {
        string content = mContent.value;

        if (content == "")
        {
            GameAlert.Show("请填写反馈内容");
            return;
        }

        JsonObject ob = new JsonObject();

        ob["content"] = content;
        ob["qq"]      = "123";
        ob["phone"]   = "12345678901";

        NetMgr.GetInstance().request_apis("feedback", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                GameAlert.Show("提交失败, 请检查网络");
                return;
            }

            GameAlert.Show("感谢您的反馈,我们会尽快处理!", () => {
                back();
            });
        });
    }
Beispiel #7
0
    public void onBtnCreate()
    {
        string _name = name.value;
        string _desc = desc.value;
        string msg   = null;

        //int price = 300;

        if (_name == "")
        {
            msg = "俱乐部名字不能为空";
        }
        else if (_desc == "")
        {
            msg = "请填写俱乐部介绍";
        }
        //else if (GameMgr.GetInstance ().userMgr.gems < price)
        //	msg = "您的麻油不够";

        if (msg != null)
        {
            GameAlert.Show(msg);
            return;
        }

        //GameAlert.Show ("创建俱乐部将立即扣除" + price + "麻油,要继续吗?", () => {

        JsonObject ob = new JsonObject();

        ob ["name"] = _name;
        ob ["desc"] = _desc;

        if (pickPath != null)
        {
            byte[] bytes  = File.ReadAllBytes(pickPath);
            string base64 = Convert.ToBase64String(bytes);
            ob ["logo"] = base64;
        }

        NetMgr nm = NetMgr.GetInstance();

        nm.request_apis("create_club", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                GameAlert.Show(ret.errmsg);
                return;
            }

            GameMgr.GetInstance().get_coins();

            GameAlert.Show("俱乐部创建成功!", () => {
                reset();
                back();
            });
        });
        //}, true);
    }
Beispiel #8
0
    public void onBtnSave()
    {
        Transform body  = transform.Find("Body");
        string    _name = getInput(body, "name/input");
        string    _desc = getInput(body, "desc/input");

        string msg = null;

        if (_name == "")
        {
            msg = "俱乐部名字不能为空";
        }
        else if (_desc == "")
        {
            msg = "请填写俱乐部介绍";
        }

        if (msg != null)
        {
            GameAlert.Show(msg);
            return;
        }

        bool auto_start = body.Find("params/auto_start").GetComponent <UIToggle>().value;

        JsonObject ob = new JsonObject();

        ob["id"]         = mClubID;
        ob["name"]       = _name;
        ob["desc"]       = _desc;
        ob["auto_start"] = auto_start;

        if (pickPath != null)
        {
            byte[] bytes  = File.ReadAllBytes(pickPath);
            string base64 = Convert.ToBase64String(bytes);
            ob["logo"] = base64;
        }

        NetMgr nm = NetMgr.GetInstance();

        nm.request_apis("set_club", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("set_club fail: " + ret.errmsg);
                return;
            }

            GameAlert.Show("俱乐部设置成功!", () => {
                back();
            });
        });
    }
Beispiel #9
0
    void doExit(int club_id)
    {
        NetMgr.GetInstance().request_apis("leave_or_delete_club", "club_id", club_id, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("leave_or_delete_club fail");
                return;
            }

            back();
        });
    }
Beispiel #10
0
    void save(JsonObject ob)
    {
        NetMgr nm = NetMgr.GetInstance();

        nm.request_apis("set_club", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("set_club fail: " + ret.errmsg);
                return;
            }

            refresh();
        });
    }
Beispiel #11
0
    void enterClub(int clubid)
    {
        /* 通过俱乐部名片进入
         *      1) 检查是否俱乐部成员
         *      2) 如果是普通会员,进入hall界面
         *      3) 如果是管理员,进入admin界面
         *      4) 如果不是俱乐部成员,发送加入申请
         */

        NetMgr nm = NetMgr.GetInstance();

        nm.request_apis("get_club_role", "club_id", clubid, data => {
            GetClubRole ret = JsonUtility.FromJson <GetClubRole> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("get_club_role fail: " + ret.errcode);
                return;
            }

            string role = ret.data.role;
            if (role == "member")
            {
                GameObject hall = GameObject.Find("PHall");
                hall.GetComponent <Hall>().enter(clubid);
            }
            else if (role == "admin")
            {
                GameObject admin = GameObject.Find("PAdmin");
                admin.GetComponent <Admin>().enter(clubid);
            }
            else if (role == "outsider")
            {
                nm.request_apis("apply_join_club", "club_id", clubid, data2 => {
                    NormalReturn ret2 = JsonUtility.FromJson <NormalReturn>(data2.ToString());
                    if (ret2.errcode != 0)
                    {
                        Debug.Log("apply_join_club fail: " + ret2.errcode);
                        return;
                    }

                    GameAlert.Show("已成功申请加入俱乐部" + clubid + ",请等待管理员审核");
                });
            }
        });
    }
Beispiel #12
0
    void createClubRoom(JsonObject conf)
    {
        NetMgr nm = NetMgr.GetInstance();

        JsonObject ob = new JsonObject();

        ob ["conf"] = conf;

        nm.request_connector("create_private_room", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                GameAlert.Show(ret.errmsg);
                return;
            }

            back();
        });
    }
Beispiel #13
0
    public void onBtnDel()
    {
        JsonObject ob = new JsonObject();

        ob["club_id"] = mClubID;
        ob["user_id"] = mEditMember.id;

        NetMgr.GetInstance().request_apis("leave_club", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("leave_club fail");
                return;
            }

            mEditor.gameObject.SetActive(false);
            refresh();
        });
    }
Beispiel #14
0
    void Sign(int id, string result)
    {
        JsonObject ob = new JsonObject();

        ob["id"]    = id;
        ob["sign"]  = result;
        ob["score"] = 0;
        ob["limit"] = 0;

        NetMgr.GetInstance().request_apis("sign_club_message", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("sign_club_message fail");
                return;
            }

            refresh();
        });
    }
Beispiel #15
0
    void onBtnKick(int uid, int roomid, string room_tag)
    {
        NetMgr nm = NetMgr.GetInstance();

        JsonObject ob = new JsonObject();

        ob["uid"]      = uid;
        ob["roomid"]   = roomid;
        ob["room_tag"] = room_tag;

        nm.request_connector("kick", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("kick fail");
                return;
            }

            refresh();
        });
    }
Beispiel #16
0
    public static void stop_room(string room_tag, Action <bool> cb)
    {
        NetMgr nm = NetMgr.GetInstance();

        nm.request_connector("stop_room", "room_tag", room_tag, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("start room fail");
                if (cb != null)
                {
                    cb(false);
                }
                return;
            }

            if (cb != null)
            {
                cb(true);
            }
        });
    }
Beispiel #17
0
    public void onBtnAdmin()
    {
        bool admin = !mEditMember.admin;

        JsonObject ob = new JsonObject();

        ob["club_id"] = mClubID;
        ob["user_id"] = mEditMember.id;
        ob["admin"]   = admin;

        NetMgr.GetInstance().request_apis("prompt_club_member", ob, data => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("prompt_club_member fail");
                return;
            }

            mEditor.gameObject.SetActive(false);
            refresh();

            GameAlert.Show((admin ? "已设置" : "已取消") + mEditMember.name + "管理员权限");
        });
    }
Beispiel #18
0
    void onBtnEdit()
    {
        int gamenum = 0;

        int[] gamenums = { 4, 8, 16 };

        for (int i = 0; i < uGameNum.Count; i++)
        {
            if (uGameNum [i].value)
            {
                gamenum = gamenums [i];
                break;
            }
        }

        int playernum = 4;

        int[] playernums = { 4, 2, 3 };

        for (int i = 0; i < uPlayerNum.Count; i++)
        {
            if (uPlayerNum [i].value)
            {
                playernum = playernums [i];
                break;
            }
        }

        int maxfan = 0;

        int[] maxfans = { 2, 3, 4, 100 };
        for (int i = 0; i < uLimits.Count; i++)
        {
            if (uLimits [i].value)
            {
                maxfan = maxfans[i];
                break;
            }
        }

        bool maima     = uMaima.value;
        bool allpairs  = uAllPairs.value;
        bool limit_ip  = uIP.value;
        bool limit_gps = uLocation.value;

        JsonObject conf = new JsonObject();

        conf.Add("type", "shmj");
        conf.Add("gamenum", gamenum);
        conf.Add("maxfan", maxfan);
        conf.Add("huafen", flowers);
        conf.Add("playernum", 4);
        conf.Add("maima", maima);
        conf.Add("qidui", allpairs);
        conf.Add("limit_ip", limit_ip);
        conf.Add("limit_gps", limit_gps);

        JsonObject ob = new JsonObject();

        ob["roomid"]  = mRoom.room_tag;
        ob["club_id"] = mRoom.club_id;
        ob["conf"]    = conf;

        NetMgr nm = NetMgr.GetInstance();

        nm.request_connector("edit_room", ob, (data) => {
            NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
            if (ret.errcode != 0)
            {
                Debug.Log("edit room fail");
                return;
            }

            back();
        });
    }
Beispiel #19
0
    void showRooms()
    {
        int    cnt = mRooms.Count;
        NetMgr nm  = NetMgr.GetInstance();
        int    uid = GameMgr.getUserMgr().userid;

        for (int i = 0; i < mRooms.Count; i++)
        {
            ClubRoomInfo room  = mRooms [i];
            Transform    item  = getItem(i);
            Transform    seats = item.Find("seats");
            bool         found = false;

            int readys   = 0;
            int nplayers = 0;

            bool idle = room.status == "idle";

            int j = 0;

            for (; j < room.players.Count && j < seats.childCount; j++)
            {
                ClubRoomPlayer p        = room.players [j];
                Transform      s        = seats.GetChild(j);
                GameObject     name     = s.Find("name").gameObject;
                GameObject     ready    = s.Find("ready").gameObject;
                GameObject     id       = s.Find("id").gameObject;
                GameObject     icon     = s.Find("icon").gameObject;
                GameObject     btn_kick = s.Find("btn_kick").gameObject;

                bool empty = p.id == 0;

                s.gameObject.SetActive(true);

                setActive(s, "icon", !empty);
                setActive(s, "name", !empty);
                setActive(s, "id", !empty);
                setActive(s, "ready", !empty && p.ready);
                setActive(s, "btn_kick", !empty && idle);

                if (!empty && idle)
                {
                    setBtnEvent(s, "btn_kick", () => {
                        onBtnKick(p.id, room.id, room.room_tag);
                    });
                }

                if (empty)
                {
                    continue;
                }

                nplayers += 1;
                if (p.ready)
                {
                    readys += 1;
                }

                setText(s, "name", p.name);
                setText(s, "id", "" + p.id);
                setIcon(s, "icon", p.id);

                if (p.id == uid)
                {
                    mRoomID = room.id;
                }
            }

            for (int k = j; k < seats.childCount; k++)
            {
                Transform s = seats.GetChild(k);
                s.gameObject.SetActive(false);
            }

            ClubRoomBaseInfo info = room.base_info;
            setText(item, "desc", info.huafen + "/" + info.huafen + (info.maima ? "带苍蝇" : "不带苍蝇") + info.maxGames + "局");
            setText(item, "progress", room.num_of_turns + " / " + info.maxGames);
            setText(item, "roomid", "ID:" + room.id);
            setText(item, "status", idle ? "开始" : "游戏中");

            Transform btn_play = item.Find("btn_play");
            btn_play.GetComponent <SpriteMgr> ().setIndex(idle ? 0 : 1);
            PUtils.onClick(btn_play, () => {
                if (room.status == "idle")
                {
                    if (readys != info.numOfSeats)
                    {
                        GameAlert.Show("玩家没有全部准备");
                        return;
                    }

                    nm.request_connector("start_room", "room_tag", room.room_tag, data => {
                        NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
                        if (ret.errcode != 0)
                        {
                            Debug.Log("start room fail");
                            return;
                        }

                        refresh();
                    });
                }
                else
                {
                    nm.request_connector("stop_room", "room_tag", room.room_tag, data => {
                        NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
                        if (ret.errcode != 0)
                        {
                            Debug.Log("stop room fail");
                            return;
                        }

                        refresh();
                    });
                }
            });

            setActive(item, "btn_edit", idle && nplayers == 0);
            setBtnEvent(item, "btn_edit", () => {
                EditRoom er = getPage <EditRoom>("PEditRoom");

                er.UpdateEvents += refresh;
                er.enter(room);
            });

            setActive(item, "btn_destroy", idle && nplayers == 0);
            setBtnEvent(item, "btn_destroy", () => {
                GameAlert.Show("确定解散房间吗?", () => {
                    JsonObject ob  = new JsonObject();
                    ob["roomid"]   = room.id;
                    ob["room_tag"] = room.room_tag;
                    ob["club_id"]  = room.club_id;

                    nm.request_apis("destroy_club_room", ob, data => {
                        NormalReturn ret = JsonUtility.FromJson <NormalReturn> (data.ToString());
                        if (ret.errcode != 0)
                        {
                            Debug.Log("destroy club room fail");
                            return;
                        }

                        refresh();
                    });
                }, true);
            });
        }

        updateItems(mRooms.Count);
    }