예제 #1
0
    public TingInfo doTing(JsonObject data)
    {
        TingInfo _info = JsonUtility.FromJson <TingInfo>(data.ToString());

        SeatInfo seat = seats[_info.seatindex];

        seat.tings   = _info.tings;
        seat.hus     = _info.hus;
        seat.tingpai = true;

        return(_info);
    }
예제 #2
0
    void InitHandler()
    {
        NetMgr       net = NetMgr.GetInstance();
        RoomMgr      rm  = RoomMgr.GetInstance();
        PomeloClient pc  = net.pc;

        pc.on("login_result", data => {
            Debug.Log("login_result");

            object ob;
            if (!data.TryGetValue("errcode", out ob))
            {
                return;
            }

            int ret = Convert.ToInt32(ob);
            if (ret != 0)
            {
                Debug.Log("login_result ret=" + ret);
                return;
            }

            JsonObject room = (JsonObject)data["data"];

            rm.updateRoom(room);

            DispatchEvent("game_reset");
        });

        pc.on("login_finished", data => {
            Debug.Log("login_finished");

            string table = "04.table3d";
            string name  = SceneManager.GetActiveScene().name;

            if (name != table)
            {
                mHandlerMap.Clear();
                LoadingScene.LoadNewScene(table);
            }
            else
            {
                if (rm.isPlaying())
                {
                    net.send("ready");
                }
            }
        });

        pc.on("exit_result", data => {
            string reason = (string)data["reason"];

            if (reason == "kick")
            {
                GameAlert.GetInstance().show("您已被管理员请出房间", () => {
                    GameManager.GetInstance().exit();
                });
            }
            else if (reason == "request")
            {
                GameManager.GetInstance().exit();
            }
        });

        pc.on("exit_notify_push", data => {
            int uid       = Convert.ToInt32(data["value"]);
            int seatindex = rm.userExit(uid);

            DispatchEvent("user_state_changed", seatindex);
        });

        pc.on("dispress_push", data => {
            GameManager.GetInstance().exit();
        });

        pc.on("new_user_comes_push", data => {
            int seatindex = rm.newUserCome(data);

            DispatchEvent("user_state_changed", seatindex);
        });

        pc.on("user_state_push", data => {
            int seatindex = rm.updateUser(data);

            DispatchEvent("user_state_changed", seatindex);
        });

        pc.on("game_wait_maima_push", data => {
            rm.updateMaima(data);

            DispatchEvent("game_wait_maima");
        });

        pc.on("game_maima_push", data => {
            rm.updateMaima(data);

            DispatchEvent("game_maima");
        });

        pc.on("user_ready_push", data => {
            int seatindex = rm.updateUser(data);

            DispatchEvent("user_state_changed", seatindex);
        });

        pc.on("game_dice_push", data => {
            rm.updateState(data);

            DispatchEvent("game_dice");
        });

        pc.on("game_holds_push", data => {
            Debug.Log("get game_holds_push");

            int si = rm.updateSeat(data);
            DispatchEvent("game_holds", si);
        });

        pc.on("game_holds_len_push", data => {
            Debug.Log("get game_holds_len_push");

            int si = rm.updateSeat(data);

            DispatchEvent("game_holds_len", si);
        });

        pc.on("game_state_push", data => {
            rm.updateState(data);

            DispatchEvent("game_state");
        });

        pc.on("game_begin_push", data => {
            Debug.Log("get game_begin_push");

            rm.newRound();
            rm.updateState(data);

            foreach (PlayerInfo p in rm.players)
            {
                p.ready = false;
                DispatchEvent("user_state_changed", p.seatindex);
            }

            DispatchEvent("game_begin");
        });

        pc.on("game_playing_push", data => {
            Debug.Log("get game_playing_push");
            rm.updateState(data);

            DispatchEvent("game_playing");
        });

        pc.on("game_sync_push", data => {
            Debug.Log("get game_sync_push");

            if (!data.ContainsKey("pseudo"))
            {
                rm.updateState(data);
                rm.updateSeats((JsonArray)data["seats"]);
            }

            DispatchEvent("user_hf_updated");
            DispatchEvent("game_sync");
        });

        pc.on("hangang_notify_push", data => {
            int seatindex = Convert.ToInt32(data["seatindex"]);
            DispatchEvent("hangang_notify", seatindex);
        });

        pc.on("game_action_push", data => {
            Debug.Log("get game_action_push");
            rm.updateAction(data);

            DispatchEvent("game_action");
        });

        pc.on("game_chupai_push", data => {
            Debug.Log("get game_chupai_push");
            rm.updateState(data);

            ChupaiPush cp = JsonUtility.FromJson <ChupaiPush> (data.ToString());
            rm.updateLimit(cp.turn, cp.limit);

            if (cp.bg == true)
            {
                return;
            }

            DispatchEvent("game_turn_change");
        });

        pc.on("game_num_push", data => {
            rm.updateRoomInfo(data);

            DispatchEvent("game_num");
        });

        pc.on("game_over_push", data => {
            rm.updateOverInfo(data);

            DispatchEvent("game_over");
        });

        pc.on("mj_count_push", data => {
            rm.updateState(data);

            if (data.ContainsKey("bg"))
            {
                return;
            }

            DispatchEvent("mj_count");
        });

        pc.on("hu_push", data => {
            HuPushInfo info = rm.updateHu(data);

            if (info.bg)
            {
                return;
            }

            DispatchEvent("hupai", info);
        });

        pc.on("game_chupai_notify_push", data => {
            Debug.Log("get game_chupai_notify_push");
            ActionInfo info = rm.doChupai(data);

            if (info.bg == true)
            {
                return;
            }

            DispatchEvent("game_chupai_notify", info);
        });

        pc.on("game_hf_push", data => {
            rm.updateFlowers(data);

            Debug.Log("get game_hf_push");

            DispatchEvent("user_hf_updated");
        });

        pc.on("game_af_push", data => {
            ActionInfo info = rm.doAddFlower(data);

            if (info.bg == true)
            {
                return;
            }

            DispatchEvent("user_hf_updated", info);
        });

        pc.on("game_mopai_push", data => {
            Debug.Log("get game_mopai_push");
            ActionInfo info = rm.doMopai(data);

            if (info.bg == true)
            {
                return;
            }

            DispatchEvent("game_mopai", info);
        });

        pc.on("guo_notify_push", data => {
            Debug.Log("get guo_notify_push");
            ActionInfo info = rm.doGuo(data);

            if (info.bg == true)
            {
                return;
            }

            DispatchEvent("guo_notify", info);
        });

        pc.on("guo_result", data => {
            Debug.Log("get guo_result");
            DispatchEvent("guo_result");
        });

        pc.on("peng_notify_push", data => {
            ActionInfo info = rm.doPeng(data);

            if (info.bg == true)
            {
                return;
            }

            DispatchEvent("peng_notify", info);
        });

        pc.on("chi_notify_push", data => {
            ActionInfo info = rm.doChi(data);

            if (info.bg == true)
            {
                return;
            }

            DispatchEvent("chi_notify", info);
        });

        pc.on("gang_notify_push", data => {
            GangInfo info = rm.doGang(data);

            if (info.bg == true)
            {
                return;
            }

            DispatchEvent("gang_notify", info);
        });

        pc.on("ting_notify_push", data => {
            TingInfo info = rm.doTing(data);

            if (info.bg == true)
            {
                return;
            }

            DispatchEvent("ting_notify", info.seatindex);
        });

        pc.on("chat_push", data => {
            ChatInfo info = JsonUtility.FromJson <ChatInfo>(data.ToString());

            DispatchEvent("chat", info);
        });

        pc.on("quick_chat_push", data => {
            QuickChatInfo info = JsonUtility.FromJson <QuickChatInfo>(data.ToString());

            DispatchEvent("quick_chat_push", info);
        });

        pc.on("emoji_push", data => {
            EmojiPush info = JsonUtility.FromJson <EmojiPush>(data.ToString());
            DispatchEvent("emoji_push", info);
        });

        pc.on("demoji_push", data => {
            Debug.Log("get demoji_push");
            DEmojiPush info = JsonUtility.FromJson <DEmojiPush>(data.ToString());
            DispatchEvent("demoji_push", info);
        });

        pc.on("dissolve_notice_push", data => {
            DissolveInfo dv = JsonUtility.FromJson <DissolveInfo>(data.ToString());
            rm.dissolve     = dv;

            DispatchEvent("dissolve_notice", dv);
        });

        pc.on("dissolve_done_push", data => {
            Debug.Log("dissolve_done_push");
            DispatchEvent("dissolve_done");
        });

        pc.on("dissolve_cancel_push", data => {
            Debug.Log("dissolve_cancel_push");

            DissolveCancel dc = JsonUtility.FromJson <DissolveCancel>(data.ToString());

            DispatchEvent("dissolve_cancel", dc);
        });

        pc.on("voice_msg_push", data => {
            VoiceMsgPush vm = JsonUtility.FromJson <VoiceMsgPush>(data.ToString());
            DispatchEvent("voice_msg", vm);
        });

        pc.on("start_club_room", data => {
        });

        pc.on("club_room_updated", data => {
            DispatchEvent("club_room_updated", data);
        });

        pc.on("clu_room_removed", data => {
            DispatchEvent("clu_room_removed", data);
        });

        pc.on("club_message_notify", data => {
            ClubMessageNotify ret = JsonUtility.FromJson <ClubMessageNotify>(data.ToString());

            sclub_message_notify = ret;

            DispatchEvent("club_message_notify", ret);
        });

        pc.on("sys_message_updated", data => {
            DispatchEvent("sys_message_updated", data);
        });

        pc.on("recommend_room_updated", data => {
            Debug.Log("recommend_room_updated");
            DispatchEvent("recommend_room_updated", data);
        });
    }