void Update() { if (movingPiece != null) { Vector2 dir = ((Vector2)Input.mousePosition - mouseStart); Vector2 nDir = dir.normalized; Vector2 aDir = new Vector2(Mathf.Abs(dir.x), Mathf.Abs(dir.y)); newIndex = Point.Clone(movingPiece.index); Point add = Point.Zero; if (dir.magnitude > 32) { if (aDir.x > aDir.y) { add = (new Point((nDir.x > 0) ? 1 : -1, 0)); } else if (aDir.y > aDir.x) { add = (new Point(0, (nDir.y > 0) ? 1 : -1)); } } newIndex.Add(add); Vector2 pos = game.GetPosFromPoint(movingPiece.index); if (!newIndex.Equals(movingPiece.index)) { pos += Point.Mult(add, 16).ToVector(); } movingPiece.MovePosTo(pos); } }