示例#1
0
        internal GamePoint[] SetMove(float distance, float angleRotate)
        {
            var angleRad = (angleRotate * Math.PI) / 180;

            CenterPolygonAbsolute = new GamePoint(-Math.Sin(angleRad) * distance + CenterPolygonAbsolute.X
                                                  , Math.Cos(angleRad) * distance + CenterPolygonAbsolute.Y);
            return(GetDrawPoints());
        }
示例#2
0
 private GamePoint[] RotatePolygon()
 {
     GamePoint[] rotateGamePoints = new GamePoint[Points.Length];
     for (int i = 0; i < Points.Length; i++)
     {
         rotateGamePoints[i] = RotatePoint(Points[i]);
     }
     return(rotateGamePoints);
 }
示例#3
0
        internal GamePoint RotatePoint(GamePoint point)
        {
            var angleRad = (AngleRotate * Math.PI) / 180;
            var x        = (point.X) * Math.Cos(angleRad) - (point.Y)
                           * Math.Sin(angleRad);
            var y = (point.X) * Math.Sin(angleRad) + (point.Y)
                    * Math.Cos(angleRad);

            return(new GamePoint((float)x, (float)y));
        }
示例#4
0
        public GamePoint[] GetDrawPoints()
        {
            GamePoint[] newGamePoints = new GamePoint[Points.Length];

            var rotatePoints = RotatePolygon();

            for (int i = 0; i < newGamePoints.Length; i++)
            {
                newGamePoints[i] = rotatePoints[i] * Scale + CenterPolygonAbsolute;
            }

            return(newGamePoints);
        }
示例#5
0
 private GamePolygon(GamePoint[] gamePoints, GamePoint centerPolygon, float angleGradus, GamePoint creationGamePoint, bool offcetCenter = false)
 {
     if (gamePoints.Length < 3)
     {
         throw new ArgumentException("Полигон объекта не может иметь менее трех вершин.");
     }
     GamePoint[] polygonGamePoint = new GamePoint[gamePoints.Length];
     for (int i = 0; i < gamePoints.Length; i++)
     {
         polygonGamePoint[i] = gamePoints[i] - centerPolygon;
     }
     Points = polygonGamePoint;
     CenterPolygonAbsolute = creationGamePoint;
     OffcetCenter          = offcetCenter;
     CenterPolygonRelative = centerPolygon;
     AngleRotate           = angleGradus;
     SetMaxRadius(CenterPolygonRelative);
 }
示例#6
0
 public float DistanceTo(GamePoint gamePoint)
 {
     return((float)Math.Sqrt((this.X - gamePoint.X) * (this.X - gamePoint.X) + (this.Y - gamePoint.Y) * (this.Y - gamePoint.Y)));
 }
示例#7
0
 //Методы возвращают расстояние между двумя точками.
 public static float Distance(GamePoint gamePointA, GamePoint gamePointB)
 {
     return((float)Math.Sqrt((gamePointA.X - gamePointB.X) * (gamePointA.X - gamePointB.X) + (gamePointA.Y - gamePointB.Y) * (gamePointA.Y - gamePointB.Y)));
 }
示例#8
0
        public static GamePolygon GetPollygonOffcetCenter(GamePoint[] gamePoints, float angleGradus, GamePoint creationGamePoint)
        {
            GamePoint centerPolygon = GetOffcetCenterPolygon(gamePoints);

            return(new GamePolygon(gamePoints, centerPolygon, angleGradus, creationGamePoint, true));
        }
示例#9
0
        public static GamePolygon GetPolygon(GamePoint[] points, float angleRotationGradus, GamePoint creationGamePoint)
        {
            GamePoint centerPolygon = GetCenterPolygon(points);

            return(new GamePolygon(points, centerPolygon, angleRotationGradus, creationGamePoint));
        }
示例#10
0
 private void SetMaxRadius(GamePoint centerPolygon)
 {
     MaxRadiusObject = (float)Points.Select(n => n * Scale).Max(n => n.DistanceTo(centerPolygon));
 }