Exemplo n.º 1
0
        private void ListView_AddGangEvent(object sender, EventArgs e)
        {
            var gi = new GangInfo();

            if (gi.ShowDialog() == DialogResult.OK)
            {
                fileCabinet.CriminalGangs.Add(gi.Gang);
                listView.GBS.DataSource = fileCabinet.CriminalGangs;
                listView.GBS.ResetBindings(false);
                // select and scroll to the last row
                var lastIdx = listView.GangList.Rows.Count - 1;
                listView.GangList.Rows[lastIdx].Selected          = true;
                listView.GangList.FirstDisplayedScrollingRowIndex = lastIdx;
            }
        }
Exemplo n.º 2
0
    public GangInfo doGang(JsonObject data)
    {
        GangInfo _info = JsonUtility.FromJson <GangInfo>(data.ToString());

        int        pai      = _info.pai;
        string     gangtype = _info.gangtype;
        SeatInfo   seat     = seats[_info.seatindex];
        List <int> holds    = seat.holds;
        List <int> pengs    = seat.pengs;

        int c = pai % 100;

        if (gangtype == null || gangtype == "")
        {
            gangtype       = getGangType(seat, c);
            _info.gangtype = gangtype;
        }

        Debug.Log("gangtype=" + gangtype);

        if ("wangang" == gangtype)           // wangang
        {
            for (int i = 0; i < pengs.Count; i++)
            {
                if (c == pengs[i] % 100)
                {
                    pengs.RemoveAt(i);
                    break;
                }
            }

            removeFromList(holds, c);
            seat.wangangs.Add(pai);
        }
        else if ("diangang" == gangtype)                // diangang
        {
            removeFromList(holds, c, 3);
            seat.diangangs.Add(pai);
        }
        else if ("angang" == gangtype)             // angang
        {
            removeFromList(holds, c, 4);
            seat.angangs.Add(pai);
        }

        return(_info);
    }
        public static async Task <GangInfo> GetGangInfo(string gangName)
        {
            using (WebClient wc = new WebClient())
            {
                string page = await wc.DownloadStringTaskAsync(new Uri($"https://zarpgaming.com/index.php/leaderboards/darkrp/gangs?search={gangName}"));

                Regex regex     = new Regex("specialrow\">(?s)(.*)<\\/tr>|krow(?s)(.*)<\\/tr>");
                Regex infoX     = new Regex("(?<=<td class=\"kcol-mid\">)(.*)(?=<\\/td>)");
                Regex gangIcon  = new Regex("(?<=\" src=\")(.*?)(?=\")");
                Regex gangOwner = new Regex("(?<=rel=\"nofollow\">)(.*)(?=<\\/a>)");

                string gangRow = regex.Match(page).ToString();

                //mc[0] = gang icon
                //mc[1] = gang name
                //mc[2] = gang owner
                //mc[3] = member count
                //mc[4] = gang cash
                //mc[5] = gang loot

                MatchCollection mc = infoX.Matches(gangRow);

                string gIcon = gangIcon.Match(mc[0].ToString()).ToString();
                string gName = mc[1].ToString();

                string gOwner;
                if (mc[2].ToString().Contains("nofollow"))
                {
                    gOwner = gangOwner.Match(mc[2].ToString()).ToString();
                }
                else
                {
                    gOwner = mc[2].ToString();
                }

                string memberCount = mc[3].ToString();
                string gangCash    = mc[4].ToString();
                string gangLoot    = mc[5].ToString();

                GangInfo gInfo = new GangInfo {
                    gangIcon = gIcon, gangName = gName, gangCash = gangCash, gangLoot = gangLoot, memberCount = memberCount, gangOwner = gOwner
                };

                return(gInfo);
            }
        }
Exemplo n.º 4
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);
        });
    }
Exemplo n.º 5
0
    void InitEventHandlers()
    {
        RoomMgr       rm = RoomMgr.GetInstance();
        GameMgr       gm = GameMgr.GetInstance();
        PlayerManager pm = PlayerManager.GetInstance();

        gm.AddHandler("game_holds", data => {
            EnQueueCmd("game_holds", data, item => {
                DHM_CardManager cm = pm.getCardManager((int)item.data);
                cm.FaPai();
            });
        });

        gm.AddHandler("game_holds_len", data => {
            EnQueueCmd("game_holds_len", data, item => {
                DHM_CardManager cm = pm.getCardManager((int)item.data);
                cm.FaPai();
            });
        });

        gm.AddHandler("game_begin", data => {
            EnQueueCmd("game_begin", data, item => {
                onGameBegin();
            });
        });

        gm.AddHandler("game_sync", data => {
            EnQueueCmd("game_sync", data, item => {
                if (rm.isPlaying())
                {
                    sync();
                }
            });
        });

        gm.AddHandler("game_action", data => {
            EnQueueCmd("game_action", data, item => {
                InteractMgr.GetInstance().ShowAction();
            });
        });

        gm.AddHandler("game_turn_change", data => {
            EnQueueCmd("game_turn_change", data, item => {
                TurnChange(rm.state.turn);
            });
        });

        gm.AddHandler("game_mopai", data => {
            EnQueueCmd("game_mopai", data, item => {
                ActionInfo info = (ActionInfo)item.data;

                MoPai(info.seatindex, info.pai);
                if (info.seatindex == rm.seatindex)
                {
                    InteractMgr.GetInstance().checkChuPai(true);
                }
            });
        });

        gm.AddHandler("user_hf_updated", data => {
            EnQueueCmd("user_hf_updated", data, item => {
                if (item.data == null)
                {
                    foreach (DHM_CardManager cm in pm.getCardManagers())
                    {
                        cm.UpdateFlowers();
                    }

                    syncDone(item);
                }
                else
                {
                    ActionInfo info = (ActionInfo)item.data;
                    AddFlower(info.seatindex, info.pai, () => syncDone(item));
                }
            }, false);
        });

        gm.AddHandler("hupai", data => {
            EnQueueCmd("hupai", data, item => {
                Hu((HuPushInfo)item.data, () => syncDone(item));
            }, false);
        });

        gm.AddHandler("game_chupai_notify", data => {
            EnQueueCmd("game_chupai_notify", data, item => {
                ActionInfo info = (ActionInfo)item.data;
                SomeOneChuPai(info.seatindex, info.pai, () => syncDone(item));
            }, false);
        });

        gm.AddHandler("guo_notify", data => {
            EnQueueCmd("guo_notify", data, item => {
                Guo();
            });
        });

        gm.AddHandler("peng_notify", data => {
            EnQueueCmd("peng_notify", data, item => {
                ActionInfo info = (ActionInfo)item.data;
                int si          = info.seatindex;

                Peng(si, info.pai);
            });
        });

        gm.AddHandler("ting_notify", data => {
            EnQueueCmd("ting_notify", data, item => {
                int si = (int)item.data;

                MainViewMgr.GetInstance().showAction(si, "ting");

                if (si == rm.seatindex)
                {
                    InteractMgr im = InteractMgr.GetInstance();

                    im.showPrompt();
                    im.checkChuPai(true);
                }

                DHM_CardManager cm = pm.getCardManager(si);
                cm.Ting();
            });
        });

        gm.AddHandler("chi_notify", data => {
            EnQueueCmd("chi_notify", data, item => {
                ActionInfo info = (ActionInfo)item.data;
                int si          = info.seatindex;

                Chi(si, info.pai);
            });
        });

        gm.AddHandler("gang_notify", data => {
            EnQueueCmd("gang_notify", data, item => {
                GangInfo info = (GangInfo)item.data;
                int type      = 0;
                int si        = info.seatindex;

                switch (info.gangtype)
                {
                case "diangang":
                    type = 1;
                    break;

                case "angang":
                    type = 2;
                    break;

                case "wangang":
                    type = 3;
                    break;
                }

                Debug.Log("gang_notify: type=" + info.gangtype + " pai=" + info.pai);

                Gang(si, info.pai, type);
            });
        });

        gm.AddHandler("game_dice", data => {
            EnQueueCmd("game_dice", data, item => {
                PlaySaiZi(rm.state.button, new int[] { rm.state.dice1, rm.state.dice2 });
            });
        });

        gm.AddHandler("game_over", data => {
            EnQueueCmd("game_over", data, item => {
                MainViewMgr.GetInstance().GameOver();
            });
        });

        gm.AddHandler("game_wait_maima", data => {
            EnQueueCmd("game_wait_maima", data, item => {
                MainViewMgr.GetInstance().showMaimaWait();
            });
        });

        gm.AddHandler("game_maima", data => {
            EnQueueCmd("game_maima", data, item => {
                MainViewMgr.GetInstance().showMaimaResult(() => syncDone(item));
            }, false);
        });
    }