示例#1
0
        private BubbleService AddBubbleToEngine()
        {
            BubbleService bubbleService = DefaultAdder.GetDefaultBubble(new Vector2(mouseState.X, mouseState.Y));

            StaticData.EngineManager.BubbleManagerEngine.AddNewService(bubbleService);
            return(bubbleService);
        }
示例#2
0
        public static List <IntPoint> GetBubblePoly(BubbleService service)
        {
            Vector2 posCenter = service.PositionXNACenter;
            float   xUL, xUR, xBL, xBR, yUL, yUR, yBL, yBR;

            xUL = posCenter.X - 20;
            yUL = posCenter.Y - 900;

            xUR = posCenter.X + 30;
            yUR = posCenter.Y - 900;

            xBR = posCenter.X + 30;
            yBR = posCenter.Y + 900;

            xBL = posCenter.X - 30;
            yBL = posCenter.Y + 900;

            return(new List <IntPoint>()
            {
                new IntPoint((int)xUL, (int)yUL),
                new IntPoint((int)xUR, (int)yUR),
                new IntPoint((int)xBR, (int)yBR),
                new IntPoint((int)xBL, (int)yBL)
            });
        }
        public static string GetAllBubblesCatchedAndVoidProlog(List <Point> listOfInterest)
        {
            String allServicesString = String.Empty;

            for (int i = 0; i < StaticData.EngineManager.BubbleManagerEngine.ListOfServices.Count; i++)
            {
                String        currentString = String.Empty;
                BubbleService cBubble       = StaticData.EngineManager.BubbleManagerEngine.ListOfServices[i];
                if (IsInList(listOfInterest, cBubble.PositionXNACenter.X, cBubble.PositionXNACenter.Y))
                {
                    if (cBubble.IsCookieCatched)
                    {
                        currentString = "bubble_catched(" + cBubble.Id + ", " + cBubble.PositionXNACenter.X +
                                        ", " + cBubble.PositionXNACenter.Y + ").";
                        allServicesString += currentString + Environment.NewLine;
                    }
                    else
                    {
                        currentString = "bubble_void(" + cBubble.Id + ", " + cBubble.PositionXNACenter.X +
                                        ", " + cBubble.PositionXNACenter.Y + ").";
                        allServicesString += currentString + Environment.NewLine;
                    }
                }
            }
            return(allServicesString);
        }
示例#4
0
        public static BubbleService CatchBubble()
        {
            MouseState    mouseState    = Mouse.GetState();
            Vector2       mousePosition = new Vector2(mouseState.X, mouseState.Y);
            BubbleService bubble        = CatchBubbleServiceForRigidBody(mousePosition);

            if (bubble != null)
            {
                return(bubble);
            }
            return(null);
        }
示例#5
0
        private void AddBlowersEffect(ref List <List <IntPoint> > initialPoly)
        {
            BubbleService bubbleService = this.CompObj as BubbleService;
            Vector2       bubblePos     = bubbleService.PositionXNACenter;

            foreach (BlowerService blowerService in this.EntraAgentSimple.EngineState.BlowerManagerEngine.ListOfServices)
            {
                if (bubbleService.PositionXNACenter.Y > blowerService.PositionXNACenter.Y - 40)
                {
                    if (Math.Abs(bubbleService.PositionXNACenter.X - blowerService.PositionXNACenter.X) <
                        StaticData.BlowerEffectAreaRadius)
                    {
                        if (HelperModules.GenericHelperModule.InDirectionOf(blowerService.PositionXNACenter, bubblePos,
                                                                            blowerService.Dir))
                        {
                            switch (blowerService.Dir)
                            {
                            case Direction.East:
                                initialPoly.Add(new List <IntPoint>()
                                {
                                    new IntPoint((int)bubblePos.X,
                                                 (int)bubblePos.Y - StaticData.LevelFarHeight),
                                    new IntPoint((int)bubblePos.X + StaticData.BubbleWithBlowerRange,
                                                 (int)bubblePos.Y - StaticData.LevelFarHeight),
                                    new IntPoint((int)bubblePos.X + StaticData.BubbleWithBlowerRange,
                                                 (int)bubblePos.Y + StaticData.LevelFarHeight),
                                    new IntPoint((int)bubblePos.X,
                                                 (int)bubblePos.Y + StaticData.LevelFarHeight),
                                });
                                break;

                            case Direction.West:
                                initialPoly.Add(new List <IntPoint>()
                                {
                                    new IntPoint((int)bubblePos.X - StaticData.BubbleWithBlowerRange,
                                                 (int)bubblePos.Y - StaticData.LevelFarHeight),
                                    new IntPoint((int)bubblePos.X,
                                                 (int)bubblePos.Y - StaticData.LevelFarHeight),
                                    new IntPoint((int)bubblePos.X,
                                                 (int)bubblePos.Y + StaticData.LevelFarHeight),
                                    new IntPoint((int)bubblePos.X - StaticData.BubbleWithBlowerRange,
                                                 (int)bubblePos.Y + StaticData.LevelFarHeight),
                                });
                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                            }
                        }
                    }
                }
            }
        }
        public static string GetAllBubblesPositionsOnly()
        {
            String allServicesString = String.Empty;

            for (int i = 0; i < StaticData.EngineManager.BubbleManagerEngine.ListOfServices.Count; i++)
            {
                String        currentString = String.Empty;
                BubbleService cBubble       = StaticData.EngineManager.BubbleManagerEngine.ListOfServices[i];
                currentString      = "bubble(" + cBubble.PositionXNA.X + ", " + cBubble.PositionXNA.Y + ").";
                allServicesString += currentString + Environment.NewLine;
            }
            return(allServicesString);
        }
示例#7
0
 public override void ExcecuteAction()
 {
     try
     {
         BubbleService bubbleService = StaticData.EngineManager.BubbleManagerEngine.GetService(this.Id);
         if (bubbleService != null)
         {
             BubblePinched           = bubbleService;
             bubbleService.IsClicked = true;
         }
     }
     catch (Exception)
     {
     }
 }
        private bool IsActionOnComponent(Component component, Action action)
        {
            switch (action.AType)
            {
            case ActionType.BlowerPress:
            {
                Blower        item    = ((Blower)component);
                BlowerService service = ((BlowerPress)action).BlowerPressed;
                return(item.X == service.PositionXNA.X && item.Y == service.PositionXNA.Y);
            }
            break;

            case ActionType.RopeCut:
            {
                Rope          item    = ((Rope)component);
                SpringService service = ((RopeCut)action).RopeBeingCut;
                return(item.X == service.Masses[0].PositionXNA.X && item.Y == service.Masses[0].PositionXNA.Y);
            }
            break;

            case ActionType.VoidAction:
                break;

            case ActionType.BubblePinch:
            {
                Bubble        item    = ((Bubble)component);
                BubbleService service = ((BubblePinch)action).BubblePinched;
                return(item.X == service.PositionXNAInitial.X && item.Y == service.PositionXNAInitial.Y);
            }
            break;

            case ActionType.TerminateBranch:
                break;

            case ActionType.RocketPress:
            {
                Rocket item = ((Rocket)component);
                RocketCarrierService service = ((RocketPress)action).RocketPressed;
                return(item.X == service.PositionXNAInitial.X && item.Y == service.PositionXNAInitial.Y);
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(false);
        }
        public static string GetAllBubblesGEVA(List <Visual2D> comps)
        {
            String allServicesString = String.Empty;

            for (int i = 0; i < StaticData.EngineManager.BubbleManagerEngine.ListOfServices.Count; i++)
            {
                String        currentString = String.Empty;
                BubbleService cBubble       = StaticData.EngineManager.BubbleManagerEngine.ListOfServices[i];
                if (comps.Contains(cBubble))
                {
                    currentString = "bubble(" + cBubble.Id + ", " + cBubble.PositionXNA.X +
                                    ", " + cBubble.PositionXNA.Y + ").";
                    allServicesString += currentString + Environment.NewLine;
                }
            }
            return(allServicesString);
        }
示例#10
0
 private void ManipulateAddingBubbles()
 {
     if (mouseState.LeftButton == ButtonState.Pressed)
     {
         if (_bubble == null)
         {
             _bubble = AddBubbleToEngine();
         }
     }
     else
     {
         if (_bubble != null && mouseState.LeftButton == ButtonState.Released)
         {
             _bubble = null;
         }
     }
 }
示例#11
0
 public List <IntPoint> GetDefBubblePoly(BubbleService service)
 {
     return(DefinitiveCompPolyHandler.GetDefComponentIntersection(service.PositionXNACenter,
                                                                  service.Width));
 }
示例#12
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();
                }
            }
        }