private void MovePipes(Vector3 currentMousePosition, Direction direction, GameTime time)
{
int distance = (int)Math.Round (ComputeLength (currentMousePosition));
if (distance > 0) {
try {
Knot newKnot;
if (knotCache.ContainsKey (direction * distance)) {
newKnot = knotCache [direction * distance];
}
else {
Knot.TryMove (direction, distance, out newKnot);
knotCache [direction * distance] = newKnot;
}
if (newKnot != null) {
KnotMoved (newKnot);
Screen.AudioManager.PlaySound (Knot3Sound.PipeMoveSound);
}
else {
KnotMoved (Knot);
Screen.AudioManager.PlaySound (Knot3Sound.PipeInvalidMoveSound);
}
previousMousePosition = currentMousePosition;
}
catch (ArgumentOutOfRangeException exp) {
Log.Debug (exp);
}
}
knotCache.Clear ();
}