Beispiel #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());
        }
Beispiel #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);
 }
Beispiel #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));
        }
Beispiel #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);
        }
Beispiel #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);
 }
Beispiel #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)));
 }
Beispiel #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)));
 }
Beispiel #8
0
        public static GamePolygon GetPollygonOffcetCenter(GamePoint[] gamePoints, float angleGradus, GamePoint creationGamePoint)
        {
            GamePoint centerPolygon = GetOffcetCenterPolygon(gamePoints);

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

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