state = State.down;\r
\r
Point destination = MovementManager.GetNeighborCell(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown);\r
- if (theMap.IsCellOpen(destination))\r
+ if (!keysPressed.Contains(Keys.LeftControl))\r
{\r
- mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
+ if (theMap.IsCellOpen(destination))\r
+ {\r
+ mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
+ }\r
+ else\r
+ {\r
+ mMotion.Update(timeSpan);\r
+ }\r
}\r
else\r
{\r
- mMotion.Update(timeSpan);\r
+ mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown);\r
}\r
\r
\r
RecalculatePosition(alpha);\r
}\r
}\r
+ public void LockUpdate(TimeSpan timeSpan, bool moveLeft, bool moveRight, bool moveUp, bool moveDown)\r
+ {\r
+ float passedTime = (float)timeSpan.TotalSeconds;\r
+ if (moveLeft == true || moveRight == true || moveUp == true || moveDown == true)\r
+ {\r
+ mDirection = GetDirection(moveLeft, moveRight, moveUp, moveDown);\r
+ }\r
+ if (mIsMoving)\r
+ {\r
+ mTimeAccumulator += passedTime;\r
+\r
+ float alpha = mTimeAccumulator / mInverseSpeed;\r
+ if (alpha >= 1.0f)\r
+ {\r
+ mIsMoving = false;\r
+ alpha = 1.0f;\r
+ }\r
+\r
+ RecalculatePosition(alpha);\r
+ }\r
+ }\r
\r
\r
/// <summary>\r