public bool IsOperation(PolyLog ppLog, PolyLog pLog, ClipType ctOperation) { foreach (APPair aP in pLog.ApPairs) { if (aP.AdderComp == this.Comp) { //foreach (APPair apPairThis in this.ApPairs) if (ppLog != null) { foreach (APPair aPP in ppLog.ApPairs) { if (EntraSolver.IsPolyOperation(aP.Poly, aPP.Poly, ClipType.ctIntersection)) { //if (EntraSolver.IsPolyOperation(apPairParent.Poly, apPairThis.Poly, ClipType.ctIntersection)) return(true); } //EntraDrawer.DrawIntoFileTesting(aPP.Poly); //EntraDrawer.DrawIntoFileTesting(aP.Poly); } } else { // Frog return(true); } } } return(false); }
public static void ReAddBlowerBubbleRopeTrajectoryMissingAreas(Vector2 posComp, BumperEntityPoly bumperEntity, ref List <List <IntPoint> > delPolys) { var bumpRigid = bumperEntity.CompObj as BumpRigid; var bumpPosXNA = bumpRigid.PositionXNA2D; var bumpPosCenter = bumpRigid.PositionXNACenter2D; Vector2 bP1, bP2; ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2); Vector2 cP1 = posComp, cP2 = posComp; Vector2 interP; MathHelperModule.FindIntersection(bP1, bP2, cP1, cP2, out interP); Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2, posComp); if (!RigidsHelperModule.IsCloseEnough(interP, (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D, 20)) { List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, posComp); EntraDrawer.DrawIntoFile(new List <List <IntPoint> >() { polyInverseCutVertical }); EntraDrawer.DrawIntoFile(delPolys); delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection); EntraDrawer.DrawIntoFile(delPolys); } }
private void ApplyDelPolysForAdders(ref List <List <IntPoint> > result, List <List <IntPoint> > bumperDelPolys) { // Fix log RemoveDelPolyFromEveryLogInSpace(bumperDelPolys, _adders); result = EntraSolver.GetPolySolution(result, bumperDelPolys, ClipType.ctDifference); }
public static void ReAddInverseCutPolygon(Vector2 posComp, BumperEntityPoly bumperEntity, ref List <List <IntPoint> > delPolys) { var bumpRigid = bumperEntity.CompObj as BumpRigid; var bumpPosXNA = bumpRigid.PositionXNA2D; var bumpPosCenter = bumpRigid.PositionXNACenter2D; Vector2 bP1, bP2; ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2); Vector2 cP1 = posComp, cP2 = posComp; Vector2 interP; MathHelperModule.FindIntersection(bP1, bP2, cP1, cP2, out interP); Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2, posComp); if (!RigidsHelperModule.IsCloseEnough(interP, (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D, 20)) // if the bump is not on the collision course with the rocket { // Rocket is not on a collision course with the bump, so cut down the del poly area vertically List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, posComp); delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection); } }
//private List<List<IntPoint>> GetDelPolysIntersection(List<List<IntPoint>> allDelPolys) //{ // if (allDelPolys.Count > 0) // { // List<List<IntPoint>> interPoly = new List<List<IntPoint>>(); // var first = allDelPolys.First(); // if (allDelPolys.Count == 1) // { // return new List<List<IntPoint>>() { first }; // } // else // { // allDelPolys.RemoveAt(0); // //EntraDrawer.DrawIntoFile(new Polygons(){first}); // //EntraDrawer.DrawIntoFile(allDelPolys); // var unions = EntraSolver.GetPolyUnions(allDelPolys); // interPoly = EntraSolver.GetPolySolution(first, unions, ClipType.ctIntersection); // return interPoly; // } // } // return null; //} public static List <List <IntPoint> > GetDelPolysIntersection(List <List <IntPoint> > allDelPolys) { if (allDelPolys.Count > 1) { List <List <IntPoint> > interPoly = new List <List <IntPoint> >(); var first = allDelPolys.First(); allDelPolys.RemoveAt(0); var unions = EntraSolver.GetPolyUnions(allDelPolys); interPoly = EntraSolver.GetPolySolution(first, unions, ClipType.ctIntersection); return(interPoly); } else { if (allDelPolys.Count == 1) { return(new List <List <IntPoint> >() { allDelPolys.First() }); } else { return(null); } } }
public static List <List <IntPoint> > GetRopePoly(SpringService service, EngineManager engineManager) { int verticalLineLength, halfFarWidth; SetProperHalfFarWidth(service, engineManager.CookieRB, out verticalLineLength, out halfFarWidth); var polySemiCircle = PolysHelper.GetShapeSemiCirclePoly(service.Masses[0].PositionXNACenter2D, ropeNearWidth, verticalLineLength, halfFarWidth); List <IntPoint> polyAdded = GetAddedGravityRectanglePoly(service, engineManager); var polyFinal = EntraSolver.GetPolySolution(polySemiCircle, polyAdded, ClipType.ctUnion); // Cut upper rectangle int cY = (int)StaticData.EngineManager.CookieRB.PositionXNACenter2D.Y; List <IntPoint> poly = new List <IntPoint>() { new IntPoint(0, 0), new IntPoint(StaticData.LevelFarWidth, 0), new IntPoint(StaticData.LevelFarWidth, cY), new IntPoint(0, cY), }; polyFinal = EntraSolver.GetPolySolution(polyFinal, poly, ClipType.ctDifference); return(polyFinal); }
public void SetOpennerNonOpenner(List <List <IntPoint> > spaceSoFar, List <CompEntityPoly> allEntitiesList, List <BumperEntityPoly> rBumpers) { var rCompsAllNew = _entraAgentSimple.AreaCompPolyHandler.GetReachServicePolys(spaceSoFar, allEntitiesList); All = rCompsAllNew.Where(comp => comp is RocketEntityPoly).Cast <RocketEntityPoly>().ToList(); // Find Openner Openners = new List <RocketEntityPoly>(); CollidedBumpers = new List <BumperEntityPoly>(); foreach (RocketEntityPoly rocketEntity in All) { bool collision = false; foreach (CompEntityPoly bumperEntity in rBumpers) { var sol = EntraSolver.GetPolySolution(bumperEntity.GetDefPoly(), rocketEntity.GetAreaPoly(), ClipType.ctIntersection); if (sol.Count > 0) { CollidedBumpers.Add(bumperEntity as BumperEntityPoly); collision = true; } } if (!collision) { Openners.Add(rocketEntity); } } }
//public bool IsOperation(PolyLog parentLog, ClipType ctOperation) //{ // List<List<IntPoint>> thisPolysUnion = GetPolysUnion(this.ApPairs); // List<List<IntPoint>> parentPolysUnion = GetPolysUnion(parentLog.ApPairs); // //EntraDrawer.DrawIntoFileTesting(thisPolysUnion); // //EntraDrawer.DrawIntoFileTesting(parentPolysUnion); // if (EntraSolver.IsPolyOperation(thisPolysUnion, parentPolysUnion, ClipType.ctIntersection)) // { // //if (parentLog.Comp is BumperEntityPoly) // { // foreach (APPair apPair in parentLog.ApPairs) // { // if (apPair.AdderComp == this.Comp) // { // return true; // } // } // } // //else // //{ // // if (parentLog.ApPairs[0].AdderComp == this.Comp) // // { // // return true; // // } // //} // } // return false; //} private List <List <IntPoint> > GetPolysUnion(List <APPair> polys) { var res = new List <List <IntPoint> >(); foreach (APPair apPair in polys) { res = EntraSolver.GetPolySolution(res, apPair.Poly, ClipType.ctUnion); } return(res); }
public override List <List <IntPoint> > ApplyEffect(List <List <IntPoint> > spaceSoFar, CompEntityPoly adder) { var initialPoly = this.GetAreaPoly(); this.EntraAgentSimple.PolysLogger.Log(new PolyLog(this, initialPoly, null)); var result = EntraSolver.GetPolySolution(initialPoly, spaceSoFar, ClipType.ctUnion); return(result); }
public override List <List <IntPoint> > ApplyEffect(List <List <IntPoint> > spaceSoFar, CompEntityPoly adder) { List <List <IntPoint> > result = new List <List <IntPoint> >(); var initialPoly = this.GetAreaPoly(); //BumpersHandler.ReAddNewlyAddedBumpsAreas(ref initialPoly, this); this.EntraAgentSimple.PolysLogger.Log(new PolyLog(this, initialPoly, adder)); result = EntraSolver.GetPolySolution(initialPoly, spaceSoFar, ClipType.ctUnion); EntraDrawer.DrawIntoFile(result); return(result); }
public static bool IsDefComponentIntersection(Vector2 posCenter, int width, List <List <IntPoint> > polys) { List <IntPoint> poly = PolysHelper.GetShapeSquarePoly(posCenter, width / 2); if (EntraSolver.IsPolyOperation(new List <List <IntPoint> >() { poly }, polys, ClipType.ctIntersection)) { return(true); } return(false); }
private void InitializeFrogPoly() { _frogPolyLog = new PolyLog(_frog); foreach (PolyLog polyLog in _log) { foreach (APPair apPair in polyLog.ApPairs) { if (EntraSolver.IsPolyOperation(_frog.GetDefPoly(), apPair.Poly, ClipType.ctIntersection)) { _frogPolyLog.AddPoly(_frog.GetDefPoly(), polyLog.Comp); } } } }
private void ClipPolygonsFromBorders(ref List <List <IntPoint> > polys) { if (polys != null) { if (polys.Count > 0) { // Clip with four borders for (int i = 0; i < 7; i += 2) { List <IntPoint> poly = GetPlanePolygon((Direction)i); polys = EntraSolver.GetPolySolution(polys, poly, ClipType.ctDifference); } } } }
public void ReAddCoveredBumpsToBeProcessed(ref List <List <IntPoint> > initialPoly, List <List <IntPoint> > spaceSoFar, CRUSTEngine.ProjectEngines.PCGEngine.PlayabilityManagers.EntraPlay.EntraAgentSimple entraAgentSimple) { List <BumperEntityPoly> rBumpers = entraAgentSimple.BumpersHandler.GetReachableBumpers(spaceSoFar, entraAgentSimple.AllCompsEntities); foreach (BumperEntityPoly bumperEntityPoly in rBumpers) { if (EntraSolver.IsPolyOperation(this.GetAreaPoly(), bumperEntityPoly.GetDefPoly(), ClipType.ctIntersection)) { //this.EntraAgentSimple.BumpersHandler.processedBumps.Remove(bumperEntityPoly); } } }
public static List <List <IntPoint> > GetDefBlowerPoly(BlowerService blower) { //return PolysHelper.GetShapeSquarePoly(blower.PositionXNACenter, (blower.Height + 50)/2); var res = AreaCompPolyHandler.GetBlowerPoly((BlowerService)blower, StaticData.BlowerEffectAreaRadius); List <IntPoint> polyCut = new List <IntPoint>() { new IntPoint(-1000, (int)blower.PositionXNA.Y + StaticData.BlowerEffectAreaRadius), new IntPoint(+1000, (int)blower.PositionXNA.Y + StaticData.BlowerEffectAreaRadius), new IntPoint(+1000, 1000), new IntPoint(-1000, 1000), }; return(EntraSolver.GetPolySolution(res, polyCut, ClipType.ctDifference)); }
private void ApplyAddPolysForAdders(ref List <List <IntPoint> > result, List <List <IntPoint> > bumperDelPolys, bool withAdd) { if (withAdd) { foreach (CompEntityPoly adder in _adders) { var bumpAddPoly = this.GetAreaPoly(adder); EntraDrawer.DrawIntoFile(bumpAddPoly); bumpAddPoly = EntraSolver.GetPolySolution(bumpAddPoly, bumperDelPolys, ClipType.ctDifference); AddToLog(bumpAddPoly, adder); EntraDrawer.DrawIntoFile(bumpAddPoly); result = EntraSolver.GetPolySolution(result, bumpAddPoly, ClipType.ctUnion); } } }
public bool IsComponentsOverlapping() { var ovlpedPairs = new List <KeyValuePair <List <IntPoint>, List <IntPoint> > >(); //String[] args = new string[2]; //args[1] = this.LevelStr; //GenManager.GenerateGevaLevel(args, null); OverlappedComponents = 0; DefinitiveCompPolyHandler def = new DefinitiveCompPolyHandler(StaticData.EngineManager); List <List <IntPoint> > polys = new List <List <IntPoint> >(); polys.AddRange(def.GetDefBubblesPolys()); polys.AddRange(def.GetDefRocketsPolys()); polys.AddRange(def.GetDefBumpersPolys()); foreach (BlowerService blowerService in StaticData.EngineManager.BlowerManagerEngine.ListOfServices) { polys.Add(PolysHelper.GetShapeSquarePoly(blowerService.PositionXNACenter, (int)StaticData.BlowerDimWidth / 2)); } for (int i = 0; i < polys.Count - 1; i++) { var polyNow = polys[i]; for (int j = i + 1; j < polys.Count; j++) { var polyCompare = polys[j]; if (polyNow != polyCompare) { if (EntraSolver.IsPolyOperation(polyCompare, polyNow, ClipType.ctIntersection)) { //List<KeyValuePair<List<IntPoint>, List<IntPoint>>> var res = (from kv in ovlpedPairs where (kv.Key == polyCompare && kv.Value == polyNow) || (kv.Key == polyNow && kv.Value == polyCompare) select kv).ToList(); if (res != null) { ovlpedPairs.Add(new KeyValuePair <List <IntPoint>, List <IntPoint> >(polyNow, polyCompare)); OverlappedComponents++; } } } } } return(OverlappedComponents != 0); }
public static List <BumperEntityPoly> GetCoveredBumpers(CompEntityPoly entity, List <List <IntPoint> > initialPoly) { List <BumperEntityPoly> coveredBumps = new List <BumperEntityPoly>(); List <BumperEntityPoly> rBumpers = entity.EntraAgentSimple.BumpersHandler.GetReachableBumpers(initialPoly, entity.EntraAgentSimple .AllCompsEntities); foreach (BumperEntityPoly bumper in rBumpers) { if (EntraSolver.IsPolyOperation(initialPoly, bumper.GetDefPoly(), ClipType.ctIntersection)) { coveredBumps.Add(bumper); } } return(coveredBumps); }
public override List <List <IntPoint> > ApplyEffect(List <List <IntPoint> > spaceSoFar, CompEntityPoly adder) { List <List <IntPoint> > result = new List <List <IntPoint> >(); var initialPoly = this.GetAreaPoly(); EntraDrawer.DrawIntoFile(initialPoly); if (adder is BlowerEntityPoly) { AddBlowersEffect(ref initialPoly); } EntraDrawer.DrawIntoFile(initialPoly); this.EntraAgentSimple.PolysLogger.Log(new PolyLog(this, initialPoly, adder)); result = EntraSolver.GetPolySolution(initialPoly, spaceSoFar, ClipType.ctUnion); EntraDrawer.DrawIntoFile(result); return(result); }
private void RemoveDelPolyFromEveryLogInSpace(List <List <IntPoint> > bumperDelPolys, List <CompEntityPoly> adders) { List <PolyLog> polys = this.EntraAgentSimple.PolysLogger.GetLog(); foreach (PolyLog polyLog in polys) { foreach (CompEntityPoly adder in adders) { if (polyLog.Comp == adder) { foreach (APPair apPair in polyLog.ApPairs) { apPair.Poly = EntraSolver.GetPolySolution(apPair.Poly, bumperDelPolys, ClipType.ctDifference); } } } } }
//public Polygons GetReachBumpersPolys(Polygons allCompsPolys) //{ // Polygons allPolys = new Polygons(); // List<BumpRigid> bumpers = _engineState.RigidsManagerEngine. // ListOfBoxRigids.Where(item => item is BumpRigid).Cast<BumpRigid>() // .ToList(); // foreach (var service in bumpers) // { // Polygon poly = null; // if (DefinitiveCompsPolysHandler.IsDefComponentIntersection( // service.PositionXNACenter2D, service.Width, allCompsPolys)) // poly = GetBumperPoly(service); // allPolys.Add(poly); // } // return allPolys; //} //public Polygons GetReachBlowersPolys(Polygons allCompsPolys) //{ // Polygons allPolys = new Polygons(); // foreach (var service in _engineState.BlowerManagerEngine.ListOfServices) // { // Polygon poly = GetBlowerPoly(service); // if (EntraSolver.IsPolyOperation(new Polygons() { poly }, allCompsPolys, ClipType.ctIntersection)) // { // allPolys.Add(poly); // } // } // return allPolys; //} //public Polygons GetReachBubblesPolys(Polygons allCompsPolys) //{ // Polygons allPolys = new Polygons(); // foreach (var service in _engineState.BubbleManagerEngine.ListOfServices) // { // if (DefinitiveCompsPolysHandler.IsDefComponentIntersection( // service.PositionXNACenter, service.Width, allCompsPolys)) // { // Polygon poly = GetBubblePoly(service); // allPolys.Add(poly); // } // } // return allPolys; //} //public Polygons GetReachRocketsPolys(Polygons allCompsPolys) //{ // Polygons allPolys = new Polygons(); // foreach (var service in _engineState.RocketsCarrierManagerEngine.GetListOfServices()) // { // if (DefinitiveCompsPolysHandler.IsDefComponentIntersection( // service.PositionXNACenter2D, service.Width, allCompsPolys)) // { // Polygon poly = GetRocketPoly(service); // allPolys.Add(poly); // } // } // return allPolys; //} #endregion public List <CompEntityPoly> GetReachServicePolys(List <List <IntPoint> > spaceSoFar, List <CompEntityPoly> entityList) { List <CompEntityPoly> allPolys = new List <CompEntityPoly>(); //EntraDrawer.DrawIntoFileTesting(spaceSoFar); foreach (var entity in entityList) { //EntraDrawer.DrawIntoFileTesting(entity.GetDefPoly()); //EntraDrawer.DrawIntoFile(entity.GetDefPoly()); //EntraDrawer.DrawIntoFile(allCompsPolys); //var p = EntraSolver.GetPolySolution(entity.GetDefPoly(), allCompsPolys, ClipType.ctIntersection); //EntraDrawer.DrawIntoFile(p); if (EntraSolver.IsPolyOperation(entity.GetDefPoly(), spaceSoFar, ClipType.ctIntersection)) { allPolys.Add(entity); } } return(allPolys); }
public List <List <IntPoint> > ApplyCloseBumpersFix(List <BumperEntityPoly> rBumpers, List <List <IntPoint> > spaceSoFar, out List <BumperEntityPoly> bumpersOfGroups) { bumpersOfGroups = new List <BumperEntityPoly>(); List <List <BumperEntityPoly> > closeGroups = GroupizeCloseBumpers(rBumpers); foreach (List <BumperEntityPoly> group in closeGroups) { foreach (BumperEntityPoly bumper in group) { spaceSoFar = EntraSolver.GetPolySolution(spaceSoFar, ((BumperEntityPoly)bumper).DelPoly, ClipType.ctDifference); } } List <BumperEntityPoly> groups = new List <BumperEntityPoly>(); closeGroups.ForEach(groups.AddRange); bumpersOfGroups = groups; return(spaceSoFar); }
public static void ReAddRocketTrajectoryMissingAreas(RocketEntityPoly rocketEntityPoly, BumperEntityPoly bumperEntity, ref List <List <IntPoint> > delPolys) { var bumpRigid = bumperEntity.CompObj as BumpRigid; var bumpPosXNA = bumpRigid.PositionXNA2D; var bumpPosCenter = bumpRigid.PositionXNACenter2D; Vector2 bP1, bP2; ProjectionHandler.FindBumperTwoBorderPoints(bumperEntity, out bP1, out bP2); Vector2 rP1, rP2; ProjectionHandler.FindRocketTwoBorderPoints(rocketEntityPoly, out rP1, out rP2); Vector2 interP; MathHelperModule.FindIntersection(bP1, bP2, rP1, rP2, out interP); Vector2 cutP = GetBumperCutStartingPoint(bumpRigid.Dir, bP1, bP2, (rocketEntityPoly.CompObj as RocketCarrierService).PositionXNACenter2D); if (!RigidsHelperModule.IsCloseEnough(interP, (bumperEntity.CompObj as BumpRigid).PositionXNACenter2D, 20)) // if the bump is not on the collision course with the rocket { // Rocket is not on a collision course with the bump, so cut down the del poly area vertically List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(cutP, rocketEntityPoly); EntraDrawer.DrawIntoFile(new List <List <IntPoint> >() { polyInverseCutVertical }); delPolys = EntraSolver.GetPolySolution(delPolys, polyInverseCutVertical, ClipType.ctIntersection); EntraDrawer.DrawIntoFile(delPolys); } }
public static void RemoveRocketsPolysIntersectionWithPlanes(RocketCarrierService rocket, ref List <List <IntPoint> > poly) { Vector2 rP1, rP2; ProjectionHandler.FindRocketTwoBorderPoints(rocket, out rP1, out rP2); Vector2 rPosCenter = new Vector2((rP1.X + rP2.X) / 2, (rP1.Y + rP2.Y) / 2); for (int i = 0; i < 7; i += 2) { var cDir = (Direction)i; //if (CompIsOnDirToBump(compPos, rPosCenter, cDir)) //{ Vector2 planeP1, planeP2; GetPlanePoints(cDir, out planeP1, out planeP2); Vector2 interP; MathHelperModule.FindIntersection(planeP1, planeP2, rP1, rP2, out interP); if (interP.X <= StaticData.LevelFarWidth && interP.X >= 0 && interP.Y <= StaticData.LevelFarHeight && interP.Y >= 0) { // Rocket is not on a collision course with the bump, // so cut down the del poly area vertically List <IntPoint> polyInverseCutVertical = GetInverseCutPolygon(interP, rocket.PositionXNACenter2D); EntraDrawer.DrawIntoFile(new List <List <IntPoint> >() { polyInverseCutVertical }); poly = EntraSolver.GetPolySolution(poly, polyInverseCutVertical, ClipType.ctIntersection); EntraDrawer.DrawIntoFile(poly); } // } } }
public static List <List <IntPoint> > GetDelPolysOfMe(BumperEntityPoly me, List <CompEntityPoly> adders) { List <List <IntPoint> > allDels = new List <List <IntPoint> >(); if (adders == null) { return(allDels); } if (adders.Count == 0) { return(allDels); } foreach (CompEntityPoly adder in adders) { if (adder != me) { //if (!(compEntityPoly is BumperEntityPoly)) { List <List <IntPoint> > newDelPolys = new List <List <IntPoint> >(); if (adder is BumperEntityPoly) { var adderBump = adder as BumperEntityPoly; if (EntraSolver.IsPolyOperation(me.GetDefPoly(), adderBump.GetAreaPoly(), ClipType.ctIntersection)) { newDelPolys = me.EntraAgentSimple.ProjectionHandler.ProjectCompOntoBumper( adderBump.PositionXNACenter2D, me); EntraDrawer.DrawIntoFile(newDelPolys); } } else { if (EntraSolver.IsPolyOperation(me.GetDefPoly(), adder.GetAreaPoly(), ClipType.ctIntersection)) { newDelPolys = me.EntraAgentSimple.ProjectionHandler.ProjectCompOntoBumper( adder.PositionXNACenter2D, me); EntraDrawer.DrawIntoFile(newDelPolys); if (adder is RocketEntityPoly) { var rocket = adder as RocketEntityPoly; ProjectionHandler.ReAddRocketTrajectoryMissingAreas( rocket, me, ref newDelPolys); var dir = (rocket.CompObj as RocketCarrierService).Dir; if (dir == Direction.North || dir == Direction.NorthEast || dir == Direction.NorthWest) { newDelPolys = new List <List <IntPoint> >(); } } else { if (adder is RopeEntityPoly) { List <BumperEntityPoly> allBumps = me.EntraAgentSimple.AllCompsEntities.FindAll(delegate(CompEntityPoly obj) { return(obj is BumperEntityPoly); }) .ConvertAll(input => input as BumperEntityPoly); List <List <BumperEntityPoly> > groups = BumpersHandler.GroupizeCloseBumpers(allBumps); if (IsBumperCloseToAnother(me, allBumps)) { if (IsOnCutSide(me, adder as RopeEntityPoly, groups) || groups.Count == 0) { ProjectionHandler.ReAddBlowerBubbleRopeTrajectoryMissingAreas( adder.PositionXNACenter2D, me, ref newDelPolys); } else { var bumperCutSide = FindCutSideBumper(me, adder as RopeEntityPoly, groups); if (bumperCutSide != null) { ProjectionHandler.ReAddInverseCutPolygon( adder.PositionXNACenter2D, bumperCutSide, ref newDelPolys); } } } else { ProjectionHandler.ReAddBlowerBubbleRopeTrajectoryMissingAreas( adder.PositionXNACenter2D, me, ref newDelPolys); } } else { ProjectionHandler.ReAddBlowerBubbleRopeTrajectoryMissingAreas( adder.PositionXNACenter2D, me, ref newDelPolys); } } } } EntraDrawer.DrawIntoFile(newDelPolys); allDels.AddRange(newDelPolys); //result = BumpersHandler.GetDelPolysIntersection(result); //if (result == null) //{ // result = new List<List<IntPoint>>(); //} } } } allDels = BumpersHandler.GetDelPolysIntersection(allDels) ?? new List <List <IntPoint> >(); return(allDels); }
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(); } } }