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 List <List <IntPoint> > IntersectWithPlanes(Vector2 compPos, Vector2 rP1, Vector2 rP2)
        {
            List <List <IntPoint> > result = new List <List <IntPoint> >();
            Vector2 rPosCenter             = new Vector2((rP1.X + rP2.X) / 2, (rP1.Y + rP2.Y) / 2);

            for (int i = 0; i < 7; i += 2)
            {
                var planeDir = (Direction)i;
                if (CompIsOnDirToBump(compPos, rPosCenter, planeDir))
                {
                    Vector2 planeP1, planeP2;
                    GetPlanePoints(planeDir, out planeP1, out planeP2);
                    List <Vector2> shadowPoints = GetIntersection(compPos, rP1, rP2, planeP1, planeP2);

                    SetCenterPoint(shadowPoints);
                    shadowPoints.Sort(ClockwiseSorter);
                    //if (IsGoodPoly(compPos, cDir))
                    var poly = PolysHelper.BuildPolygon(shadowPoints);
                    EntraDrawer.DrawIntoFile(new List <List <IntPoint> >()
                    {
                        poly
                    });
                    result.Add(poly);
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        private static void RunEntraAgent(string[] args)
        {
            IsTestingEntra = true;
            GenManager.GenerateGevaLevel(args, StaticData.EntraImageInput);
            EntraAgentSimple entraAgentSimple = new EntraAgentSimple();
            var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);

            EntraDrawer.DrawIntoFileTesting(res.ReachableSpace);
        }
Exemplo n.º 4
0
        public Bitmap RunEntraAgent(EngineManager engineState, out EntraResult eRes)
        {
            this.EntraAgentSimple = new EntraAgentSimple();
            eRes = this.EntraAgentSimple.CheckPlayability(engineState);
            Bitmap b = EntraDrawer.GetPolyOnlyBitmap(eRes);

            if (StaticData.IsEntraPathActivated)
            {
                StaticData.EngineManager.EntraPathManager.RunAgent();
            }
            return(b);
        }
Exemplo n.º 5
0
        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);

            this.EntraAgentSimple.PolysLogger.Log(new PolyLog(this, initialPoly, adder));
            result = EntraSolver.GetPolySolution(initialPoly, spaceSoFar, ClipType.ctUnion);
            EntraDrawer.DrawIntoFile(result);
            return(result);
        }
Exemplo n.º 6
0
 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);
         }
     }
 }
Exemplo n.º 7
0
        public static void ShowTestResult(String[] args)
        {
            GenManager.GenerateGevaLevel(args, StaticData.EntraImageInput);

            //EngineShotsManager shots = new EngineShotsManager();
            //shots.TakeEngineShot(StaticData.EntraImageInput);

            EntraAgentSimple entraAgentSimple = new EntraAgentSimple();
            var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);

            EntraDrawer.DrawIntoFileTesting(res.ReachableSpace);

            EntraPathAgent pathAgent = new EntraPathAgent(entraAgentSimple);

            pathAgent.DrawPaths();
        }
Exemplo n.º 8
0
        public static void PrintEffetivceSpace(String[] args, bool withLevelImage, int i)
        {
            if (withLevelImage)
            {
                String strImage = StaticData.EntraImageInput;
                GenManager.GenerateGevaLevel(args, strImage);
                EntraAgentSimple entraAgentSimple = new EntraAgentSimple();

                var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);
                EntraDrawer.DrawIntoFileGeva(res.ReachableSpace, true, i);
            }
            else
            {
                GenManager.GenerateGevaLevel(args, null);
                EntraAgentSimple entraAgentSimple = new EntraAgentSimple();

                var res = entraAgentSimple.CheckPlayability(StaticData.EngineManager);
                EntraDrawer.DrawIntoFileGeva(res.ReachableSpace, false, i);
            }
        }
Exemplo n.º 9
0
        private List <List <IntPoint> > ApplyMe(List <List <IntPoint> > spaceSoFar,
                                                List <CompEntityPoly> newAdders,
                                                bool withAdd = true)
        {
            List <List <IntPoint> > result = spaceSoFar;

            EntraDrawer.DrawIntoFile(result);

            AddNewAdders(newAdders);

            var bumperDelPolys = this.GetDelPolys(_adders) ?? new List <List <IntPoint> >();

            EntraDrawer.DrawIntoFile(bumperDelPolys);

            ApplyDelPolysForAdders(ref result, bumperDelPolys);
            EntraDrawer.DrawIntoFile(result);

            ApplyAddPolysForAdders(ref result, bumperDelPolys, withAdd);
            EntraDrawer.DrawIntoFile(result);

            return(result);
        }
Exemplo n.º 10
0
        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);
            }
        }
Exemplo n.º 11
0
        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);
                }
                // }
            }
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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();
                }
            }
        }