예제 #1
0
        private static CollisionInfo GetCollisionInfo(RigidCircle circle, RigidTriangle triangle)
        {
            var a = triangle.Points[0]; var b = triangle.Points[1]; var c = triangle.Points[2];
            var q = GetClosestPoint(circle.Center, a, b, c);
            var v = q - circle.Center;

            return(Vector.ScalarProduct(v, v) <= circle.Radius * circle.Radius
                ? new CollisionInfo(v.Length, v, q)
                : null);
        }
        private static void DrawTriangle(RigidTriangle shape, Vector cameraPosition, Pen strokePen, Graphics g)
        {
            var pointsInCamera = new PointF[3];

            for (var i = 0; i < 3; i++)
            {
                pointsInCamera[i] = shape.Points[i].ConvertFromWorldToCamera(cameraPosition).GetPointF();
            }

            g.DrawPolygon(strokePen, pointsInCamera);
        }
        private static void DrawTriangle(RigidTriangle shape, Pen strokePen, Graphics g)
        {
            var points = new PointF[3];

            for (var i = 0; i < 3; i++)
            {
                points[i] = shape.Points[i].GetPointF();
            }

            g.DrawPolygon(strokePen, points);
        }
예제 #4
0
            public Range(Vector playerCenter)
            {
                var trianglePoints = new[]
                {
                    playerCenter.Copy(),
                    playerCenter + new Vector(0, -74),
                    playerCenter + new Vector(32, 0)
                };

                Sector = new RigidCircleQuarter(
                    new Vector(0, -1),
                    2,
                    new RigidCircle(playerCenter.Copy(), 74, false, false));
                Triangle     = new RigidTriangle(trianglePoints, false, false);
                currentAngle = 90;
            }