public static List <List <BumperEntityPoly> > GroupizeCloseBumpers(List <BumperEntityPoly> rBumpers) { List <List <BumperEntityPoly> > result = new List <List <BumperEntityPoly> >(); foreach (BumperEntityPoly bumper1 in rBumpers) { List <BumperEntityPoly> listOfCloseToBumper1 = new List <BumperEntityPoly>() { bumper1 }; foreach (BumperEntityPoly bumper2 in rBumpers) { if (bumper1 != bumper2) { BumpRigid b1 = bumper1.CompObj as BumpRigid; BumpRigid b2 = bumper2.CompObj as BumpRigid; if (RigidsHelperModule.IsCloseEnough(b1, b2, 90)) { AddToProperList(bumper1, bumper2, ref listOfCloseToBumper1, ref result); //listOfCloseToBumper1.Add(bumper2); } } } if (listOfCloseToBumper1.Count > 1) { result.Add(listOfCloseToBumper1); } } for (int i = 0; i < result.Count; i++) { result[0].Sort(GroupSorter); } return(result); }
public override void AddSelfToEngine() { Direction bDir = (Direction)(this.dir); BumpRigid boxRigid = new BumpRigid(new Vector3(this.X, this.Y, 0), Material.Wood, StaticData.BumpHalfSize, bDir); StaticData.EngineManager.RigidsManagerEngine.AddRigidBody(boxRigid); }
private BumpRigid AddBumpsToEngine() { Direction bDir = Direction.East; BumpRigid boxRigid = new BumpRigid(new Vector3(mouseState.X, mouseState.Y, 0), Material.Wood, new Vector3(30, 15, 0), bDir); StaticData.EngineManager.RigidsManagerEngine.AddRigidBody(boxRigid); return(boxRigid); }
public static List <IntPoint> GetBumperDeletionPoly(BumpRigid bump) { Vector2 posCenter = bump.PositionXNACenter2D; float xUL, xUR, xBL, xBR, yUL, yUR, yBL, yBR; xUL = xUR = xBL = xBR = yUL = yUR = yBL = yBR = 0; return(new List <IntPoint>() { new IntPoint((int)posCenter.X - nR, (int)posCenter.Y), new IntPoint((int)posCenter.X + nR, (int)posCenter.Y), new IntPoint((int)posCenter.X + nR, (int)posCenter.Y + AreaCompPolyHandler.BumperDelArea), new IntPoint((int)posCenter.X - nR, (int)posCenter.Y + AreaCompPolyHandler.BumperDelArea), }); }
private bool CookieCollidedWithBump() { foreach (var boxRigid in StaticData.EngineManager.RigidsManagerEngine.ListOfBoxRigids) { BumpRigid bump = boxRigid as BumpRigid; if (bump != null) { CollisionData data = new CollisionData(); data.contacts = new List <Contact>(); if (CollisionDetector.boxAndSphere(bump, StaticData.EngineManager.CookieRB, ref data)) { return(true); } } } return(false); }
private void ManipulateAddingBumps() { if (mouseState.LeftButton == ButtonState.Pressed) { if (_bump == null) { _bump = AddBumpsToEngine(); } } else { if (_bump != null && mouseState.LeftButton == ButtonState.Released) { _bump = null; } } }
public static int BumpersComparator(CompEntityPoly e1, CompEntityPoly e2) { BumpRigid b1 = e1.CompObj as BumpRigid; BumpRigid b2 = e2.CompObj as BumpRigid; if (b1.PositionXNACenter2D.Y > b2.PositionXNACenter2D.Y) { return(1); } else { if (b1.PositionXNACenter2D.Y < b2.PositionXNACenter2D.Y) { return(-1); } } return(0); }
public static void FindBumperTwoBorderPoints(BumperEntityPoly bumperEntity, out Vector2 pb1, out Vector2 pb2) { BumpRigid bump = (bumperEntity.CompObj as BumpRigid); Vector2 bXNA = bump.PositionXNA2D; Vector2 bXNACenter = bump.PositionXNACenter2D; int halfBumpWidth = bump.Width / 2 - 5; switch (bump.Dir) { case Direction.East: case Direction.West: pb1 = bXNA + new Vector2(0, bump.Height / 2); pb2 = bXNA + new Vector2(bump.Width, bump.Height / 2); break; case Direction.SouthEast: case Direction.NorthWest: pb1 = bXNACenter + new Vector2(-halfBumpWidth, -halfBumpWidth); pb2 = bXNACenter + new Vector2(+halfBumpWidth, +halfBumpWidth); break; case Direction.South: case Direction.North: pb1 = bXNACenter + new Vector2(0, -halfBumpWidth); pb2 = bXNACenter + new Vector2(0, bump.Width - halfBumpWidth); break; case Direction.SouthWest: case Direction.NorthEast: pb1 = bXNACenter + new Vector2(-halfBumpWidth, +halfBumpWidth); pb2 = bXNACenter + new Vector2(+halfBumpWidth, -halfBumpWidth); break; default: throw new ArgumentOutOfRangeException(); } }
public static List <IntPoint> GetBumperPoly(BumpRigid me, Vector2 ePos) { Vector2 posCenter = me.PositionXNACenter2D; float xUL, xUR, xBL, xBR, yUL, yUR, yBL, yBR; xUL = xUR = xBL = xBR = yUL = yUR = yBL = yBR = 0; CookieDirection abDir = GetABCookieDirection(ePos, posCenter); CookieDirection rlDir = GetRLCookieDirection(ePos, posCenter); switch (me.Dir) { case Direction.East: case Direction.West: if (abDir == CookieDirection.FromAbove) { if (rlDir == CookieDirection.FromLeft) { return(new List <IntPoint>() { new IntPoint((int)posCenter.X, (int)posCenter.Y - fR), new IntPoint((int)posCenter.X + dfR, (int)posCenter.Y - fR + 10), new IntPoint((int)posCenter.X + dfR, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X + nR, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X + nR, (int)posCenter.Y), new IntPoint((int)posCenter.X, (int)posCenter.Y), }); } else { return(new List <IntPoint>() { new IntPoint((int)posCenter.X - dfR, (int)posCenter.Y - fR + 10), new IntPoint((int)posCenter.X, (int)posCenter.Y - fR), new IntPoint((int)posCenter.X, (int)posCenter.Y), new IntPoint((int)posCenter.X - nR, (int)posCenter.Y), new IntPoint((int)posCenter.X - nR, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X - dfR, (int)posCenter.Y + 900), }); } } else // From Bottom { if (rlDir == CookieDirection.FromLeft) { return(new List <IntPoint>() { new IntPoint((int)posCenter.X, (int)posCenter.Y), new IntPoint((int)posCenter.X + dfR, (int)posCenter.Y + 30), new IntPoint((int)posCenter.X + dfR, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X, (int)posCenter.Y + 900), }); } else { return(new List <IntPoint>() { new IntPoint((int)posCenter.X - dfR, (int)posCenter.Y + 30), new IntPoint((int)posCenter.X, (int)posCenter.Y), new IntPoint((int)posCenter.X, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X - dfR, (int)posCenter.Y + 900), }); } } break; case Direction.SouthEast: case Direction.NorthWest: if (abDir == CookieDirection.FromAbove) { return(new List <IntPoint>() { new IntPoint((int)posCenter.X - 20, (int)posCenter.Y - 20), new IntPoint((int)posCenter.X + 20, (int)posCenter.Y - fR), new IntPoint((int)posCenter.X + dfR, (int)posCenter.Y - nR), new IntPoint((int)posCenter.X + dfR, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X + 20, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X + 20, (int)posCenter.Y + 20), }); } else { //if (abDir == CookieDirection.FromBottom) { return(new List <IntPoint>() { new IntPoint((int)posCenter.X - dfR / 2, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X - dfR / 2, (int)posCenter.Y), new IntPoint((int)posCenter.X - 20, (int)posCenter.Y - 20), new IntPoint((int)posCenter.X + nR, (int)posCenter.Y + nR), new IntPoint((int)posCenter.X + nR, (int)posCenter.Y + 900), }); } } break; case Direction.South: case Direction.North: return(new List <IntPoint>() { }); break; case Direction.SouthWest: case Direction.NorthEast: if (abDir == CookieDirection.FromAbove) { return(new List <IntPoint>() { new IntPoint((int)posCenter.X - dfR, (int)posCenter.Y - fR), new IntPoint((int)posCenter.X, (int)posCenter.Y - fR), new IntPoint((int)posCenter.X + 20, (int)posCenter.Y - 20), new IntPoint((int)posCenter.X - 20, (int)posCenter.Y + 20), new IntPoint((int)posCenter.X - 20, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X - dfR, (int)posCenter.Y + 900) }); } else { return(new List <IntPoint>() { new IntPoint((int)posCenter.X - 20, (int)posCenter.Y + 20), new IntPoint((int)posCenter.X + 20, (int)posCenter.Y - 20), new IntPoint((int)posCenter.X + dfR, (int)posCenter.Y), new IntPoint((int)posCenter.X + dfR, (int)posCenter.Y + 900), new IntPoint((int)posCenter.X - 20, (int)posCenter.Y + 900), }); } break; default: throw new ArgumentOutOfRangeException(); } }
public List <IntPoint> GetDefBumperPoly(BumpRigid bump) { return(DefinitiveCompPolyHandler.GetDefComponentIntersection(bump.PositionXNACenter2D, bump.Width)); }
public static void AddBumpsAreaForBubble(ref List <List <IntPoint> > initialPoly, BumperEntityPoly bumper, BubbleEntityPoly bubble) { BubbleService bubbleService = bubble.CompObj as BubbleService; Vector2 bubblePos = bubbleService.PositionXNACenter; //var coveredBumps = BumpersHandler.GetCoveredBumpers(bubble, initialPoly); int fR = AreaCompPolyHandler.fR; int nR = AreaCompPolyHandler.nR; int dfR = AreaCompPolyHandler.dfR; //foreach (BumperEntityPoly bumper in coveredBumps) { BumpRigid bump = bumper.CompObj as BumpRigid; Vector2 bPos = bump.PositionXNACenter2D; CookieDirection abDir = AreaCompPolyHandler.GetABCookieDirection(bubblePos, bPos); CookieDirection rlDir = AreaCompPolyHandler.GetRLCookieDirection(bubblePos, bPos); switch (bump.Dir) { case Direction.East: case Direction.West: if (abDir == CookieDirection.FromBottom) { if (rlDir == CookieDirection.FromRight) { initialPoly = EntraSolver.GetPolySolution(initialPoly, new List <IntPoint>() { new IntPoint((int)bPos.X, (int)bPos.Y + 900), new IntPoint((int)bPos.X - fR, (int)bPos.Y + 900), new IntPoint((int)bPos.X - fR, (int)bPos.Y - 900), new IntPoint((int)bPos.X, (int)bPos.Y - 900) }, ClipType.ctUnion); } else { //initialPoly = EntraSolver.GetPolySolution(initialPoly, // new Polygon() // { // new IntPoint((int) bPos.X, // (int) bPos.Y - 900), // new IntPoint((int) bPos.X + fR, // (int) bPos.Y - 900), // new IntPoint((int) bPos.X + fR, // (int) bPos.Y + nR), // new IntPoint((int) bPos.X - 20, // (int) bPos.Y + nR), // new IntPoint((int) bPos.X - 20, // (int) bPos.Y + 20), // }, // ClipType.ctUnion); initialPoly = EntraSolver.GetPolySolution(initialPoly, new List <IntPoint>() { new IntPoint((int)bPos.X, (int)bPos.Y - 900), new IntPoint((int)bPos.X + fR, (int)bPos.Y - 900), new IntPoint((int)bPos.X + fR, (int)bPos.Y + 900), new IntPoint((int)bPos.X, (int)bPos.Y + 900) }, ClipType.ctUnion); } } else { // the bubble is above the bumps so don't add anything } break; case Direction.South: case Direction.North: break; case Direction.NorthWest: case Direction.SouthEast: if (abDir == CookieDirection.FromBottom) // From Right and Left are the same { initialPoly = EntraSolver.GetPolySolution(initialPoly, new List <IntPoint>() { new IntPoint((int)bPos.X, (int)bPos.Y + 900), new IntPoint((int)bPos.X - fR, (int)bPos.Y + 900), new IntPoint((int)bPos.X - fR, (int)bPos.Y - 900), new IntPoint((int)bPos.X, (int)bPos.Y - 900) }, ClipType.ctUnion); } break; case Direction.NorthEast: case Direction.SouthWest: if (abDir == CookieDirection.FromBottom) // From Right and Left are the same { //var poly = new Polygon() // { // new IntPoint((int) bPos.X, (int) bPos.Y - 900), // new IntPoint((int) bPos.X + fR, // (int) bPos.Y - 900), // new IntPoint((int) bPos.X + fR, (int) bPos.Y), // new IntPoint((int) bPos.X, (int) bPos.Y), // }; //EntraDrawer.DrawIntoFile(poly); //initialPoly = EntraSolver.GetPolySolution(initialPoly, // poly, // ClipType.ctUnion); var poly = new List <IntPoint>() { new IntPoint((int)bPos.X, (int)bPos.Y - 900), new IntPoint((int)bPos.X + fR, (int)bPos.Y - 900), new IntPoint((int)bPos.X + fR, (int)bPos.Y + 900), new IntPoint((int)bPos.X, (int)bPos.Y + 900), }; initialPoly = EntraSolver.GetPolySolution(initialPoly, poly, ClipType.ctUnion); EntraDrawer.DrawIntoFile(poly); } break; default: throw new ArgumentOutOfRangeException(); } } }