Пример #1
0
    public void gameover(JSONObject messageObj)
    {
        //{"body": {"user_info": [{"add_score": 300, "uid": 89062723, "cards": [], "double": 3, "win_round": 1, "fail_round": 0, "ave_score": 300, "round": 1, "sum_score": 300, "is_win": true},
        //{"add_score": 30, "uid": 116355, "cards": [0, 28, 42, 43, 5, 31, 32, 20, 46, 9, 22, 35, 48, 36, 49, 51], "double": 3, "win_round": 0, "fail_round": 1, "ave_score": 30, "round": 1,
        //"sum_score": 30, "is_win": false}, {"add_score": 30, "uid": 118152, "cards": [41, 47, 50, 12, 25], "double": 3, "win_round": 0, "fail_round": 1, "ave_score": 30, "round": 1,
        //"sum_score": 30, "is_win": false}], "rocket_times": 0, "winner": 89062723, "bomb_times": 0, "is_spring": false}, "tag": "gameover", "type": "ddz"}
        for (int i = 0; i < messageObj["body"]["user_info"].list.Count; i++)
        {
            if (mainCls.getPlayerWithID((int)messageObj["body"]["winner"].n).isBanker)
            {
                if (messageObj["body"]["user_info"].list[i]["uid"].n == messageObj["body"]["winner"].n)
                {
                    messageObj["body"]["user_info"].list[i]["winmoney"] = messageObj["body"]["user_info"].list[i]["add_score"];
                }
                else
                {
                    messageObj["body"]["user_info"].list[i]["winmoney"] = new JSONObject((-messageObj["body"]["user_info"].list[i]["add_score"].n).ToString());
                }
            }
            else
            {
                if (!mainCls.getPlayerWithID((int)messageObj["body"]["user_info"].list[i]["uid"].n).isBanker)
                {
                    messageObj["body"]["user_info"].list[i]["winmoney"] = messageObj["body"]["user_info"].list[i]["add_score"];
                }
                else
                {
                    messageObj["body"]["user_info"].list[i]["winmoney"] = new JSONObject((-messageObj["body"]["user_info"].list[i]["add_score"].n).ToString());
                }
            }
        }
        messageObj["body"]["double"]         = messageObj["body"]["user_info"].list[0]["double"];
        messageObj["body"]["user_win_money"] = messageObj["body"]["user_info"];
//		Debug.LogError( messageObj.ToString() );
    }
Пример #2
0
    public void ProcessDeal(JSONObject messageObj)
    {
        /*
         * => 发牌
         * {"body": {"player_infos": [{"win_times": 142, "active_point": 0, "uid": 312503, "mobile_type": -1, "level": 0, "bag_money": 1148854,
         * "into_money": 1148834, "winning": 28, "avatar_img": "", "avatar_no": 12, "is_staff": false, "exp": 16,
         * "vip_level": 0, "cards": [0, 1, 14, 2, 41, 16, 17, 5, 18, 6, 46, 9, 35, 10, 38, 51, 52], "position": 0, "nickname": "wyg123456", "lose_times": 357, "client_address": "北京市"},
         * {"win_times": 1200, "active_point": 0, "uid": 299017, "mobile_type": -1, "level": 0, "bag_money": 42137, "into_money": 42117, "winning": 62, "avatar_img": "", "avatar_no": 1, "is_staff": false, "exp": 0, "vip_level": 0, "cards": [26, 40, 42, 30, 31, 45, 20, 8, 21, 47, 22, 23, 24, 37, 50, 12, 53], "position": 1, "nickname": "sygame08", "lose_times": 709, "client_address": "北京市"},
         *
         * {"win_times": 4, "active_point": 0, "uid": 337666, "mobile_type": -1, "level": 0, "bag_money": 928, "into_money": 968, "winning": 28, "avatar_img": "", "avatar_no": 2, "is_staff": false, "exp": 0.0, "vip_level": 0, "cards": [13, 39, 27, 15, 29, 4, 43, 44, 19, 32, 7, 33, 34, 48, 36, 11, 25], "position": 2, "nickname": "forker", "lose_times": 10, "client_address": "北京市"}],
         *
         * "visible_card": 47, "visible_index": 9, "deskinfo": {"unit_money": 5, "room_type": 20, "top_money": 500}, "banker": 299017, "timeout": 12, "hide_cards": [3, 49, 28]}, "tag": "deal", "type": "ddz"}
         */

        JSONObject body = messageObj["body"];

//		List<JSONObject> cards = body["mycards"].list;
        int timeout = (int)body["timeout"].n;

        DDZCount.Instance.DestroyHUD();
        foreach (GameObject player in mainCls._playingPlayerList)
        {
            if (player != null)
            {
                DDZPlayerCtrl ctrl         = player.GetComponent <DDZPlayerCtrl>();
                bool          tempShowDeck = false;
                if (ctrl.isShowDeck)
                {
                    tempShowDeck = true;
                }
                ctrl.resetState();
                if (tempShowDeck)
                {
                    ctrl.isShowDeck = true;
                }
                ctrl.Clearcards();
            }
        }
        foreach (JSONObject playerInfo in body["player_infos"].list)
        {
            List <JSONObject> cards = playerInfo["cards"].list;
            if (playerInfo["uid"].n == mainCls.obID)
            {
                mainCls.userPlayerCtrl.SetDeal(cards);
            }
            else
            {
                DDZPlayerCtrl playCtrl = mainCls.getPlayerWithID((int)playerInfo["uid"].n);
                if (playCtrl != null)
                {
                    bool needReset = true;
                    if (playCtrl.isShowDeck)
                    {
                        needReset = false;
                    }
                    mainCls.StartCoroutine(playCtrl.showDeck(cards));
                    if (needReset)
                    {
                        playCtrl.isShowDeck = false;
                    }
                }
            }
        }
        foreach (GameObject player in mainCls._playingPlayerList)
        {
            if (player != null)
            {
                DDZPlayerCtrl ctrl = player.GetComponent <DDZPlayerCtrl>();
                ctrl.updateCardCount(17, true);
            }
        }
    }