Esempio n. 1
0
        /// <summary>
        /// Client - send the server my current player state.
        /// </summary>
        private void SendServerMyAvatarState()
        {
            if (Context.GameClient.Engine.Me == null)
            {
                return;
            }

            if (!Engine.Me.GetProperty(EntityPropertyEnum.Position).IsDirty&&
                !Engine.Me.GetProperty(EntityPropertyEnum.Rotation).IsDirty)
            {
                return;
            }

            var message = new ClientMoveMessage
            {
                Position       = Engine.Me.GetPosition(),
                Rotation       = Engine.Me.GetRotation(),
                MovementVector = Engine.Me.GetMovementVector()
            };

            Engine.Me.GetProperty(EntityPropertyEnum.Position).ClearDirtyFlag();
            Engine.Me.GetProperty(EntityPropertyEnum.Rotation).ClearDirtyFlag();
            Engine.Me.GetProperty(EntityPropertyEnum.MovementVector).ClearDirtyFlag();

            Engine.SendMessage(message);
        }
Esempio n. 2
0
        static public void Execute(ClientMessageCarrior msg, GameServer server)
        {
            try
            {
                string id   = msg.id;
                int    code = msg.message.stateCode;

                switch (code)
                {
                case MsgCode.CLIENT_MOVE:
                    ClientMoveMessage m = msg.message as ClientMoveMessage;
                    server.MoveAndFire(id, m.dx, m.dy);
                    break;

                case MsgCode.CLIENT_QUIT:
                    server.Quit(id);
                    break;

                //case Fire:
                //    server.Fire(id);
                //    break;
                default:
                    break;
                }
            }
            catch
            {
            }
        }