示例#1
0
		private static Rectangle CalculateArrowDrawArea(Material material, Vector2D start, Vector2D target)
		{
			start += Vector2D.Normalize(start.DirectionTo(target)) * 0.033f;
			target -= Vector2D.Normalize(start.DirectionTo(target)) * 0.033f;
			var distance = start.DistanceTo(target);
			var size = new Size(distance, distance / material.DiffuseMap.PixelSize.AspectRatio);
			return Rectangle.FromCenter((start + target) / 2, size * GameLogic.ArrowSize);
		}
示例#2
0
        private static Rectangle CalculateArrowDrawArea(Material material, Vector2D start, Vector2D target)
        {
            start  += Vector2D.Normalize(start.DirectionTo(target)) * 0.033f;
            target -= Vector2D.Normalize(start.DirectionTo(target)) * 0.033f;
            var distance = start.DistanceTo(target);
            var size     = new Size(distance, distance / material.DiffuseMap.PixelSize.AspectRatio);

            return(Rectangle.FromCenter((start + target) / 2, size * GameLogic.ArrowSize));
        }
示例#3
0
 private void OnReleasing()
 {
     if (grabbedBall != null)
     {
         grabbedBall.LinearVelocity = lastMousePosition.DirectionTo(grabbedBall.Position) * 4f;
     }
     grabbedBall = null;
 }
        private static void ZoomLinePoints(List <Vector2D> points, float zoomAmount)
        {
            Vector2D center = Vector2D.Half;

            for (int i = 0; i < points.Count; i++)
            {
                points[i] = center + center.DirectionTo(points[i]) * (1 + zoomAmount);
            }
        }
示例#5
0
		private Vector2D GetNextPathPosition(Vector2D formerPosition)
		{
			var nextPosition = formerPosition +
				formerPosition.DirectionTo(Path.Path[nextPathIndex].Position);
			if (nextPosition == Path.Path[nextPathIndex].Position)
				nextPathIndex++;
			if (nextPathIndex >= Path.Path.Count)
			{
				nextPathIndex = 1;
				nextPosition = Path.Path[0].Position;
			}
			lastPosition = nextPosition;
			return nextPosition + Vector2D.Half;
		}
示例#6
0
        private Vector2D GetNextPathPosition(Vector2D formerPosition)
        {
            var nextPosition = formerPosition +
                               formerPosition.DirectionTo(Path.Path[nextPathIndex].Position);

            if (nextPosition == Path.Path[nextPathIndex].Position)
            {
                nextPathIndex++;
            }
            if (nextPathIndex >= Path.Path.Count)
            {
                nextPathIndex = 1;
                nextPosition  = Path.Path[0].Position;
            }
            lastPosition = nextPosition;
            return(nextPosition + Vector2D.Half);
        }
示例#7
0
 private float GetRotation()
 {
     return(lastPosition.DirectionTo(Path.Path[nextPathIndex].Position).GetRotation() + 90.0f);
 }
示例#8
0
 public void DirectionTo()
 {
     Assert.AreEqual(new Vector2D(2, -6), v1.DirectionTo(v2));
 }