コード例 #1
0
    /// <summary>
    /// 点击开始游戏按钮事件处理
    /// </summary>
    private void OnBtnBeginGameClickEventHanlder()
    {
        //创建角色界面
        if (m_bIsCreateRole)
        {
            RoleOperation_CreateRoleProto proto = new RoleOperation_CreateRoleProto();

            proto.JobId        = (byte)m_currentJobId;
            proto.RoleNickName = m_uiSceneSelectRoleView.RoleNameInputField.text;

            //角色昵称合法性检查
            if (string.IsNullOrEmpty(proto.RoleNickName))
            {
                UIMessageCtr.Instance.Show("提示", "请输入你的昵称");
                return;
            }

            //把创建的角色信息发送到服务端
            NetWorkSocket.Instance.SendMsg(proto.ToArray());
        }
        //选人界面
        else
        {
            //开始已有角色逻辑
            RoleOperation_EnterGameProto proto = new RoleOperation_EnterGameProto();
            proto.RoleId = this.m_currentRoleId;

            //把角色编号发送给服务器
            NetWorkSocket.Instance.SendMsg(proto.ToArray());
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            GameEntry.Socket.ConnerToMainSocket("127.0.0.1", 2038);
        }
        if (Input.GetKeyDown(KeyCode.C))
        {
            //for (int i = 0; i < 100; i++)
            //{
            //这里是有问题的----------------
            //System_HeartbeatProto proto = new System_HeartbeatProto();

            //GameEntry.Socket.SendMsg(proto.ToArray());
            //RoleOperation_LogOnGameServerProto proto = new RoleOperation_LogOnGameServerProto();
            //proto.AccountId = 222;
            //GameEntry.Socket.SendMsg(proto.ToArray());
            //GameEntry.Socket.SendMainMsg(proto);
            //}
            //RoleOperation_LogOnGameServerProto proto = new RoleOperation_LogOnGameServerProto();
            //proto.AccountId = 1;
            //GameEntry.Socket.SendMainMsg(proto);

            RoleOperation_CreateRoleProto roleOperation_CreateRoleProto = new RoleOperation_CreateRoleProto();
            roleOperation_CreateRoleProto.JobId        = 1;
            roleOperation_CreateRoleProto.RoleNickName = "ddd";
            GameEntry.Socket.SendMsg(roleOperation_CreateRoleProto.ToArray());
        }
    }
コード例 #3
0
    /// <summary>
    /// 点击进入游戏按钮
    /// </summary>
    private void OnClickEnterGameButton()
    {
        //创建角色界面点击进入游戏
        if (isCreateRole)
        {
            if (string.IsNullOrEmpty(selectRoleView.NickNameInput.text))
            {
                MessageCtrl.Instance.Show("创建角色提示", "昵称不能为空");
                return;
            }

            RoleOperation_CreateRoleProto proto = new RoleOperation_CreateRoleProto();
            proto.JobID    = m_JobList[selectIndex].Id;
            proto.NickName = selectRoleView.NickNameInput.text;
            NetWorkSocket.Instance.SendMsg(proto.ToArray());
        }
        //选择界面点击进入游戏
        else
        {
            RoleOperation_EnterGameProto proto = new RoleOperation_EnterGameProto();
            proto.RoleID = CurrentRoleID;
            NetWorkSocket.Instance.SendMsg(proto.ToArray());
        }
    }