public void Handle(RotationCommand command, ICommandOwner commandOwner)
        {
            if (commandOwner is IRotateable)
            {
                var directionOwner = ((IDirectionOwner)commandOwner);

                var newDegree = directionOwner.Direction.Degree.Add(command.Degree);

                var newDirection = directionManager.GetDirections().First(x => x.Degree == newDegree);

                directionOwner.SetDirection(newDirection);
            }
        }
Ejemplo n.º 2
0
        public void Handle(MoveCommand command, ICommandOwner owner)
        {
            if (owner is IMoveable)
            {
                if (command.Degree != 0)
                {
                    throw new NotImplementedException();
                }

                var tileOwner      = ((ITileOwner)owner);
                var directionOwner = ((IDirectionOwner)owner);

                var targetPosition = tileOwner.CurrentTile.FindNeighbourTilePosition(directionOwner.Direction);

                tileOwner.Move(targetPosition);
            }
        }
Ejemplo n.º 3
0
 public void Apply(ICommandOwner owner, ICommand command)
 {
     owner.Command(command);
 }
Ejemplo n.º 4
0
 public void Handle <C, H>(ICommandOwner <C, H> owner, C command) where C : ICommand where H : ICommandHandler <C>
 {
     owner.Handler.Handle(command, owner);
 }