예제 #1
0
 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);
 }
예제 #2
0
        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);
        }
예제 #3
0
 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);
             }
         }
     }
 }
예제 #4
0
        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);
                }
            }
        }
예제 #5
0
        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);
        }
예제 #6
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);
        }
예제 #7
0
        //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);
        }
예제 #8
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);
        }