Ejemplo n.º 1
0
    private void OnResCreateRoom(NotificationArg arg)
    {
        var data = arg.GetValue <ResCreateRoom>();

        if (data.code != 0)
        {
            MsgBox.ShowErr(data.msg, 2);
            return;
        }
        Data.Game.Id = data.roomId;

        createRoomWindow.Hide();
        SceneManager.LoadScene("Game");
    }
Ejemplo n.º 2
0
    private void OnResLoginByWeChatCode(NotificationArg arg)
    {
        var data = arg.GetValue <ResLoginByWeChatCode>();

        if (data.code != 0)
        {
            MsgBox.ShowErr(data.msg, 2);
            Data.User.Token = "";
            return;
        }
        Debug.Log(data.code + "  " + data.msg + "   " + data.token);
        Data.User.Token = data.token;
        SceneManager.LoadScene("Menu");
    }
Ejemplo n.º 3
0
        private void OnResClubUsers(NotificationArg arg)
        {
            var data = arg.GetValue <ResClubUsers>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                return;
            }
            Data.Club.Users = data.users;
            usersWindow.Show();
            usersWindow.position = new Vector3();
            usersWindow.width    = mainUI.width;
            usersWindow.height   = mainUI.height;
        }
Ejemplo n.º 4
0
        private void OnBroadcastBanker(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastBanker>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            ui.GetChild("btnTimes").visible = false;
            Debug.Log("庄家是:" + data.game.playerId + "  " + data.game.banker);
            if (Data.User.Id != data.game.playerId)
            {
                ui.GetChild("btnScores").visible = true;
            }


            foreach (var p in Data.Game.Players.Values)
            {
                if (p.Info.id == data.game.playerId)
                {
                    p.IsBanker = true;

                    var zhuang = p.PlayerUi.GetChild("zhuang");
                    var zScale = zhuang.scale;
                    zhuang.position = zhuang.GlobalToLocal(cardCenterPlace.position);

                    zhuang.SetScale(4f, 4f);
                    zhuang.visible = true;

                    zhuang.TweenMove(new Vector2(p.zhuangPos.x, p.zhuangPos.y), 0.5f);
                    zhuang.TweenScale(new Vector2(zScale.x, zScale.y), 0.5f).OnComplete(() =>
                    {
                        zhuang.SetScale(1f, 1f);
                    });
                }
                else
                {
                    // 隐藏所有闲家家抢庄倍数
                    var tc = p.PlayerUi.GetController("times");
                    tc.selectedIndex = 0;
                }
            }

            hideSetScoreTips();
            nScoreTips = 5;
            showSetScoreTips();
        }
Ejemplo n.º 5
0
        private void OnResExitClub(NotificationArg arg)
        {
            var data = arg.GetValue <ResExitClub>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                return;
            }
            if (data.clubId != Data.Club.Id)
            {
                Debug.Log("收到不是当前茶楼的消息");
                return;
            }
            exit();
        }
Ejemplo n.º 6
0
        private void OnResGameStart(NotificationArg arg)
        {
            var data = arg.GetValue <ResClubGameStart>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                return;
            }
            if (data.clubId != Data.Club.Id)
            {
                Debug.LogWarning("收到不是当前茶楼的消息");
                return;
            }
            Api.Room.GetRoom(data.roomId);
        }
Ejemplo n.º 7
0
        private void OnBroadcastDefaultVoice(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastDefaultVoice>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            if (data.roomId != Data.Game.Id)
            {
                Debug.Log("收到不属于该房间的消息,来自房间号:" + data.roomId);
                return;
            }

            if (data.voiceId < 0 || data.voiceId > 9 || data.sex < 0 || data.sex > 1)
            {
                Debug.Log("声音编号或性别不合法");
                return;
            }


            var index = data.deskId - Data.Game.DeskId;

            if (index < 0)
            {
                index = 10 + index;
            }


            gameAudio.clip = Resources.Load <AudioClip>("Game/audio/voice/voice_" + data.voiceId + "_" + data.sex);
            gameAudio.Play();

            // 自己不用显示
            if (data.deskId == Data.Game.DeskId)
            {
                return;
            }
            var playerUi = ui.GetChild("player" + (index + 1)).asCom;
            var c        = playerUi.GetController("speak");

            c.selectedIndex = 1;
            playerUi.TweenScale(new Vector2(1, 1), 3).OnComplete(() =>
            {
                c.selectedIndex = 0;
            });
        }
Ejemplo n.º 8
0
    private void OnResShareText(NotificationArg arg)
    {
        var data = arg.GetValue <ResShareText>();

        if (data.code != 0)
        {
            MsgBox.ShowErr(data.msg);
            return;
        }
#if UNITY_IPHONE
        ShareText(data.shareText);
#elif UNITY_ANDROID
        AndroidJavaClass  jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject>("currentActivity");
        jo.Call("shareText", data.shareText);
#endif
    }
Ejemplo n.º 9
0
        private void OnBroadcastTimes(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastTimes>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            ShowSetTimes(data.game.roomId, data.game.playerId, data.game.times);
            // 如果是自己,就隐藏抢庄按钮
            if (data.game.playerId == Data.User.Id)
            {
                ui.GetChild("btnTimes").visible = false;
            }
            Debug.Log(data.game.playerId + "抢庄倍数:" + data.game.times);
        }
Ejemplo n.º 10
0
        private void OnBroadcastSitRoom(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastSitRoom>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                return;
            }
            if (data.roomId != Data.Game.Id)
            {
                Debug.LogWarning("收到不属于该房间的消息:BroadcastSitRoom");
                return;
            }
            AddPlayer(data.deskId, data.uid);
            Api.User.GetUserInfo(data.uid);
        }
Ejemplo n.º 11
0
        private void OnBroadcastJoinClub(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastJoinClub>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                exit();
                return;
            }

            if (data.uid == Data.User.Id)
            {
                Api.Club.GetClub(Data.Club.Id);
                Api.Club.ClubRooms(Data.Club.Id);// 获取当前茶楼所有房间信息
            }
        }
Ejemplo n.º 12
0
        private void OnBroadcastCompareCard(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastCompareCard>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            hideSetScoreTips();
            // 隐藏网络延迟导致迟收到选庄包显示的下注按钮
            ui.GetChild("btnScores").visible   = false;
            ui.GetChild("btnKanpai").visible   = false;
            ui.GetChild("btnLiangpai").visible = false;

            var games = data.games;

            foreach (var game in games)
            {
                var me = game.playerId == Data.User.Id && !isLiangpai;
                PutCard(game.deskId, game.cards, game.cardType, me);
                showNiu(game.playerId, game.cardType);
                Debug.Log(game.playerId + ":" + game.totalScore);

                Data.Game.TotalScore.Add(Data.Game.Id, game.playerId, game.totalScore);

                var p       = Data.Game.GetPlayer(game.playerId);
                var scoreUi = p.PlayerUi.GetChild("score");

                var offsetY = -40;
                if (game.totalScore > 0)
                {
                    scoreUi.text = "+" + game.totalScore;
                }
                else
                {
                    scoreUi.text = "" + game.totalScore;
                }
                scoreUi.TweenMoveY(p.scorePos.y + offsetY, 2f).OnComplete(() =>
                {
                    scoreUi.position = p.scorePos;
                    scoreUi.text     = Data.Game.TotalScore.Get(Data.Game.Id, game.playerId) + "";
                });
            }
        }
Ejemplo n.º 13
0
        private void OnBroadcastAllScore(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastAllScore>();


            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            if (data.roomId != Data.Game.Id)
            {
                Debug.Log("收到不属于该房间的消息,来自房间号:" + data.roomId);
                return;
            }

            if (data.users == null)
            {
                return;
            }


            TuiUser t = null;

            foreach (var v in data.users)
            {
                if (v.uid != Data.User.Id)
                {
                    continue;
                }
                t = v;
            }


            if (t == null)  // 如果不能推注,隐藏第3个按钮
            {
                btnScore3.title   = "0";
                btnScore3.visible = false;
            }
            else
            {
                btnScore3.title   = t.score + "";
                btnScore3.visible = true;
            }
        }
Ejemplo n.º 14
0
        private void OnResDeleteRoom(NotificationArg arg)
        {
            var data = arg.GetValue <ResDeleteRoom>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            if (data.roomId != Data.Game.Id)
            {
                Debug.LogWarning("收到不属于该房间的消息:ResDeleteRoom");
                return;
            }
            MsgBox.ShowErr("房间已解散", 1);
            Data.Game.Id = 0;
            LeaveRoom();
        }
Ejemplo n.º 15
0
        private void OnResRoomList(NotificationArg arg)
        {
            var data = arg.GetValue <ResRoomList>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            if (data.rooms == null)
            {
                return;
            }
            foreach (var room in data.rooms)
            {
                addRoomItem(room);
            }
        }
Ejemplo n.º 16
0
        private void OnResEditClubUser(NotificationArg arg)
        {
            var data = arg.GetValue <ResEditClubUser>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                return;
            }

            if (data.clubId != Data.Club.Id)
            {
                Debug.Log("收到不是当前俱乐部的消息,来自俱乐部id:" + data.clubId);
                return;
            }

            Api.Club.ClubUsers(Data.Club.Id);
        }
Ejemplo n.º 17
0
        private void OnResClubList(NotificationArg arg)
        {
            var data = arg.GetValue <ResClubList>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            if (data.clubs == null)
            {
                return;
            }
            foreach (var club in data.clubs)
            {
                addClubItem(club);
            }
        }
Ejemplo n.º 18
0
        private void OnResEditClubRoom(NotificationArg arg)
        {
            var data = arg.GetValue <ResEditClubRoom>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                return;
            }
            if (data.clubId != Data.Club.Id)
            {
                Debug.Log("收到不是当前茶楼的消息");
                return;
            }
            // 更新茶楼信息
            Api.Club.GetClub(Data.Club.Id);
            editClubRoomWindow.Hide();
        }
Ejemplo n.º 19
0
        private void OnResSit(NotificationArg arg)
        {
            var data = arg.GetValue <ResSit>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                if (data.msg == "您当前正在其他房间")
                {
                    Data.Game.Id   = data.roomId;
                    Data.Game.info = null;
                    LeaveRoom();
                    return;
                }
                exit();
                return;
            }

            Data.Game.DeskId = data.deskId;
            addPlayers(data.players);



            // 如果是首位开始类型的房间,自己也是第一个来的,就显示开始按钮
            if (Data.Game.info.startType == 1 && data.players.Count == 1 && Data.Game.info.current == 0)
            {
                btnStart.visible = true;
            }
            else if (Data.Game.info.startType == 0 && data.uid == Data.Game.info.uid && Data.Game.info.current == 0) // 老板开始游戏并且自己是老板,就显示开始按钮
            {
                btnStart.visible = true;
            }
            else if (Data.Game.info.status == 0)
            {
                ShowTips("您已准备好,等待房主开始游戏···");
            }

            // 如果游戏开始后重新进入游戏,显示提示层
            if (Data.Game.info.current > 0)
            {
                ui.GetController("panel").selectedIndex = 1;
                ui.GetChild("panel").sortingOrder       = 20000;
            }
        }
Ejemplo n.º 20
0
    private void OnResNotice(NotificationArg arg)
    {
        var data = arg.GetValue <ResNotice>();

        if (data.code != 0)
        {
            MsgBox.ShowErr(data.msg);
            return;
        }

        MsgWindow msgWindow = new MsgWindow();

        msgWindow.Show();
        msgWindow.position = new Vector2();
        msgWindow.width    = mainUI.width;
        msgWindow.height   = mainUI.height;
        msgWindow.SetTitle("消息通知");
        msgWindow.SetMsg(data.notice != ""?data.notice:"<center>暂无通知</center>");
    }
Ejemplo n.º 21
0
        private void OnResClubRoomUsers(NotificationArg arg)
        {
            var data = arg.GetValue <ResClubRoomUsers>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                return;
            }
            if (data.users == null)
            {
                return;
            }
            foreach (var u in data.users)
            {
                Debug.Log(u.nick);
                updateDeskUser(data.tableId, u.deskId, u.avatar, u.nick);
            }
        }
Ejemplo n.º 22
0
        private void OnBroadcastGameOver(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastGameOver>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            if (data.roomId != Data.Game.Id)
            {
                Debug.Log("收到不属于该房间的消息,来自房间号:" + data.roomId);
                return;
            }

            ui.GetChild("defaultVoice").asComboBox.Dispose();

            Data.Game.TotalScore.Clear();
            Data.Game.Id = 0;
            SceneManager.LoadScene("History");
        }
Ejemplo n.º 23
0
        private void OnBroadcastScore(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastScore>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                return;
            }
            ShowSetScore(data.game.roomId, data.game.playerId, data.game.score);
            // 如果是自己,就隐藏下注按钮
            if (data.game.playerId == Data.User.Id)
            {
                // 如果是自己,就播放下注音乐
                gameAudio.clip = Resources.Load <AudioClip>("Game/audio/game_setScore");
                gameAudio.Play();
            }
            ui.GetChild("btnScores").visible = false;
            Debug.Log(data.game.playerId + " 下注:" + data.game.score);
            //hideSetScoreTips();
        }
Ejemplo n.º 24
0
        private void OnResRoom(NotificationArg arg)
        {
            var data = arg.GetValue <ResRoom>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                exit();
                return;
            }

            var room = data.room;

            Data.Game.info = room;


            var text = "";

            if (Data.Club.Id > 0)
            {
                text += "茶楼:" + Data.Club.Id + "\n";
                text += "桌号:" + "第" + Data.Club.TableId + "桌\n";
            }
            else
            {
                text += "房号:" + room.id + "\n";
            }


            text += "底分:" + scores[room.score] + "\n";
            text += "局数:" + room.current + "/" + room.count;

            ui.GetChild("infoText").text = text;


            if (Data.Game.GetPlayer(Data.User.Id) == null)
            {
                Api.Room.Sit(Data.Game.Id);
            }
        }
Ejemplo n.º 25
0
        private void OnResClub(NotificationArg arg)
        {
            var data = arg.GetValue <ResClub>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg, 2);
                exit();
                return;
            }

            Data.Club.Info   = data.club;
            Data.Club.IsBoss = data.club.uid == Data.User.Id;

            var info = ui.GetChild("header").asCom.GetChild("info").asTextField;

            info.text = Data.Club.Id + "\n" + data.club.name;

            var roll = ui.GetChild("rollText").asCom;

            roll.GetChild("text").text = data.club.rollText;

            Tables.RemoveChildrenToPool();
            for (var i = 1; i <= 10; i++)
            {
                ClubInfo t = null;
                if (data.tables != null)
                {
                    foreach (var v in data.tables)
                    {
                        if (v.id == i)
                        {
                            t = v;
                        }
                    }
                }

                addItem(t == null?data.club:t, i);
            }
        }
Ejemplo n.º 26
0
        private void OnResJoinRoom(NotificationArg arg)
        {
            var data = arg.GetValue <ResJoinRoom>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                Data.Game.Id   = 0;
                Data.Game.info = null;
                LeaveRoom();

                return;
            }

            Api.Room.GetRoom(Data.Game.Id);
            Api.Room.Sit(Data.Game.Id);

            // 暂时不用围观功能,所以后面两句不需要调用

            //Data.Room.RemoveAllPlayers();
            //addPlayers(data.players);
        }
Ejemplo n.º 27
0
        private void OnResClubRooms(NotificationArg arg)
        {
            var data = arg.GetValue <ResClubRooms>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                return;
            }
            if (data.rooms == null)
            {
                return;
            }
            foreach (var room in data.rooms)
            {
                if (room.clubId != Data.Club.Id)
                {
                    Debug.Log("收到不是当前俱乐部的消息");
                    continue;
                }
                Api.Room.GetRoom(room.id);
            }
        }
Ejemplo n.º 28
0
        private void OnResLeaveRoom(NotificationArg arg)
        {
            var data = arg.GetValue <ResLeaveRoom>();

            if (data.code != 0 && data.msg != "该房间不存在")
            {
                MsgBox.ShowErr(data.msg);
                return;
            }
            // 如果是自己退出,就返回菜单页
            if (data.uid == Data.User.Id)
            {
                Data.Game.Id   = 0;
                Data.Game.info = null;

                LeaveRoom();
                return;
            }

            // 其他用户退出
            var player = Data.Game.GetPlayer(data.uid);

            if (player == null)
            {
                Debug.LogWarning("用户退出失败:" + data.uid);
                return;
            }
            player.PlayerUi.visible = false;
            Data.Game.Players.Remove(data.uid);

            // 如果我是新房主,就显示开始按钮
            if (data.newBoss == Data.User.Id)
            {
                btnStart.visible = true;
                HideTips();
            }
        }
Ejemplo n.º 29
0
        private void OnBroadcastDelClub(NotificationArg arg)
        {
            var data = arg.GetValue <BroadcastDelClub>();

            if (data.code != 0)
            {
                MsgBox.ShowErr(data.msg);
                exit();
                return;
            }

            if (data.clubId != Data.Club.Id)
            {
                Debug.Log("收到不是当前俱乐部的消息,来自俱乐部id:" + data.clubId);
                return;
            }

            if (data.uid != Data.User.Id)
            {
                MsgBox.ShowErr("该茶楼被老板解散");
            }
            GRoot.inst.CloseAllWindows();
            exit();
        }
Ejemplo n.º 30
0
        private void OnResGameResult(NotificationArg arg)
        {
            ui.GetChild("textTip").text = "";

            var data = arg.GetValue <ResGameResult>();

            if (data.code != 0)
            {
                tPage = page;
                MsgBox.ShowErr(data.msg);
                return;
            }
            page = tPage;

            ui.GetChild("roomId").text = "房号:" + data.room.id;
            ui.GetChild("count").text  = "局数:" + data.room.count;
            ui.GetChild("score").text  = "底分:" + scores[data.room.score];

            DateTime dt = DateTime.ParseExact(data.room.createdAt, "yyyy-MM-ddTHH:mm:ss+08:00", System.Globalization.CultureInfo.CurrentCulture);

            ui.GetChild("time").text = "" + dt.ToString("yyyy-MM-dd HH:mm:ss");


            foreach (var u in users)
            {
                u.visible = false;
            }

            var i    = 0;
            var minG = data.games[0]; // 总分最小的玩家的数据
            var maxG = data.games[1];
            var minU = users[0];      // 总分最小的玩家的ui句柄
            var maxU = users[1];

            foreach (var u in data.games)
            {
                var userUi = users[i++];


                // 找出最大最小
                if (u.totalScore > maxG.totalScore)
                {
                    maxG = u;
                    maxU = userUi;
                }
                else if (u.totalScore < minG.totalScore)
                {
                    minG = u;
                    minU = userUi;
                }

                userUi.visible = true;
                var userInfo = userUi.GetChild("userInfo").asCom;
                userInfo.GetChild("imgAvatar").asLoader.url = Utils.Helper.GetReallyImagePath(u.avatar);

                var nick = userInfo.GetChild("textNick").asTextField;
                var id   = userInfo.GetChild("textId").asTextField;
                nick.text = "昵称:" + u.nick;
                id.text   = "ID:" + u.uid;
                if (u.uid == Data.User.Id)
                {
                    nick.color = new Color(255, 255, 0);
                    id.color   = new Color(255, 255, 0);
                }
                else
                {
                    nick.color = new Color(255, 255, 255);
                    id.color   = new Color(255, 255, 255);
                }

                var        score = userUi.GetChild("score").asTextField;
                TextFormat tf    = score.textFormat;
                if (u.totalScore >= 0)
                {
                    tf.font = "ui://1ad63yxfq9h6q5";
                }
                else
                {
                    tf.font = "ui://1ad63yxfq9h6q6";
                }

                score.textFormat = tf;
                score.text       = (u.totalScore > 0 ? "+" : "") + u.totalScore;
                score.data       = score.text;
                var zhuang = userUi.GetChild("zhuang");
                zhuang.text = u.banks + "";
            }

            // 显示大赢家和土豪
            if (minG.totalScore == 0)
            {
                return;
            }
            minU.GetController("winner").selectedIndex = 2;
            maxU.GetController("winner").selectedIndex = 1;
        }