Esempio n. 1
0
        static int _g_get_icon(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                ClubRoomPlayer gen_to_be_invoked = (ClubRoomPlayer)translator.FastGetCSObj(L, 1);
                LuaAPI.lua_pushstring(L, gen_to_be_invoked.icon);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(1);
        }
Esempio n. 2
0
        static int _s_set_ready(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

                ClubRoomPlayer gen_to_be_invoked = (ClubRoomPlayer)translator.FastGetCSObj(L, 1);
                gen_to_be_invoked.ready = LuaAPI.lua_toboolean(L, 2);
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(0);
        }
Esempio n. 3
0
        static int __CreateInstance(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
                if (LuaAPI.lua_gettop(L) == 1)
                {
                    ClubRoomPlayer gen_ret = new ClubRoomPlayer();
                    translator.Push(L, gen_ret);

                    return(1);
                }
            }
            catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to ClubRoomPlayer constructor!"));
        }
Esempio n. 4
0
    void showDetail(ClubRoomInfo room)
    {
        mRoomID = room.id;

        Transform detail = transform.Find("detail");

        setActive(detail, null, true);

        Transform seats = detail.Find("seats");
        UIGrid    grid  = seats.GetComponent <UIGrid>();

        int nseats  = room.players.Count;
        int empties = 0;

        for (int i = 0; i < seats.childCount && i < nseats; i++)
        {
            ClubRoomPlayer p     = room.players [i];
            Transform      s     = seats.GetChild(i);
            bool           empty = p.id == 0;

            setActive(s, null, true);
            setActive(s, "name", !empty);
            setActive(s, "bghead/icon", !empty);

            setIcon(s, "bghead/icon", p.id);
            setText(s, "name", p.name);
            if (empty)
            {
                empties++;
            }
        }

        for (int i = nseats; i < seats.childCount; i++)
        {
            Transform s = seats.GetChild(i);
            setActive(s, null, false);
        }

        grid.Reposition();

        ClubRoomBaseInfo info  = room.base_info;
        Transform        rules = detail.Find("rules");

        setText(rules, "rule", "上海敲麻");
        setText(rules, "huafen", "" + info.huafen);
        setText(rules, "playernum", "" + info.numOfSeats);
        setText(rules, "gamenum", "" + info.maxGames);
        setText(rules, "maxfan", "" + info.maxFan);
        setText(rules, "maima", info.maima ? "是" : "否");
        setText(rules, "qidui", info.qidui ? "是" : "否");
        setText(rules, "limit_ip", "否");
        setText(rules, "limit_gps", "否");

        setBtnEvent(detail, "btn_join", () => {
            if (empties == 0)
            {
                GameAlert.Show("房间已满,请重新选择");
                return;
            }

            mShow = false;
            GameMgr.GetInstance().enterRoom(room.room_tag, code => {
                Debug.Log("club enterRoom code=" + code);
                if (0 != code)
                {
                    mShow = true;

                    string content = "房间不存在";

                    if (code == 2224)
                    {
                        content = "房间已满!";
                    }
                    else if (code == 2222)
                    {
                        content = "钻石不足";
                    }
                    else if (code == 2231)
                    {
                        content = "您的IP和其他玩家相同";
                    }
                    else if (code == 2232)
                    {
                        content = "您的位置和其他玩家太近";
                    }
                    else if (code == 2233)
                    {
                        content = "您的定位信息无效,请检查是否开启定位";
                    }
                    else if (code == 2251)
                    {
                        content = "您不是俱乐部普通成员,无法加入俱乐部房间";
                    }

                    GameAlert.Show(content);
                }
            });
        });

        setBtnEvent(detail, "btn_back", () => {
            mRoomID = 0;
            setActive(detail, null, false);
        });
    }
Esempio n. 5
0
    void showRooms()
    {
        int     cnt = mRooms.Count;
        GameMgr gm  = GameMgr.GetInstance();
        int     uid = GameMgr.getUserMgr().userid;

        bool show = false;

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

            int j = 0;

            for (; j < room.players.Count && j < table.childCount; j++)
            {
                ClubRoomPlayer p     = room.players [j];
                Transform      s     = table.GetChild(j);
                bool           empty = p.id == 0;

                s.gameObject.SetActive(true);

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

                UIButton btn = s.GetComponent <UIButton>();
                btn.enabled = empty;
                if (empty)
                {
                    setBtnEvent(s, null, () => {
                        showDetail(room);
                    });

                    continue;
                }

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

                if (p.id == uid)
                {
                    found = true;
                }
            }

            for (int k = j; k < table.childCount; k++)
            {
                Transform s = table.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);
            setActive(item, "btn_leave", found);

            if (found)
            {
                setBtnEvent(item, "btn_leave", () => {
                    leaveRoom(room.id, room.room_tag);
                });
            }

            if (mRoomID == room.id)
            {
                show = true;
                showDetail(room);
            }
        }

        updateItems(mRooms.Count);

        if (!show)
        {
            mRoomID = 0;
            setActive(transform, "detail", false);
        }
    }
Esempio n. 6
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);
    }