Exemplo n.º 1
0
    /// <summary>
    /// 点击离开房间后处理服务器返回的消息
    /// </summary>
    /// <param name="msg">服务器返回的离开房间消息</param>
    private void LeaveRoomHandle(object msg)
    {
        var leaveRoomMsg = msg as mmopb.leaveRoom_ack;

        if (leaveRoomMsg.isSuc)
        {
            //打开房间列表
            roomsView.rooms.SetActive(true);
            //关闭进入的房间
            roomView.room_boot.SetActive(false);

            //删除原来有的列表
            GameObject[] rooms = GameObject.FindGameObjectsWithTag("ROOM");
            foreach (GameObject room in rooms)
            {
                Destroy(room);
            }
            //删除聊天消息
            GameObject[] messages = GameObject.FindGameObjectsWithTag("ROOMMSG");
            foreach (GameObject message in messages)
            {
                Destroy(message);
            }
            //请求房间列表数据
            var rooms_req = new mmopb.roomList_req();
            ClientNet.Instance.Send(ProtoHelper.EncodeWithName(rooms_req));
        }
        else
        {
            Debug.Log(leaveRoomMsg.error);
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 在房间列表界面点击刷新列表按钮刷新房间列表数据
    /// </summary>
    /// <param name="param"></param>
    private void OnClickBtnRefresh(object param)
    {
        button.clip = common;
        button.Play();
        //删除原来有的列表
        GameObject[] rooms = GameObject.FindGameObjectsWithTag("ROOM");
        foreach (GameObject room in rooms)
        {
            Destroy(room);
        }
        var rooms_req = new mmopb.roomList_req();

        ClientNet.Instance.Send(ProtoHelper.EncodeWithName(rooms_req));
    }
Exemplo n.º 3
0
    // Use this for initialization
    public void Start()
    {
        //邀请显示
        if (InviteInfo.Instance.IsAgreeInvite)
        {
            roomsView.rooms.SetActive(false);
            roomView.room_boot.SetActive(true);
            //清空信息
            PlayersInfo playersInfo = roomView.room.GetComponent <PlayersInfo>();
            playersInfo.name_Yang.text = "";
            playersInfo.camp_Yang.text = "";
            playersInfo.name_Yin.text  = "";
            playersInfo.camp_Yin.text  = "";
            Dictionary <Int32, mmopb.p_roleInfoInRoom> playerList = InviteInfo.Instance.PlayerList;
            foreach (KeyValuePair <Int32, mmopb.p_roleInfoInRoom> player in playerList)
            {
                if (player.Value.camp == 1)
                {
                    playersInfo.name_Yang.text = player.Value.nickName;
                    playersInfo.camp_Yang.text = "阳";
                }
                else
                {
                    playersInfo.name_Yin.text = player.Value.nickName;
                    playersInfo.camp_Yin.text = "阴";
                }
            }
            LocalUser.Instance.Camp           = playerList[LocalUser.Instance.PlayerId].camp;
            InviteInfo.Instance.IsAgreeInvite = false;
        }

        //进入时请求房间列表数据
        var rooms_req = new mmopb.roomList_req();

        ClientNet.Instance.Send(ProtoHelper.EncodeWithName(rooms_req));

        //音量设置
        GameObject  canvas      = GameObject.Find("Canvas");
        AudioSource audioSource = canvas.GetComponent <AudioSource>();

        audioSource.volume = LocalUser.Instance.Voice;
        audioSource.mute   = LocalUser.Instance.IsMute;

        //事件
        UIDispacher.Instance.AddEventListener("Return", OnClickBtnReturn);
        UIDispacher.Instance.AddEventListener("Refresh", OnClickBtnRefresh);
        UIDispacher.Instance.AddEventListener("CreateRoom", OnClickBtnCreateRoom);
        UIDispacher.Instance.AddEventListener("Join", OnClickBtnJoin);
        UIDispacher.Instance.AddEventListener("StartGame", OnClickBtnStartGame);
        UIDispacher.Instance.AddEventListener("QuitRoom", OnClickBtnQuitRoom);
        UIDispacher.Instance.AddEventListener("InviteFriend", OnClickBtnInviteFriend);
        UIDispacher.Instance.AddEventListener("SendMessage", OnClickBtnSendMessage);
        UIDispacher.Instance.AddEventListener("CloseInviteFriends", OnClickBtnCloseInviteFriends);
        UIDispacher.Instance.AddEventListener("ClickInviteTargetFriend", ClickInviteTargetFriend);
        UIDispacher.Instance.AddEventListener("ClickYesNewInvite", ClickYesNewInvite);
        UIDispacher.Instance.AddEventListener("ClickNoNewInvite", ClickNoNewInvite);

        NetDispacher.Instance.AddEventListener("roomList_ack", LoadRoomsHandle);
        NetDispacher.Instance.AddEventListener("createRoom_ack", CreateRoomHandle);
        NetDispacher.Instance.AddEventListener("enterRoom_ack", EnterRoomHandle);
        NetDispacher.Instance.AddEventListener("roleInfoInRoom_bcst", RoleInfoInRoomHandle);
        NetDispacher.Instance.AddEventListener("startBattle_bcst", StartBattle_bcstHandle);
        NetDispacher.Instance.AddEventListener("leaveRoom_ack", LeaveRoomHandle);
        NetDispacher.Instance.AddEventListener("sendMessage_bcst", RevChatMsgHandle);
        NetDispacher.Instance.AddEventListener("friendsList_ack", FriendsListHandle);
        NetDispacher.Instance.AddEventListener("noticeInviteFriend_ecn", RevInviteMsgHandle);
        NetDispacher.Instance.AddEventListener("inviteResult_ack", RevInviteResultHandle);
    }