예제 #1
0
 private void Apply(EnterGameCommand command, GameTime gameTime)
 {
     _grid.Enter(command.Entity, command.Coordinates);
     command.Entity.SetCoordinates(command.Coordinates, gameTime);
     command.Entity.Appears();
     _pipeline.Subscribe(command.Entity);
 }
예제 #2
0
        protected override void OnReceived(byte[] body)
        {
            ByteArrayArrayStream stream = new ByteArrayArrayStream(body);

            ByteArrayStreamReader reader = new ByteArrayStreamReader(stream);

            try
            {
                if (Adler32.Generate(body, 4) == reader.ReadUInt())
                {
                    if (Keys == null)
                    {
                        Rsa.DecryptAndReplace(body, 21);
                    }

                    Command command = null;

                    switch (reader.ReadByte())
                    {
                    case 0x01:
                    {
                        var packet = server.PacketsFactory.Create <EnterGameIncomingPacket>(reader);

                        command = new EnterGameCommand(this, packet);
                    }
                    break;
                    }

                    if (command != null)
                    {
                        server.QueueForExecution(command);
                    }
                }
            }
            catch (Exception ex)
            {
                server.Logger.WriteLine(ex.ToString());
            }

            base.OnReceived(body);
        }
예제 #3
0
 private void Apply(EnterGameCommand command, GameTime gameTime)
 {
     _grid.Exit(command.Entity);
     command.Entity.ClearPosition();
     _pipeline.Unsubscribe(command.Entity);
 }
예제 #4
0
        private void InitializeEntity(Entity entity, Coordinates to, GameTime gameTime)
        {
            var command = new EnterGameCommand(entity, to);

            _doCommandsHandler.Apply(command, gameTime);
        }