/// <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
    public static RoleOperation_CreateRoleProto GetProto(byte[] buffer, bool isChild = false)
    {
        RoleOperation_CreateRoleProto proto = new RoleOperation_CreateRoleProto();

        MMO_MemoryStream ms = null;

        if (!isChild)
        {
            ms = GameEntry.Socket.SocketSendMS;
        }
        else
        {
            ms = GameEntry.Pool.DequeueClassObject <MMO_MemoryStream>();
        }
        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.JobId        = (byte)ms.ReadByte();
        proto.RoleNickName = ms.ReadUTF8String();

        if (isChild)
        {
            GameEntry.Pool.EnqueueClassObject(ms);
        }
        return(proto);
    }
Пример #4
0
    public static void OnRoleOperation_CreateRole(byte[] buffer)
    {
        RoleOperation_CreateRoleProto proto = RoleOperation_CreateRoleProto.GetProto(buffer);

#if DEBUG_LOG_PROTO
        Debug.Log("<color=#00eaff>接收消息:</color><color=#00ff9c>" + proto.ProtoEnName + " " + proto.ProtoCode + "</color>");
        Debug.Log("<color=#c5e1dc>==>>" + JsonUtility.ToJson(proto) + "</color>");
#endif
    }
 public static RoleOperation_CreateRoleProto ToProto(byte[] buffer)
 {
     using (MMO_MemoryStream ms = new MMO_MemoryStream(buffer))
     {
         RoleOperation_CreateRoleProto proto = new RoleOperation_CreateRoleProto();
         proto.JobID    = ms.ReadInt();
         proto.NickName = ms.ReadUTF8String();
         return(proto);
     }
 }
Пример #6
0
    public static RoleOperation_CreateRoleProto GetProto(byte[] buffer)
    {
        RoleOperation_CreateRoleProto proto = new RoleOperation_CreateRoleProto();

        using (MMO_MemoryStream ms = new MMO_MemoryStream(buffer))
        {
            proto.JobId        = (byte)ms.ReadByte();
            proto.RoleNickName = ms.ReadUTF8String();
        }
        return(proto);
    }
    public static RoleOperation_CreateRoleProto GetProto(MMO_MemoryStream ms, byte[] buffer)
    {
        RoleOperation_CreateRoleProto proto = new RoleOperation_CreateRoleProto();

        ms.SetLength(0);
        ms.Write(buffer, 0, buffer.Length);
        ms.Position = 0;

        proto.JobId        = (byte)ms.ReadByte();
        proto.RoleNickName = ms.ReadUTF8String();

        return(proto);
    }
Пример #8
0
        private void CreateRoleProtoCallBack(Role role, byte[] content)
        {
            RoleOperation_CreateRoleProto proto = RoleOperation_CreateRoleProto.ToProto(content);

            //查询是否又相同昵称的
            int count = RoleCacheModel.Instance.GetCount(string.Format("[NickName] = '{0}'", proto.NickName));
            MFReturnValue <object> ret = null;

            if (count == 0)
            {
                //创建
                RoleEntity entity = new RoleEntity();
                entity.JobId               = proto.JobID;
                entity.NickName            = proto.NickName;
                entity.Sex                 = (byte)EnumSex.Female;
                entity.Status              = EnumEntityStatus.Released;
                entity.Level               = 1;
                entity.AccountId           = role.AccountId;
                entity.CreateTime          = DateTime.Now;
                entity.UpdateTime          = DateTime.Now;
                entity.LastWorldMapSceneId = 1;
                //暂定
                JobEntity      jobEntity      = JobDBModel.Instance.Get(proto.JobID);
                JobLevelEntity jobLevelEntity = JobLevelDBModel.Instance.Get(entity.Level);
                entity.MaxHP     = jobLevelEntity.HP;
                entity.CurrentHP = entity.MaxHP;
                entity.MaxMP     = jobLevelEntity.MP;
                entity.CurrentMP = entity.MaxMP;
                entity.Attack    = (int)Math.Round(jobEntity.Attack * jobLevelEntity.Attack * 0.01f);
                entity.Defense   = (int)Math.Round(jobEntity.Defense * jobLevelEntity.Defense * 0.01f);
                entity.Hit       = (int)Math.Round(jobEntity.Hit * jobLevelEntity.Hit * 0.01f);
                entity.Dodge     = (int)Math.Round(jobEntity.Dodge * jobLevelEntity.Dodge * 0.01f);
                entity.Cri       = (int)Math.Round(jobEntity.Cri * jobLevelEntity.Cri * 0.01f);
                entity.Res       = (int)Math.Round(jobEntity.Res * jobLevelEntity.Res * 0.01f);
                entity.Gold      = 0;
                entity.Money     = 0;
                entity.Exp       = 0;
                entity.Fighting  = entity.Attack * 4 + entity.Defense * 4 + entity.Hit * 2 + entity.Dodge * 2 + entity.Res + entity.Cri;
                ret            = RoleCacheModel.Instance.Create(entity);
                role.CurRoleId = (int)ret.OutputValues["Id"];
            }
            else
            {
                ret            = new MFReturnValue <object>();
                ret.HasError   = true;
                ret.ReturnCode = 1000;
            }
            SelectRoleInfoReturn(role);
            CreateRoleProtoReturn(ret, role);
            SelectSkillReturn(role);
        }
Пример #9
0
        /// <summary>
        /// 创建角色按钮点击
        /// </summary>
        public void CreateRoleButtonClick()
        {
            if (string.IsNullOrEmpty(m_TxtNickName.text))
            {
                GameEntry.UI.OpenDialog(new DialogParams()
                {
                    Mode    = 1,
                    Title   = "提示",
                    Message = "请输入您的昵称",
                });
                return;
            }

            RoleOperation_CreateRoleProto proto = new RoleOperation_CreateRoleProto();

            proto.JobId        = (byte)m_CurrSelectJobId;
            proto.RoleNickName = m_TxtNickName.text;

            GameEntry.Socket.SendProtoMessage(proto);
        }
    /// <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());
        }
    }