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); } }
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); } }
public void Apply(ICommandOwner owner, ICommand command) { owner.Command(command); }
public void Handle <C, H>(ICommandOwner <C, H> owner, C command) where C : ICommand where H : ICommandHandler <C> { owner.Handler.Handle(command, owner); }