Ejemplo n.º 1
0
        void btnOK_Clicked(object sender, GUIEventArgs e)
        {
            // 发送创建角色消息
            C2S_CharCreate msg;

            msg.messageId = C2S_CharCreate.Id;
            GameFrameManager.SendNetMessage <C2S_CharCreate>(msg);
        }
Ejemplo n.º 2
0
        public void OnReplicateMove()
        {
            NCharacterController controller = OwnerController;

            if (controller != null)
            {
                // 发送移动消息
                C2S_Move msg;
                msg.messageId    = C2S_Move.Id;
                msg.Position     = controller.Location;
                msg.Acceleration = controller.Acceleration;
                msg.Yaw          = controller.Rotation.y;
                msg.Flag         = NSavedMove.ControllerToFlags(controller);
                msg.TimeStamp    = NativeEngineHelper.GetTimeSeconds();
                GameFrameManager.SendNetMessage <C2S_Move>(msg);
            }
        }
Ejemplo n.º 3
0
        void btnOK_Clicked(object sender, GUIEventArgs e)
        {
            // 发送登录消息
            // Create a point struct.
            C2S_LoginProof loginMsg;

            loginMsg.messageId  = C2S_LoginProof.Id;
            loginMsg.CurVersion = 0;
            loginMsg.AccountID  = NativeEngineHelper.CheckCRC(uiID.Text.ToString().Trim());
            string password = uiPassword.Text.ToString().Trim();

            loginMsg.Password = password;
            loginMsg.IP       = 0;
            loginMsg.Mac      = String.Empty;
            GameFrameManager.SendNetMessage <C2S_LoginProof>(loginMsg);

            btnOK.Disable();
        }
        public void ClientUseSkill(UInt32 spellId)
        {
            NCamera      camera   = Program.game.GameWindow.ViewportControl.Viewport.Camera;
            Ray          mouseRay = camera.GetMouseRay(PlayerInput.MouseValueX, PlayerInput.MouseValueY);
            NCheckResult hit      = new NCheckResult();

            if (GameEngine.EngineInstance.CurrentLevel.LineCheck(out hit, mouseRay.Position, mouseRay.Position + mouseRay.Direction * camera.ZFar, LineCheckType.World))
            {
                C2S_CastSpell msg;
                msg.MessageId = C2S_CastSpell.Id;
                msg.SpellID   = spellId;
                msg.TargetId  = 0;
                msg.TargetPos = hit.location;
                msg.TimeStamp = NativeEngineHelper.GetTimeSeconds();
                msg.CastCount = 1;
                GameFrameManager.SendNetMessage <C2S_CastSpell>(msg);
            }
        }
Ejemplo n.º 5
0
        void btnEnterGame_Clicked(object sender, GUIEventArgs e)
        {
            // 发送进入游戏消息
            C2S_CharEnterGame enterGameReq;

            enterGameReq.messageId = C2S_CharEnterGame.Id;
            enterGameReq.PlayerId  = 125;
            GameFrameManager.SendNetMessage <C2S_CharEnterGame>(enterGameReq);

            // 请求服务器事件
            C2S_CheckTime checkTimeReq;

            checkTimeReq.MessageId       = C2S_CheckTime.Id;
            checkTimeReq.ClientTimeStamp = NativeEngineHelper.GetTimeSeconds();
            GameFrameManager.SendNetMessage <C2S_CheckTime>(checkTimeReq);

            btnEnterGame.Disable();
        }
Ejemplo n.º 6
0
        public bool LoadFrame()
        {
            // 发送请求角色列表消息
            C2S_CharEnum msg;

            msg.messageId = C2S_CharEnum.Id;
            GameFrameManager.SendNetMessage <C2S_CharEnum>(msg);

            GameHelper.LoadUIForm(GUISystem.Instance.RootWindow, "content", "/ui/form/SelectRoleForm.nui");

            UIButton btnCreateRole = GUISystem.Instance.RootWindow.FindChild("CreateRole", true) as UIButton;

            btnEnterGame = GUISystem.Instance.RootWindow.FindChild("EnterGame", true) as UIButton;
            UIButton btnExitGame = GUISystem.Instance.RootWindow.FindChild("ExitGame", true) as UIButton;

            btnEnterGame.Disable();
            btnCreateRole.Clicked += new EventHandler <GUIEventArgs>(btnCreateRole_Clicked);
            btnEnterGame.Clicked  += new EventHandler <GUIEventArgs>(btnEnterGame_Clicked);
            btnExitGame.Clicked   += new EventHandler <GUIEventArgs>(btnExitGame_Clicked);

            return(true);
        }
        public void OnReplicateMove()
        {
            LocalPlayerController controller = OwnerController;

            if (controller != null &&
                GameFrameManager.Instance.CurrentFrameType == GameFrameType.Gaming)
            {
                // 发送移动消息
                C2S_Move msg;
                msg.messageId    = C2S_Move.Id;
                msg.Position     = controller.Location;
                msg.Acceleration = controller.Acceleration;
                msg.Yaw          = Vector3.CalcYaw(controller.Acceleration);
                msg.Flag         = NSavedMove.ControllerToFlags(controller, controller.PressJump ? (Byte)MovementFlag.PressJump : Byte.MinValue);
                msg.TimeStamp    = NativeEngineHelper.GetTimeSeconds();
                GameFrameManager.SendNetMessage <C2S_Move>(msg);

                // 保存到消息队列以便验证
                controller.NetMovementMessages.Add(msg);

                //Debug.WriteLine("Send C2S_Move " + " Position:" + msg.Position + " Acceleration:" + msg.Acceleration + " Flag:" + msg.Flag);
            }
        }
Ejemplo n.º 8
0
        public void NotifyNetMessageReceived(MessageReceivedEvent e)
        {
            if (e.messageId == (UInt16)NetCharacter.SC_CharError)
            {
                // todo: 显示错误消息
                e.Handled = true;
            }
            else if (e.messageId == (UInt16)NetCharacter.SC_CharEnum)
            {
                S2C_CharEnum ret = MarshalConversion.PtrToStruct <S2C_CharEnum>(e.MessagePtr);

                btnEnterGame.Enable();

                e.Handled = true;
            }
            else if (e.messageId == (UInt16)NetCharacter.SC_CharEnterGame)
            {
                // 向服务器请求获取玩家的初始属性数据
                C2S_GetInitStat initStatReq;
                initStatReq.MessageId = C2S_GetInitStat.Id;
                GameFrameManager.SendNetMessage <C2S_GetInitStat>(initStatReq);

                S2C_CharEnterGame ret = MarshalConversion.PtrToStruct <S2C_CharEnterGame>(e.MessagePtr);
                GameEngine.EngineInstance.LocalPlayer.CharacterID = ret.PlayerId;
                GameEngine.EngineInstance.LocalPlayer.Transport(GameEngine.EngineInstance.GameLevel, ret.Position, true);
                GameEngine.EngineInstance.LocalPlayer.Rotation = new Vector3(0.0f, ret.Yaw, 0.0f);

                e.Handled = true;
            }
            else if (e.messageId == (UInt16)NetLoading.SC_GetInitStat)
            {
                GameEngine.EngineInstance.LocalPlayer.StatData.OnRecvInitStat(new IntPtr(e.MessagePtr.ToInt32() + 2));

                // 注意发送和接受顺序
                C2S_GetInitSpell initSpellReq;
                initSpellReq.MessageId = C2S_GetInitSpell.Id;
                GameFrameManager.SendNetMessage <C2S_GetInitSpell>(initSpellReq);
            }
            else if (e.messageId == (UInt16)NetLoading.SC_GetInitSpell)
            {
                // 初始化技能
                OnRecvInitSpell(e);

                C2S_GetInitAura initAuraReq;
                initAuraReq.MessageId = C2S_GetInitAura.Id;
                GameFrameManager.SendNetMessage <C2S_GetInitAura>(initAuraReq);
            }
            else if (e.messageId == (UInt16)NetLoading.SC_GetInitAura)
            {
                // 初始化BUFF
                OnRecvInitAura(e);

                // todo: 发送进入地图消息
                C2S_MapEnter enterMapReq;
                enterMapReq.messageId = C2S_MapEnter.Id;
                GameFrameManager.SendNetMessage <C2S_MapEnter>(enterMapReq);
            }
            else if (e.messageId == (UInt16)NetMap.SC_MapEnter)
            {
                GameFrameManager.Instance.CurrentFrameType = GameFrameType.Gaming;

                e.Handled = true;
            }
        }