private void AddingPointsUpdate() { Cursor cursor = GuiManager.Cursor; if (cursor.WindowOver == null) { Polygon polygon = CurrentShapeCollection.Polygons[0]; #region If cursor clicked, add new point if (cursor.PrimaryClick) { Matrix inverseRotation = polygon.RotationMatrix; #if FRB_MDX inverseRotation.Invert(); #else Matrix.Invert(ref inverseRotation, out inverseRotation); #endif Point newPoint = new Point( mReactiveHud.NewPointPolygon.Position.X - polygon.Position.X, mReactiveHud.NewPointPolygon.Position.Y - polygon.Position.Y); FlatRedBall.Math.MathFunctions.TransformPoint(ref newPoint, ref inverseRotation); // adding new point polygon.Insert(mReactiveHud.IndexBeforeNewPoint + 1, newPoint); } #endregion } }
private static IEnumerable <double> LocationVectorToInput(Point point) { var pathingPointList = new List <double> { AbsoluteXCoordinateToRelative((float)point.X), AbsoluteXCoordinateToRelative((float)point.Y) }; return(pathingPointList); }
/// <summary></summary> /// <param name="position">World position of this fake Node.</param> /// <param name="availablePortals">Portals leading out of NavArea this fake Node is positioned in.</param> private static TNode _CreateFakeNode(ref Point position, List <TNode> availablePortals, int nodeID) { var node = new TNode(); node.mID = nodeID; // fake Node node.Position.X = (float)position.X; node.Position.Y = (float)position.Y; return(node); }
/// <summary> /// Create "fake" Portal Node inside NavArea. /// I will auto-link one way to other Portal Nodes. = other Portal Nodes will not be affected, will not know about the links. /// </summary> public static TNode CreateFakeStartNode(ref Point position, List <TNode> availablePortals) { var node = _CreateFakeNode(ref position, availablePortals, -1); float distanceToTravel; foreach (var otherPortalNode in availablePortals) { distanceToTravel = (float)RUtils.Distance2D(ref node.Position, ref otherPortalNode.Position); node._FakeLinkToOneWay(otherPortalNode, distanceToTravel); } return(node); }
public virtual void PostInitialize() { bool oldShapeManagerSuppressAdd = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = true; if (BoatSpriteInstance.Parent == null) { BoatSpriteInstance.CopyAbsoluteToRelative(); BoatSpriteInstance.AttachTo(this, false); } if (BoatSpriteInstance.Parent == null) { BoatSpriteInstance.X = 0f; } else { BoatSpriteInstance.RelativeX = 0f; } if (BoatSpriteInstance.Parent == null) { BoatSpriteInstance.Y = 0f; } else { BoatSpriteInstance.RelativeY = 0f; } BoatSpriteInstance.Texture = BoatSprite; BoatSpriteInstance.TextureScale = 1f; if (mHitbox.Parent == null) { mHitbox.CopyAbsoluteToRelative(); mHitbox.AttachTo(this, false); } Hitbox.Visible = false; FlatRedBall.Math.Geometry.Point[] HitboxPoints = new FlatRedBall.Math.Geometry.Point[] { new FlatRedBall.Math.Geometry.Point(13, 32), new FlatRedBall.Math.Geometry.Point(13, -32), new FlatRedBall.Math.Geometry.Point(-13, -32), new FlatRedBall.Math.Geometry.Point(-13, 32), new FlatRedBall.Math.Geometry.Point(13, 32) }; Hitbox.Points = HitboxPoints; if (AnchorSpriteInstance.Parent == null) { AnchorSpriteInstance.CopyAbsoluteToRelative(); AnchorSpriteInstance.AttachTo(this, false); } AnchorSpriteInstance.Texture = AnchorSprite; AnchorSpriteInstance.TextureScale = 0.5f; AnchorSpriteInstance.Visible = false; mGeneratedCollision = new FlatRedBall.Math.Geometry.ShapeCollection(); mGeneratedCollision.Polygons.AddOneWay(mHitbox); FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = oldShapeManagerSuppressAdd; }
private void MakeCurrentPointRightAngle() { Polygon currentPolygon = CurrentPolygons[0]; int indexBefore = mReactiveHud.CornerIndexSelected - 1; if (indexBefore < 0) { indexBefore = CurrentPolygons[0].Points.Count - 2; } int indexAfter = (mReactiveHud.CornerIndexSelected + 1) % (CurrentPolygons[0].Points.Count - 1); int m = 3; Point grabbedPoint = currentPolygon.Points[mReactiveHud.CornerIndexSelected]; Point pointBefore = currentPolygon.Points[indexBefore]; Point pointAfter = currentPolygon.Points[indexAfter]; Point toBefore = pointBefore - grabbedPoint; Point toAfter = pointAfter - grabbedPoint; toBefore.Normalize(); toAfter.Normalize(); double xToSet = 0; double yToSet = 0; if (Math.Abs(toBefore.X) < Math.Abs(toAfter.X)) { xToSet = pointBefore.X; yToSet = pointAfter.Y; } else { xToSet = pointAfter.X; yToSet = pointBefore.Y; } grabbedPoint.X = xToSet; grabbedPoint.Y = yToSet; currentPolygon.SetPoint(mReactiveHud.CornerIndexSelected, grabbedPoint); if (mReactiveHud.CornerIndexSelected == 0) { currentPolygon.SetPoint(currentPolygon.Points.Count - 1, grabbedPoint); } }
public void GetObjectsOver <T>(AttachableList <T> allObjects, AttachableList <T> objectsOver) where T : PositionedObject, IAttachable, ICursorSelectable { if (mRectangle.Visible) { mRectangleStarted = false; float x = 0; float y = 0; GuiManager.Cursor.GetCursorPosition(out x, out y, 0); mRectangle.X = (x + mOriginalPoint.X) / 2.0f; mRectangle.Y = (y + mOriginalPoint.Y) / 2.0f; mRectangle.ScaleX = Math.Abs(x - mOriginalPoint.X) / 2.0f; mRectangle.ScaleY = Math.Abs(y - mOriginalPoint.Y) / 2.0f; if (System.Math.Abs(x - mOriginalPoint.X) > .1f && System.Math.Abs(y - mOriginalPoint.Y) > .1f) { Polygon spritePolygon = new Polygon(); Point[] spritePoints = new Point[5]; foreach (T t in allObjects) { if (t.CursorSelectable) { spritePoints[0] = new Point(-t.ScaleX, t.ScaleY); spritePoints[1] = new Point(t.ScaleX, t.ScaleY); spritePoints[2] = new Point(t.ScaleX, -t.ScaleY); spritePoints[3] = new Point(-t.ScaleX, -t.ScaleY); spritePoints[4] = spritePoints[0]; spritePolygon.Points = spritePoints; spritePolygon.Position = t.Position; spritePolygon.RotationMatrix = t.RotationMatrix; if (spritePolygon.CollideAgainst(mRectangle)) { objectsOver.Add(t); } } } } } }
/// <summary></summary> /// <param name="position">World position of this fake Node.</param> /// <param name="availablePortals">Portals leading out of NavArea this fake Node is positioned in.</param> /// <param name="containingNavArea">NavArea this fake Node is positioned in.</param> public static TNode CreateFakeNodeDebug(ref Point position, List <TNode> availablePortals, bool isEndNode, NavArea <TNode, TLink> containingNavArea) { TNode node; if (isEndNode) { node = CreateFakeEndNode(ref position, availablePortals, containingNavArea); } else { node = CreateFakeStartNode(ref position, availablePortals); } node.mParentNavArea1 = containingNavArea; node.mParentNavArea2 = containingNavArea; return(node); }
/// <summary> /// - Create "fake" Portal Node in the "middle" of NavArea. /// - Tell all Portal Nodes in containing NavArea to link (one way) to the new fake Node. /// = other Portal Nodes will create links to this fake Node. /// CleanupFakeEndNodeLinks() has to be called after fake Node is not needed anymore to remove those "fake" links. /// </summary> /// <param name="position"></param> /// <param name="availablePortals"></param> /// <param name="containingNavAreaID"></param> /// <returns></returns> public static TNode CreateFakeEndNode(ref Point position, List <TNode> availablePortals, NavArea <TNode, TLink> containingNavArea) { var fakePortalNode = _CreateFakeNode(ref position, availablePortals, -2); float distanceBetweeNodes; foreach (var otherPortalNode in availablePortals) { distanceBetweeNodes = (float)RUtils.Distance2D(ref fakePortalNode.Position, ref otherPortalNode.Position); otherPortalNode.LinkToOneWay( fakePortalNode, distanceBetweeNodes, // cost // Add real portal line here. containingNavArea ); } return(fakePortalNode); }
public virtual void PostInitialize() { bool oldShapeManagerSuppressAdd = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = true; if (mLine1.Parent == null) { mLine1.CopyAbsoluteToRelative(); mLine1.AttachTo(this, false); } FlatRedBall.Math.Geometry.Point[] Line1Points = new FlatRedBall.Math.Geometry.Point[] { new FlatRedBall.Math.Geometry.Point(-6, 6), new FlatRedBall.Math.Geometry.Point(6, -6) }; Line1.Points = Line1Points; if (mLine2.Parent == null) { mLine2.CopyAbsoluteToRelative(); mLine2.AttachTo(this, false); } FlatRedBall.Math.Geometry.Point[] Line2Points = new FlatRedBall.Math.Geometry.Point[] { new FlatRedBall.Math.Geometry.Point(6, 6), new FlatRedBall.Math.Geometry.Point(-6, -6) }; Line2.Points = Line2Points; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = oldShapeManagerSuppressAdd; }
internal static FlatRedBall.Math.Geometry.Polygon ReadPolygon(ContentReader input) { FlatRedBall.Math.Geometry.Polygon polygon = new FlatRedBall.Math.Geometry.Polygon(); polygon.Position = new Vector3(input.ReadSingle(), input.ReadSingle(), input.ReadSingle()); polygon.RotationZ = input.ReadSingle(); int numberOfPoints = input.ReadInt32(); FlatRedBall.Math.Geometry.Point[] pointList = new FlatRedBall.Math.Geometry.Point[numberOfPoints]; for (int i = 0; i < numberOfPoints; i++) { pointList[i] = new FlatRedBall.Math.Geometry.Point(input.ReadDouble(), input.ReadDouble()); } polygon.Points = pointList; polygon.Name = input.ReadString(); return(polygon); }
/// <summary>Creates a new PositionedNode.</summary> public static TNode Create(int id, NavArea <TNode, TLink> parentNavArea, NavArea <TNode, TLink> otherParentNavArea, SimpleLine portalForFirstParent) { Point portalCenter = _LineCenter(portalForFirstParent); var node = new TNode(); node.mID = id; node.mParentNavArea1 = parentNavArea; node.mParentNavArea2 = otherParentNavArea; node.mPortalSide1 = portalForFirstParent; node.mPortalSide1ParentAreaId = parentNavArea.ID; node.mPortalSide2 = NavMesh <TNode, TLink> ._GetInvertedLine(portalForFirstParent); node.mPortalSide2ParentAreaId = otherParentNavArea.ID; node.Position.X = (float)portalCenter.X; node.Position.Y = (float)portalCenter.Y; //node.mActive = true; return(node); }
private void AddingPointsOnEndUpdate() { Cursor cursor = GuiManager.Cursor; if (cursor.PrimaryClick) { if (CurrentShapeCollection.Polygons.Count == 0) { Polygon polygon = AddRectanglePolygon(); SelectPolygon(polygon); Point[] newPoints = new Point[1]; newPoints[0].X = cursor.WorldXAt(0) - polygon.X; newPoints[0].Y = cursor.WorldYAt(0) - polygon.Y; polygon.Points = newPoints; } else { Polygon currentPolygon = CurrentShapeCollection.Polygons[0]; Point[] newPoints = new Point[currentPolygon.Points.Count + 1]; for (int i = 0; i < currentPolygon.Points.Count; i++) { newPoints[i] = currentPolygon.Points[i]; } newPoints[currentPolygon.Points.Count].X = cursor.WorldXAt(0) - currentPolygon.X; newPoints[currentPolygon.Points.Count].Y = cursor.WorldYAt(0) - currentPolygon.Y; currentPolygon.Points = newPoints; } } }
public virtual void PostInitialize() { bool oldShapeManagerSuppressAdd = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = true; if (mArrowPoly1.Parent == null) { mArrowPoly1.CopyAbsoluteToRelative(); mArrowPoly1.AttachTo(this, false); } if (ArrowPoly1.Parent == null) { ArrowPoly1.X = 2f; } else { ArrowPoly1.RelativeX = 2f; } if (ArrowPoly1.Parent == null) { ArrowPoly1.Y = 58f; } else { ArrowPoly1.RelativeY = 58f; } if (ArrowPoly1.Parent == null) { ArrowPoly1.RotationZ = 1.57f; } else { ArrowPoly1.RelativeRotationZ = 1.57f; } FlatRedBall.Math.Geometry.Point[] ArrowPoly1Points = new FlatRedBall.Math.Geometry.Point[] { new FlatRedBall.Math.Geometry.Point(0, -50), new FlatRedBall.Math.Geometry.Point(0, 50), new FlatRedBall.Math.Geometry.Point(5, 35), new FlatRedBall.Math.Geometry.Point(-5, 35), new FlatRedBall.Math.Geometry.Point(0, 50) }; ArrowPoly1.Points = ArrowPoly1Points; if (mArrowPoly4.Parent == null) { mArrowPoly4.CopyAbsoluteToRelative(); mArrowPoly4.AttachTo(this, false); } if (ArrowPoly4.Parent == null) { ArrowPoly4.X = 2f; } else { ArrowPoly4.RelativeX = 2f; } if (ArrowPoly4.Parent == null) { ArrowPoly4.Y = -58f; } else { ArrowPoly4.RelativeY = -58f; } if (ArrowPoly4.Parent == null) { ArrowPoly4.RotationZ = -1.57f; } else { ArrowPoly4.RelativeRotationZ = -1.57f; } FlatRedBall.Math.Geometry.Point[] ArrowPoly4Points = new FlatRedBall.Math.Geometry.Point[] { new FlatRedBall.Math.Geometry.Point(0, -50), new FlatRedBall.Math.Geometry.Point(0, 50), new FlatRedBall.Math.Geometry.Point(5, 35), new FlatRedBall.Math.Geometry.Point(-5, 35), new FlatRedBall.Math.Geometry.Point(0, 50) }; ArrowPoly4.Points = ArrowPoly4Points; if (mArrowPoly2.Parent == null) { mArrowPoly2.CopyAbsoluteToRelative(); mArrowPoly2.AttachTo(this, false); } if (ArrowPoly2.Parent == null) { ArrowPoly2.X = 58f; } else { ArrowPoly2.RelativeX = 58f; } if (ArrowPoly2.Parent == null) { ArrowPoly2.Y = 1f; } else { ArrowPoly2.RelativeY = 1f; } FlatRedBall.Math.Geometry.Point[] ArrowPoly2Points = new FlatRedBall.Math.Geometry.Point[] { new FlatRedBall.Math.Geometry.Point(0, -50), new FlatRedBall.Math.Geometry.Point(0, 50), new FlatRedBall.Math.Geometry.Point(5, 35), new FlatRedBall.Math.Geometry.Point(-5, 35), new FlatRedBall.Math.Geometry.Point(0, 50) }; ArrowPoly2.Points = ArrowPoly2Points; if (mArrowPoly3.Parent == null) { mArrowPoly3.CopyAbsoluteToRelative(); mArrowPoly3.AttachTo(this, false); } if (ArrowPoly3.Parent == null) { ArrowPoly3.X = -58f; } else { ArrowPoly3.RelativeX = -58f; } if (ArrowPoly3.Parent == null) { ArrowPoly3.Y = 1f; } else { ArrowPoly3.RelativeY = 1f; } if (ArrowPoly3.Parent == null) { ArrowPoly3.RotationZ = 3.14f; } else { ArrowPoly3.RelativeRotationZ = 3.14f; } FlatRedBall.Math.Geometry.Point[] ArrowPoly3Points = new FlatRedBall.Math.Geometry.Point[] { new FlatRedBall.Math.Geometry.Point(0, -50), new FlatRedBall.Math.Geometry.Point(0, 50), new FlatRedBall.Math.Geometry.Point(5, 35), new FlatRedBall.Math.Geometry.Point(-5, 35), new FlatRedBall.Math.Geometry.Point(0, 50) }; ArrowPoly3.Points = ArrowPoly3Points; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = oldShapeManagerSuppressAdd; }
public virtual void PostInitialize() { bool oldShapeManagerSuppressAdd = FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = true; CenterH.Visible = false; CenterH.Color = Microsoft.Xna.Framework.Color.DarkBlue; FlatRedBall.Math.Geometry.Point[] CenterHPoints = new FlatRedBall.Math.Geometry.Point[] { new FlatRedBall.Math.Geometry.Point(-25, 0), new FlatRedBall.Math.Geometry.Point(25, 0) }; CenterH.Points = CenterHPoints; CenterV.Visible = false; CenterV.Color = Microsoft.Xna.Framework.Color.DarkBlue; FlatRedBall.Math.Geometry.Point[] CenterVPoints = new FlatRedBall.Math.Geometry.Point[] { new FlatRedBall.Math.Geometry.Point(0, 25), new FlatRedBall.Math.Geometry.Point(0, -25) }; CenterV.Points = CenterVPoints; RectsList.Add(Rect1Main); if (Rect1Main.Parent == null) { Rect1Main.Z = 10f; } else { Rect1Main.RelativeZ = 10f; } Rect1Main.Width = 100f; Rect1Main.Height = 100f; Rect1Main.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(Rect2InnerTouching); if (Rect2InnerTouching.Parent == null) { Rect2InnerTouching.X = 50f; } else { Rect2InnerTouching.RelativeX = 50f; } if (Rect2InnerTouching.Parent == null) { Rect2InnerTouching.Y = -100f; } else { Rect2InnerTouching.RelativeY = -100f; } if (Rect2InnerTouching.Parent == null) { Rect2InnerTouching.Z = 10f; } else { Rect2InnerTouching.RelativeZ = 10f; } Rect2InnerTouching.Width = 100f; Rect2InnerTouching.Height = 100f; Rect2InnerTouching.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(RectOuterTouching2); if (RectOuterTouching2.Parent == null) { RectOuterTouching2.X = -220f; } else { RectOuterTouching2.RelativeX = -220f; } if (RectOuterTouching2.Parent == null) { RectOuterTouching2.Y = -213f; } else { RectOuterTouching2.RelativeY = -213f; } if (RectOuterTouching2.Parent == null) { RectOuterTouching2.Z = 10f; } else { RectOuterTouching2.RelativeZ = 10f; } RectOuterTouching2.Width = 100f; RectOuterTouching2.Height = 100f; RectOuterTouching2.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(Rect3InnerTouching); if (Rect3InnerTouching.Parent == null) { Rect3InnerTouching.X = -100f; } else { Rect3InnerTouching.RelativeX = -100f; } if (Rect3InnerTouching.Parent == null) { Rect3InnerTouching.Y = -20f; } else { Rect3InnerTouching.RelativeY = -20f; } if (Rect3InnerTouching.Parent == null) { Rect3InnerTouching.Z = 10f; } else { Rect3InnerTouching.RelativeZ = 10f; } Rect3InnerTouching.Width = 100f; Rect3InnerTouching.Height = 100f; Rect3InnerTouching.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(Rect4InnerTouching); if (Rect4InnerTouching.Parent == null) { Rect4InnerTouching.X = 70f; } else { Rect4InnerTouching.RelativeX = 70f; } if (Rect4InnerTouching.Parent == null) { Rect4InnerTouching.Y = 40f; } else { Rect4InnerTouching.RelativeY = 40f; } if (Rect4InnerTouching.Parent == null) { Rect4InnerTouching.Z = 10f; } else { Rect4InnerTouching.RelativeZ = 10f; } Rect4InnerTouching.Width = 40f; Rect4InnerTouching.Height = 60f; Rect4InnerTouching.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(Rect5InnerTouching); if (Rect5InnerTouching.Parent == null) { Rect5InnerTouching.X = -105f; } else { Rect5InnerTouching.RelativeX = -105f; } if (Rect5InnerTouching.Parent == null) { Rect5InnerTouching.Y = 90f; } else { Rect5InnerTouching.RelativeY = 90f; } if (Rect5InnerTouching.Parent == null) { Rect5InnerTouching.Z = 10f; } else { Rect5InnerTouching.RelativeZ = 10f; } Rect5InnerTouching.Width = 150f; Rect5InnerTouching.Height = 80f; Rect5InnerTouching.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(Rect6OuterTouching); if (Rect6OuterTouching.Parent == null) { Rect6OuterTouching.X = 70f; } else { Rect6OuterTouching.RelativeX = 70f; } if (Rect6OuterTouching.Parent == null) { Rect6OuterTouching.Y = 120f; } else { Rect6OuterTouching.RelativeY = 120f; } if (Rect6OuterTouching.Parent == null) { Rect6OuterTouching.Z = 10f; } else { Rect6OuterTouching.RelativeZ = 10f; } Rect6OuterTouching.Width = 200f; Rect6OuterTouching.Height = 100f; Rect6OuterTouching.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(Rect7OuterTouching); if (Rect7OuterTouching.Parent == null) { Rect7OuterTouching.X = -350f; } else { Rect7OuterTouching.RelativeX = -350f; } if (Rect7OuterTouching.Parent == null) { Rect7OuterTouching.Y = 221f; } else { Rect7OuterTouching.RelativeY = 221f; } if (Rect7OuterTouching.Parent == null) { Rect7OuterTouching.Z = 10f; } else { Rect7OuterTouching.RelativeZ = 10f; } Rect7OuterTouching.Width = 40f; Rect7OuterTouching.Height = 100f; Rect7OuterTouching.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(Rect8OuterNotTouching); if (Rect8OuterNotTouching.Parent == null) { Rect8OuterNotTouching.X = -320f; } else { Rect8OuterNotTouching.RelativeX = -320f; } if (Rect8OuterNotTouching.Parent == null) { Rect8OuterNotTouching.Y = -150f; } else { Rect8OuterNotTouching.RelativeY = -150f; } if (Rect8OuterNotTouching.Parent == null) { Rect8OuterNotTouching.Z = 10f; } else { Rect8OuterNotTouching.RelativeZ = 10f; } Rect8OuterNotTouching.Width = 100f; Rect8OuterNotTouching.Height = 200f; Rect8OuterNotTouching.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(Rect8OuterNotTouching2); if (Rect8OuterNotTouching2.Parent == null) { Rect8OuterNotTouching2.X = -100f; } else { Rect8OuterNotTouching2.RelativeX = -100f; } if (Rect8OuterNotTouching2.Parent == null) { Rect8OuterNotTouching2.Y = -170f; } else { Rect8OuterNotTouching2.RelativeY = -170f; } if (Rect8OuterNotTouching2.Parent == null) { Rect8OuterNotTouching2.Z = 10f; } else { Rect8OuterNotTouching2.RelativeZ = 10f; } Rect8OuterNotTouching2.Width = 100f; Rect8OuterNotTouching2.Height = 200f; Rect8OuterNotTouching2.Color = Microsoft.Xna.Framework.Color.Salmon; RectsList.Add(Rect6OuterTouching2); if (Rect6OuterTouching2.Parent == null) { Rect6OuterTouching2.X = -250f; } else { Rect6OuterTouching2.RelativeX = -250f; } if (Rect6OuterTouching2.Parent == null) { Rect6OuterTouching2.Y = 0f; } else { Rect6OuterTouching2.RelativeY = 0f; } if (Rect6OuterTouching2.Parent == null) { Rect6OuterTouching2.Z = 10f; } else { Rect6OuterTouching2.RelativeZ = 10f; } Rect6OuterTouching2.Width = 200f; Rect6OuterTouching2.Height = 100f; Rect6OuterTouching2.Color = Microsoft.Xna.Framework.Color.Salmon; FlatRedBall.Math.Geometry.ShapeManager.SuppressAddingOnVisibilityTrue = oldShapeManagerSuppressAdd; }
private void AddingPointsOnEndUpdate() { Cursor cursor = GuiManager.Cursor; if(cursor.PrimaryClick) { if (CurrentShapeCollection.Polygons.Count == 0) { Polygon polygon = AddRectanglePolygon(); SelectPolygon(polygon); Point[] newPoints = new Point[1]; newPoints[0].X = cursor.WorldXAt(0) - polygon.X; newPoints[0].Y = cursor.WorldYAt(0) - polygon.Y; polygon.Points = newPoints; } else { Polygon currentPolygon = CurrentShapeCollection.Polygons[0]; Point[] newPoints = new Point[currentPolygon.Points.Count + 1]; for (int i = 0; i < currentPolygon.Points.Count; i++) { newPoints[i] = currentPolygon.Points[i]; } newPoints[currentPolygon.Points.Count].X = cursor.WorldXAt(0) - currentPolygon.X; newPoints[currentPolygon.Points.Count].Y = cursor.WorldYAt(0) - currentPolygon.Y; currentPolygon.Points = newPoints; } } }
private void AddingPointsUpdate() { Cursor cursor = GuiManager.Cursor; if (cursor.WindowOver == null) { Polygon polygon = CurrentShapeCollection.Polygons[0]; #region If cursor clicked, add new point if (cursor.PrimaryClick) { Matrix inverseRotation = polygon.RotationMatrix; #if FRB_MDX inverseRotation.Invert(); #else Matrix.Invert(ref inverseRotation, out inverseRotation); #endif Point newPoint = new Point( mReactiveHud.NewPointPolygon.Position.X - polygon.Position.X, mReactiveHud.NewPointPolygon.Position.Y - polygon.Position.Y); FlatRedBall.Math.MathFunctions.TransformPoint(ref newPoint, ref inverseRotation); // adding new point polygon.Insert( mReactiveHud.IndexBeforeNewPoint + 1, newPoint); } #endregion } }