Exemplo n.º 1
0
    public void OnClickTopCreateRoomBtn()
    {
        if (!_plazaPanel.activeSelf)
        {
            //
            //  这个时候需要判断是处于什么情况,分别有,创建房间,离开房间,解散房间
            switch (_actionType)
            {
            //case CommonDefine.eRoomActionType.CAN_CREATE_ROOM:
            //	OnClickTopCreateRoomBtn ();
            //	break;
            case CommonDefine.eRoomActionType.CAN_LEAVE_ROOM:
                //其他人离开就是普通离开房间
                RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.LEAVE_ROOM, false);
                break;

            case CommonDefine.eRoomActionType.CAN_DISSOLVE:
                //房主离开就是解散房间
                RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.LEAVE_ROOM, false);
                break;
            }
            return;
        }

        showPanel(ePlazaRoomPanelType.CREATE_PANEL);
    }
Exemplo n.º 2
0
    void OnEnable()
    {
        _lianQiPanel.gameObject.SetActive(false);
        _actionPanel.gameObject.SetActive(false);
        //_playerInfoPanel.SetActive (false);
        _chatPanel.gameObject.SetActive(false);
        _gameResultPanel.gameObject.SetActive(false);
        _lianQiWaitPanel.gameObject.SetActive(true);

        //投降和切换棋子信息不能点击
        enableTopBarButton(false);

        for (int i = 0; i < _players.Length; i++)
        {
            if (_players [i] != null)
            {
                Destroy(_players[i].gameObject);
            }
            _players [i] = null;
        }

        addAllEvent();

        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.ENTER_ROOM_FINISH, null);
    }
Exemplo n.º 3
0
    //------------------------------以下界面事件传出-----------------------------------------------
    //快速开始
    public void OnClickJoinRoom()
    {
        RoomEvent.sV2C_JoinRoom data;
        //请根据界面结果填写
        int pn = 2;
        int gl = 4;

        if (_currentType == CommonDefine.eRoomClassicType.MODE_2_4)
        {
            pn = 2;
            gl = 4;
        }
        else if (_currentType == CommonDefine.eRoomClassicType.MODE_2_6)
        {
            pn = 2;
            gl = 6;
        }
        else if (_currentType == CommonDefine.eRoomClassicType.MODE_4_6)
        {
            pn = 4;
            gl = 6;
        }

        data.playerNum = pn;
        data.gridLevel = gl;
        data.plazaID   = 0;      //c填写
        data.pwd       = "";
        data.roomId    = 0;
        data.plazaName = "";
        data.tagId     = 0;

        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.JOIN_ROOM, (object)data);
    }
Exemplo n.º 4
0
    public void OnPlayerClickReadyBtn()
    {
        RoomEvent.sV2C_PlayerAct data;
        data.act = RoomEvent.sV2C_PlayerAct.ACT_TYPE.ACT_READY;

        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.PLAYER_ACT, (object)data);
    }
Exemplo n.º 5
0
    void OnRespPlayerAct(Message msg)
    {
        // 自己只收到一个简单的响应,别人准备收到的是 playerstate
        //ret:
        msgSimpleResp resp = msgSimpleResp.deserialize(msg);
        SelfData      self = Account.getSelfData();

        if (resp.ret == 0)
        {
            //自己准备成功
            if (Room.Room.updatePlayerStateByUserID(self.userID, CommonDefine.PLAYER_STATE.STATE_TYPE_ROOMREADY))
            {
                RoomEvent.sC2V_PlayerState ps;
                ps.state      = CommonDefine.PLAYER_STATE.STATE_TYPE_ROOMREADY;
                ps.local      = Room.Room.getLocalBySeat(Room.Room.selfSeat);
                ps.ifAllReady = Room.Room.getIfAllPlayerReady();

                RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_PLAER_STATE, (object)ps);

                //准备成功,上报天赋列表
                RoomEvent.sV2C_PlayerTalentList ptl;
                ptl.local = ps.local;

                Room.Player?player = Room.Room.getPlayerBySeat(Room.Room.selfSeat);

                ptl.talentList = new List <int>();
                for (int i = 0; i < player.Value.talentList.Count; i++)
                {
                    ptl.talentList.Add((int)player.Value.talentList[i]);
                }

                onEventReportTalent((object)ptl);
            }
        }
    }
Exemplo n.º 6
0
    void onEnterRoomFinish(object data)
    {
        //刷新房间规则显示
        RoomEvent.sC2V_RoomRule rr;
        rr.playerNum   = Room.Room.roomRule.playerNum;
        rr.gameTime    = Room.Room.roomRule.gameTime;
        rr.gridLevel   = Room.Room.roomRule.gridLevel;
        rr.rule        = Room.Room.roomRule.rule;
        rr.lmtRound    = Room.Room.roomRule.lmtRound;
        rr.lmtTurnTime = Room.Room.roomRule.lmtTurnTime;
        rr.roomLevel   = Room.Room.roomLevel;
        rr.roomID      = 0;   //此处不需要,填0
        rr.plazaName   = Room.Room.plazaName;
        rr.tag         = Room.Room.tagId;
        rr.type        = (CommonDefine.eCreateRoomType)Room.Room.roomType;

        if (Room.Room.plazaid != 0)
        {
            LobbyEvent.Plaza plaza = getPlazaById(Room.Room.plazaid);
            rr.star = plaza.star;
        }
        else
        {
            rr.star = 0;
        }

        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_ROOMRULE, (object)rr);

        if (Room.Room.roomType == CommonDefine.eCreateRoomType.ROOM_CLASSIC_PLAZA ||
            Room.Room.roomType == CommonDefine.eCreateRoomType.ROOM_PLAZA ||
            Room.Room.isRelink)
        {
            //完全进入游戏界面后,需要通知服务器可以发用户enter信息了,原则上来说,需要界面真正加载完成后再发,这里暂时直接发送
            msgNotifyEnterRoomFinish efmsg = new msgNotifyEnterRoomFinish();
            efmsg.isRelink = Room.Room.isRelink;
            ProtocolManager.getInstance().sendMsg(GameProtocol.P_GAME_ENTER_ROOM_FINISH, efmsg);
        }
        else
        {
            // 因为房间和组队模式,用户相关信息已经下发,所以需要手动驱动相关消息刷新游戏界面
            for (int i = 0; i < Room.Room.playerList.Count; i++)
            {
                /////////////////////////////enter/////////////////////////////////
                RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.PLAER_ENTER, Room.Room.playerList[i]);

                ///////////////////////state/////////////////////////////////
                RoomEvent.sC2V_PlayerState ps;
                ps.state      = (CommonDefine.PLAYER_STATE)Room.Room.playerList[i].state;
                ps.local      = Room.Room.getLocalBySeat(Room.Room.playerList[i].seat);
                ps.ifAllReady = true;

                RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_PLAER_STATE, (object)ps);
            }

            //进入游戏后的start game
            onEventStartGame(true);
        }
    }
Exemplo n.º 7
0
    public void OnPlayerClickSendChatBtn(int chatID)
    {
        RoomEvent.sV2C_PlayerTalk data;
        data.content = "" + chatID;
        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.TALK_MSG, (object)data);

        //关闭聊天窗口
        _chatPanel.gameObject.SetActive(false);
    }
Exemplo n.º 8
0
    public void OnClickGetRoomList()
    {
        RoomEvent.sV2C_GetRoomList data;

        data.currentPage = 0;
        data.perCnt      = 10;

        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.GET_ROOM_LIST, (object)data);
    }
Exemplo n.º 9
0
    public void OnClickReady(bool ready)
    {
        //点击准备
        RoomEvent.sV2C_PlayerAct data;
        data.act = RoomEvent.sV2C_PlayerAct.ACT_TYPE.ACT_READY;

        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.PLAYER_ACT, (object)data);

        _readyBtn.interactable = false;
    }
Exemplo n.º 10
0
    void removeAllEvent()
    {
        LobbyEvent.EM().RemoveEvent(LobbyEvent.EVENT.UPDATE_PLAZA);

        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.UPDATE_LEAVE_ROOM);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.UPDATE_ROOMRULE);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.PLAER_ENTER);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.UPDATE_PLAER_STATE);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.UPDATE_DISSOLVE_ROOM);
    }
Exemplo n.º 11
0
    //玩家聊天
    void OnPlayerTalk(Message msg)
    {
        msgPlayerTalkMsg resp = msgPlayerTalkMsg.deserialize(msg);

        if (resp.flag == msgSimpleResp.eFlag.SUCCESS)
        {
            RoomEvent.sC2V_PlayerTalk pt;
            pt.local   = Room.Room.getLocalBySeat(resp.seat);
            pt.content = resp.content;
            RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.SHOW_TALK_MSG, (object)pt);
        }
    }
Exemplo n.º 12
0
    //--------------------------一些操作------------------------------------------------------
    void addAllEvent()
    {
        LobbyEvent.EM().AddEvent(LobbyEvent.EVENT.UPDATE_PLAZA, onUpdatePlaza);

        RoomEvent.EM().AddEvent(RoomEvent.EVENT.UPDATE_LEAVE_ROOM, onPlayerLeave);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.UPDATE_ROOMRULE, onUpdateRoomRule);

        RoomEvent.EM().AddEvent(RoomEvent.EVENT.PLAER_ENTER, onPlayerEnter);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.UPDATE_PLAER_STATE, onPlayerState);
        //RoomEvent.EM ().AddEvent (RoomEvent.EVENT.SHOW_TALK_MSG, onShowTalkMsg);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.UPDATE_LEAVE_ROOM, onPlayerLeave);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.UPDATE_DISSOLVE_ROOM, onDissolve);
    }
Exemplo n.º 13
0
    void OnRespLeaveRoom(Message msg)
    {
        msgRespLeaveRoom resp = msgRespLeaveRoom.deserialize(msg);

        if (resp.type == msgRespLeaveRoom.LEAVE_TYPE.LEAVE_CANT_LEAVE)
        {
            //不能离开,目前是游戏不能离开,此消息在游戏中的时候离开会收到
        }
        else if (resp.type == msgRespLeaveRoom.LEAVE_TYPE.LEAVE_ESCAPE)
        {
            //逃跑,目前不支持
        }
        else if (resp.type == msgRespLeaveRoom.LEAVE_TYPE.LEAVE_KICK)
        {
            //被t了,目前不支持
        }
        else if (resp.type == msgRespLeaveRoom.LEAVE_TYPE.LEAVE_NORMAL)
        {
            //正常离开,切到大厅界面
            if (Room.Room.roomType == CommonDefine.eCreateRoomType.ROOM_PLAZA ||
                Room.Room.roomType == CommonDefine.eCreateRoomType.ROOM_CLASSIC_PLAZA)
            {
                ViewManagerEvent.sShowView s;
                s.fromView = ViewManagerEvent.VIEW_TYPE.GAME_VIEW;
                s.toView   = ViewManagerEvent.VIEW_TYPE.LOBBY_VIEW;
                ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_VIEW, (object)s);
            }
            else
            {
                //此处为离开队伍或者离开房间,对于自己而言,这就是解散同样的处理
                RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_DISSOLVE_ROOM, null);
            }
        }
        else if (resp.type == msgRespLeaveRoom.LEAVE_TYPE.LEAVE_NOT_IN_ROOM)
        {
            //不在房间中,直接切到大厅界面
            ViewManagerEvent.sShowView s;
            s.fromView = ViewManagerEvent.VIEW_TYPE.GAME_VIEW;
            s.toView   = ViewManagerEvent.VIEW_TYPE.LOBBY_VIEW;
            ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_VIEW, (object)s);
        }
        else if (resp.type == msgRespLeaveRoom.LEAVE_TYPE.LEAVE_DISSOLVE)
        {
            // 房间解散
            //切换面板
            RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_DISSOLVE_ROOM, null);
        }

        Room.Room.reset();
    }
Exemplo n.º 14
0
    public void OnClickQuickStartBtn()
    {
        if (!_plazaPanel.activeSelf)
        {
            OnClickShareBtn();
            return;
        }

        //请输入房号

        int currentRoomID = 0;

        int.TryParse(_currentRoomID.text, out currentRoomID);
        if (currentRoomID != 0)
        {
            //已经在房间中
            CommonUtil.Util.showDialog("系统提示", "您已经在房间,无法创建房间");
            return;
        }

        int roomID = 0;

        int.TryParse(_inputRoomID.text, out roomID);
        if (roomID == 0)
        {
            //请输入房号
            CommonUtil.Util.showDialog("温馨提示", "请输入房号");
            return;
        }
        if (_inputRoomID.text.Length != 6)
        {
            // 房间号不正确
            CommonUtil.Util.showDialog("温馨提示", "请输入正确的房号");
            return;
        }

        RoomEvent.sV2C_JoinRoom data;

        data.playerNum = 0;
        data.gridLevel = 0;
        data.plazaID   = 0;
        data.pwd       = "";
        data.roomId    = roomID;
        data.tagId     = -1;
        data.plazaName = "";

        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.JOIN_ROOM, (object)data);
    }
Exemplo n.º 15
0
    public void addRoomGameEvent()
    {
        /// reqJoinRoom->respJoinRoom->playerEnter->reqPlayerAct(非自动准备情况)->respPlayerAct/OnPlayerState->start->leave
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_PLAYER_INFO, OnPlayerEnter);    //玩家进入房间
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_PLAYER_STATE, OnPlayerState);   //玩家准备等
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_PLAYER_TALK_MSG, OnPlayerTalk); //玩家聊天
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_PLAYER_LEAVE, OnPlayerLeave);   //玩家离开房间
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_CLOCK, OnPlayerClock);          //玩家步骤剩余时间
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_TALENT_LIST, OnTalentList);     //收到天赋列表


        RoomEvent.EM().AddEvent(RoomEvent.EVENT.ENTER_ROOM_FINISH, onEnterRoomFinish);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.LEAVE_ROOM, onEventLeaveRoom);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.PLAYER_ACT, onEventPlayerAct);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.TALK_MSG, onEventPlayerTalk);
    }
Exemplo n.º 16
0
    public void removeRoomGameEvent()
    {
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_PLAYER_INFO);     //玩家进入房间
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_PLAYER_STATE);    //玩家准备等
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_PLAYER_TALK_MSG); //玩家聊天
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_PLAYER_LEAVE);    //玩家离开房间
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_CLOCK);           //玩家步骤剩余时间
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_TALENT_LIST);     //收到天赋列表


        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.ENTER_ROOM_FINISH);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.LEAVE_ROOM);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.PLAYER_ACT);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.TALK_MSG);
        //清除数据
        Room.Room.reset();
    }
Exemplo n.º 17
0
    //玩家准备等
    void OnPlayerState(Message msg)
    {
        msgPlayerState resp = msgPlayerState.deserialize(msg);

        if (Room.Room.updatePlayerStateByUserID(resp.userID, (CommonDefine.PLAYER_STATE)resp.state))
        {
            //用户存在,则通知更新用户状态
            //诸如已准备、离线等
            //纯界面数据定义,请定义在roomevent里
            RoomEvent.sC2V_PlayerState ps;
            ps.state      = (CommonDefine.PLAYER_STATE)resp.state;
            ps.local      = Room.Room.getLocalBySeat(resp.seat);
            ps.ifAllReady = Room.Room.getIfAllPlayerReady();

            RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_PLAER_STATE, (object)ps);
        }
    }
Exemplo n.º 18
0
    //玩家进入房间
    void OnPlayerEnter(Message msg)
    {
        msgPlayerInfo resp = msgPlayerInfo.deserialize(msg);

        SelfData self = Account.getSelfData();

        if (resp.userID != self.userID && Room.Room.playerList.Count == 0)
        {
            Debug.Log("第一个进来的玩家不是自己,这会导致座位错误,无法处理,出错!");
            return;
        }

        //将数据写入游戏房间数据
        Room.Player player = new Room.Player();
        player.charm   = resp.charm;
        player.draw    = resp.draw;
        player.escapse = resp.escape;
        player.vip     = resp.vip;
        player.gold    = resp.gold;
        player.head    = resp.headUrl;
        player.lose    = resp.lose;
        player.name    = resp.name;
        player.score   = resp.score;
        player.seat    = resp.seat;
        player.sex     = resp.sex;
        player.state   = CommonDefine.PLAYER_STATE.STATE_TYPE_SITDOWN;      // 默认坐下状态,接下来要准备
        player.userID  = resp.userID;
        player.win     = resp.win;
        player.isOwner = Room.Room.owner == resp.userID;

        player.talentList = new List <eTalentType> ();
        //进来的如果是自己,则初始化天赋列表
        //从自己的数据中获取
        if (resp.userID == self.userID)
        {
            //self
            player.talentList.AddRange(self.talentList);
        }

        //原则上来说,第一个进入的必须是自己,否则不应该处理
        Room.Room.addPlayer(player);

        //显示用户, 此处需要将seat转为local
        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.PLAER_ENTER, player);
    }
Exemplo n.º 19
0
    public void removeRoomLobbyEvent()
    {
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_ROOMSTATE_CHANGE);  //房间状态变化
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_PLAYER_INFO);       //玩家进入房间
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_PLAYER_STATE);      //玩家准备等
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_PLAYER_LEAVE);      //玩家离开房间
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_START_GAME);        //收到游戏开始通知
        ProtocolManager.getInstance().removePushMsgEventListener(GameProtocol.P_GAME_TALENT_LIST);       //收到天赋列表

        //
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.CREATE_ROOM);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.JOIN_ROOM);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.GET_ROOM_LIST);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.LEAVE_ROOM);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.PLAYER_ACT);
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.SHOW_ROOM_LIST);        //界面自己请求房间列表数据,即该界面显示的时候invoke
        RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.START_GAME);
    }
Exemplo n.º 20
0
    public void addRoomLobbyEvent()
    {
        //注册网络消息
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_ROOMSTATE_CHANGE, OnRoomStateChange); //房间状态变化
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_PLAYER_INFO, OnPlayerEnter);          //玩家进入房间
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_PLAYER_STATE, OnPlayerState);         //玩家准备等
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_PLAYER_LEAVE, OnPlayerLeave);         //玩家离开房间
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_START_GAME, OnGameStart);             //收到游戏开始通知
        ProtocolManager.getInstance().addPushMsgEventListener(GameProtocol.P_GAME_TALENT_LIST, OnTalentList);           //收到天赋列表

        //注册界面消息
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.CREATE_ROOM, onEventCreateRoom);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.JOIN_ROOM, onEventJoinRoom);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.GET_ROOM_LIST, onEventGetRoomList);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.LEAVE_ROOM, onEventLeaveRoom);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.PLAYER_ACT, onEventPlayerAct);
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.SHOW_ROOM_LIST, onEventShowRoomList);       //界面自己请求房间列表数据,即该界面显示的时候invoke
        RoomEvent.EM().AddEvent(RoomEvent.EVENT.START_GAME, onEventStartGame);
    }
Exemplo n.º 21
0
    void OnRoomStateChange(Message msg)
    {
        msgRoomStateChange resp = msgRoomStateChange.deserialize(msg);

        Room.RoomData rd;
        rd.roomId        = resp.roomId;
        rd.roomDes       = "";
        rd.isFull        = 0;
        rd.roomName      = "";
        rd.roomPersonCnt = 0;
        rd.rule          = "";
        rd.roomPwd       = "";

        if (resp.type == msgRoomStateChange.ROOMSTATE_CHANGE_TYPE.ROOMSTATE_ADD)
        {
            rd.isFull        = 0;
            rd.roomName      = resp.roomName;
            rd.roomPersonCnt = 0;
            rd.rule          = resp.rule;
            rd.roomPwd       = resp.roomPassword;
            rd.roomDes       = "add";

            Room.Room.addRoomListByRoomID(resp.roomId, rd);
        }
        else if (resp.type == msgRoomStateChange.ROOMSTATE_CHANGE_TYPE.ROOMSTATE_REMOVE)
        {
            Room.Room.removeRoomListByRoomID(resp.roomId);
            rd.roomDes = "remove";
            Room.Room.addRoomListByRoomID(resp.roomId, rd);
        }
        else if (resp.type == msgRoomStateChange.ROOMSTATE_CHANGE_TYPE.ROOMSTATE_UPDATE)
        {
            rd.roomDes       = "update";
            rd.roomPersonCnt = resp.personCnt;

            Room.Room.updateRoomListByRoomID(resp.roomId, resp.personCnt);
        }

        //  这里借用以下房间描述暂时
        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_ROOM_STATE, (object)rd);
    }
Exemplo n.º 22
0
 void removeAllEvent()
 {
     RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.UPDATE_ROOMRULE);
     RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.PLAER_ENTER);
     RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.UPDATE_PLAER_STATE);
     RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.SHOW_TALK_MSG);
     RoomEvent.EM().RemoveEvent(RoomEvent.EVENT.UPDATE_LEAVE_ROOM);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_GAME_START);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_DRAW);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_DRAW_RESULT);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_TURN);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_ABANDON);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_PASS);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_ABANDON_PASS);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_PLAY);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_MOVE);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_RESULT);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_FLAG);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.SHOW_LIANQI);
     GameEvent.EM().RemoveEvent(GameEvent.EVENT.TO_GAMEVEIW_UPDATE_SCORE);
 }
Exemplo n.º 23
0
 //----------------------------------------------------------------
 void addAllEvent()
 {
     RoomEvent.EM().AddEvent(RoomEvent.EVENT.UPDATE_ROOMRULE, onUpdateRoomRule);
     RoomEvent.EM().AddEvent(RoomEvent.EVENT.PLAER_ENTER, onPlayerEnter);
     RoomEvent.EM().AddEvent(RoomEvent.EVENT.UPDATE_PLAER_STATE, onPlayerState);
     RoomEvent.EM().AddEvent(RoomEvent.EVENT.SHOW_TALK_MSG, onShowTalkMsg);
     RoomEvent.EM().AddEvent(RoomEvent.EVENT.UPDATE_LEAVE_ROOM, onPlayerLeave);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_GAME_START, onShowGameStart);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_DRAW, onReqDraw);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_DRAW_RESULT, onRespDraw);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_TURN, onShowTurn);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_ABANDON, onShowAbandon);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_PASS, onShowPass);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_ABANDON_PASS, onShowAbandonPass);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_PLAY, onShowPlay);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_MOVE, onShowMove);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_RESULT, onShowResult);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_FLAG, onShowFlag);
     GameEvent.EM().AddEvent(GameEvent.EVENT.SHOW_LIANQI, onShowLianQi);
     GameEvent.EM().AddEvent(GameEvent.EVENT.TO_GAMEVEIW_UPDATE_SCORE, onUpdateScore);
 }
Exemplo n.º 24
0
    public void onClickJoinRoom(int playerNum, int gridLevel, int plazaID, string name, int tag)
    {
        if (playerNum == 0)
        {
            //提示请选择人数和阶数

            return;
        }

        RoomEvent.sV2C_JoinRoom data;

        data.playerNum = playerNum;
        data.gridLevel = gridLevel;
        data.plazaID   = plazaID;
        data.pwd       = "";
        data.roomId    = 0;
        data.plazaName = name;
        data.tagId     = tag;

        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.JOIN_ROOM, (object)data);
    }
Exemplo n.º 25
0
    void onEventLeaveRoom(object data)
    {
        bool mustLeave = (bool)data;

        if (mustLeave)
        {
            Room.Room.reset();

            ViewManagerEvent.sShowView s;
            s.fromView = ViewManagerEvent.VIEW_TYPE.GAME_VIEW;
            s.toView   = ViewManagerEvent.VIEW_TYPE.LOBBY_VIEW;
            ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_VIEW, (object)s);

            RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_DISSOLVE_ROOM, null);
        }
        else
        {
            msgReqLeaveRoom lr = new msgReqLeaveRoom();
            lr.game = GameType.GAME_LIANQI;
            ProtocolManager.getInstance().sendMsg(GameProtocol.P_GAME_REQ_LEAVEROOM, lr, OnRespLeaveRoom);
        }
    }
Exemplo n.º 26
0
    //玩家离开房间
    void OnPlayerLeave(Message msg)
    {
        //自己离开收到的是另外一个消息:msgRespLeaveRoom,如果是非请求离开,则会收到这个,需要根据id判断是否是自己。
        //目前不支持t人,所以自己一般不会收到这个消息
        msgPlayerLeave resp = msgPlayerLeave.deserialize(msg);

        SelfData self = Account.getSelfData();

        if (resp.userID == self.userID)
        {
            if (resp.type == msgPlayerLeave.PLAYER_LEAVE_ROOM_TYPE.LEAVE_ROOM_GAMEEND)
            {
                //此时清空房间缓存数据
                Room.Room.reset();
            }
            else if (resp.type == msgPlayerLeave.PLAYER_LEAVE_ROOM_TYPE.LEAVE_ROOM_REMOVED)
            {
            }
        }
        else
        {
            if (msgPlayerLeave.PLAYER_LEAVE_ROOM_TYPE.LEAVE_ROOM_OWNER_DISSOLVE == resp.type)
            {
                //解散房间 相当于自己退出
                ////切换面板
                RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_DISSOLVE_ROOM, null);
                Room.Room.reset();
            }
            else
            {
                //别人退出
                if (Room.Room.removePlayerBySeat(resp.seat))
                {
                    RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_LEAVE_ROOM, (object)(Room.Room.getLocalBySeat(resp.seat)));
                }
            }
        }
    }
Exemplo n.º 27
0
    public void OnClickCreateRoomBtn()
    {
        RoomEvent.sV2C_CreateRoom data;
        data.roomName     = "";    //设置成自己的昵称
        data.roomPassword = "";    //不设置密码

        JsonObject rule = new JsonObject();

        rule.Add("playerNum", _currentPlayerNum);
        rule.Add("gridLevel", _currentGridLevel);
        rule.Add("rule", "default");
        rule.Add("gameTime", 0);
        rule.Add("lmtRound", _currentLmtRound);
        rule.Add("lmtTurnTime", _currentLmtTurnTime);

        //rule.Add ("levelID",(int)_currentPlazaLevel);
        data.roomType  = CommonDefine.eCreateRoomType.ROOM_ROOM;
        data.rule      = rule.ToString();
        data.minScore  = _baseScoreList[(int)_currentPlazaLevel - 1];
        data.maxScore  = 0;       //没有最大限制
        data.baseScore = _baseScoreList[(int)_currentPlazaLevel - 1];

        RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.CREATE_ROOM, data);
    }
Exemplo n.º 28
0
    void OnRespJoinRoom(Message msg)
    {
        ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_LOADING_ANI, false);

        msgRespJoinRoom resp = msgRespJoinRoom.deserialize(msg);
        //此处需要根据各种响应值,来给出友好提示
        string tip = "加入房间失败";

        //RESP_JOINROOM_FLAG
        if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_SUCCESS ||
            resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINGROOM_ALREADY_IN_ROOM)
        {
            //规则应该一定不会为空的
            if (resp.rule == null || resp.rule.Length == 0)
            {
                //
                return;
            }

            if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINGROOM_ALREADY_IN_ROOM)
            {
                //原则上此处可以直接进入房间,也可以是弹窗提示用户是否重新进入房间
                //
            }

            // 设置相关数据
            Room.Room.setRoomData(resp.roomId, resp.levelId, resp.plazaid, resp.roomType, resp.owner, resp.rule, resp.baseScore);
            Room.Room.isRelink = resp.isRelink;

            //这里需要判断是哪种类型的房间
            if (Room.Room.roomType == CommonDefine.eCreateRoomType.ROOM_ROOM)
            {
                msgNotifyEnterRoomFinish efmsg = new msgNotifyEnterRoomFinish();
                efmsg.isRelink = Room.Room.isRelink;
                ProtocolManager.getInstance().sendMsg(GameProtocol.P_GAME_ENTER_ROOM_FINISH, efmsg);


                if (!Room.Room.isRelink)
                {
                    //刷新房间规则显示
                    RoomEvent.sC2V_RoomRule rr;
                    rr.playerNum   = Room.Room.roomRule.playerNum;
                    rr.gameTime    = Room.Room.roomRule.gameTime;
                    rr.gridLevel   = Room.Room.roomRule.gridLevel;
                    rr.rule        = Room.Room.roomRule.rule;
                    rr.lmtRound    = Room.Room.roomRule.lmtRound;
                    rr.lmtTurnTime = Room.Room.roomRule.lmtTurnTime;
                    rr.roomLevel   = resp.levelId;
                    rr.roomID      = resp.roomId;
                    rr.plazaName   = Room.Room.plazaName;

                    if (Room.Room.plazaid != 0)
                    {
                        LobbyEvent.Plaza plaza = getPlazaById(Room.Room.plazaid);
                        rr.star = plaza.star;
                    }
                    else
                    {
                        rr.star = 0;
                    }

                    rr.tag  = Room.Room.tagId;
                    rr.type = Room.Room.roomType;

                    RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.UPDATE_ROOMRULE, (object)rr);
                }
                else
                {
                    //////
                    ViewManagerEvent.sShowView data;
                    data.fromView = ViewManagerEvent.VIEW_TYPE.LOBBY_VIEW;
                    data.toView   = ViewManagerEvent.VIEW_TYPE.GAME_VIEW;
                    ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_VIEW, (object)data);
                }
            }
            else if (Room.Room.roomType == CommonDefine.eCreateRoomType.ROOM_TEAM)
            {
            }
            else
            {
                //另外需要显示房间规则相关的信息在房间某个位置
                //进入房间成功,切换到游戏场景,这里应为主动操作,不需要事件通知请访问GameController来切换
                //或者这里直接切换也行
                //也可以事件通知,为了统一起见
                ViewManagerEvent.sShowView data;
                data.fromView = ViewManagerEvent.VIEW_TYPE.LOBBY_VIEW;
                data.toView   = ViewManagerEvent.VIEW_TYPE.GAME_VIEW;
                ViewManagerEvent.EM().InvokeEvent(ViewManagerEvent.EVENT.SHOW_VIEW, (object)data);
            }

            //结束处理
            return;
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINGROOM_FAIL_ROOM_NOT_EXIST)
        {
            tip = "房间不存在,请重试";
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_ACCOUNT_ERR)
        {
            tip = "加入失败,用户异常";
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_FAIL_NO_FREE_ROOM)
        {
            tip = "加入失败,没有可用的房间";
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_FIAL_SYSERR)
        {
            tip = "加入失败,系统错误";
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_GOLD_LESS)
        {
            tip = "加入失败,您的积分不足,请充值";
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_GOLD_MORE)
        {
            tip = "加入失败,您太有钱了,请到其他模式游戏";
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_LEVEL_LESS)
        {
            tip = "加入失败,您的级别太高了";
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_LEVEL_MORE)
        {
            tip = "加入失败,您的级别太低了";
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_PLAZA_ERR)
        {
            tip = "加入失败,参数错误";
        }
        else if (resp.flag == msgRespJoinRoom.RESP_JOINROOM_FLAG.JOINROOM_PWD_ERR)
        {
            tip = "加入失败,密码错误";
        }

        CommonUtil.Util.showDialog("系统提示", tip);
    }
Exemplo n.º 29
0
 public void OnClickStart()
 {
     //
     _startBtn.interactable = false;
     RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.START_GAME, false);
 }
Exemplo n.º 30
0
 public void onEventShowRoomList(object data)
 {
     RoomEvent.EM().InvokeEvent(RoomEvent.EVENT.SHOW_ROOM_LIST, (object)(Room.Room.roomList));
 }