예제 #1
0
        private static bool IsOnCutSide(BumperEntityPoly bumpRef, RopeEntityPoly ropeEntityPoly,
                                        List <List <BumperEntityPoly> > groups)
        {
            var posRope = ropeEntityPoly.PositionXNACenter2D;
            var posBump = bumpRef.PositionXNACenter2D;

            foreach (List <BumperEntityPoly> group in groups)
            {
                if (posRope.X < posBump.X)
                {
                    if (bumpRef == group[group.Count - 1])
                    {
                        return(true);
                    }
                }
                else
                {
                    if (bumpRef == group[0])
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #2
0
 private static bool IsBumperCloseToAnother(BumperEntityPoly bumperRef, List <BumperEntityPoly> allBumps)
 {
     foreach (BumperEntityPoly bumper in allBumps)
     {
         if (bumper != bumperRef)
         {
             int dis = (int)Math.Abs(bumperRef.PositionXNACenter2D.X - bumper.PositionXNACenter2D.X);
             if (dis < 100)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
예제 #3
0
        private static BumperEntityPoly FindCutSideBumper(BumperEntityPoly bumpRef, RopeEntityPoly ropeEntityPoly,
                                                          List <List <BumperEntityPoly> > groups)
        {
            var posRope = ropeEntityPoly.PositionXNACenter2D;
            var posBump = bumpRef.PositionXNACenter2D;

            foreach (List <BumperEntityPoly> group in groups)
            {
                if (group.Contains(bumpRef))
                {
                    if (posRope.X < posBump.X)
                    {
                        return(group[group.Count - 1]);
                    }
                    else
                    {
                        return(group[0]);
                    }
                }
            }
            return(null);
        }
예제 #4
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);
        }