Example #1
0
 public override void ExcecuteAction()
 {
     try
     {
         if (Id == -1)
         {
             // Find nearest blower to the cookie and blow it up!
             BlowerService blowerService =
                 RigidsHelperModule.CatchNearestVisual2D(StaticData.EngineManager.CookieRB,
                                                         StaticData.EngineManager.BlowerManagerEngine
                                                         .ListOfServices.Select(
                                                             blower => (Visual2D)blower).ToList(),
                                                         1000) as BlowerService;
             if (blowerService != null)
             {
                 BlowerPressed = blowerService;
                 // blow it
                 blowerService.AddForceToCookie();
             }
         }
         else
         {
             BlowerService blowerService = StaticData.EngineManager.BlowerManagerEngine.GetService(this.Id);
             if (blowerService != null)
             {
                 BlowerPressed = blowerService;
                 blowerService.AddForceToCookie();
             }
         }
     }
     catch (Exception)
     {
     }
 }
Example #2
0
        private BlowerService AddBlowersToEngine()
        {
            Direction     bDir          = Direction.East;
            BlowerService blowerService = new BlowerService(new Vector3(mouseState.X, mouseState.Y, 0), bDir);

            StaticData.EngineManager.BlowerManagerEngine.AddNewService(blowerService);
            return(blowerService);
        }
        public static string GetAllBlowersPositionsOnly()
        {
            String allBlowersString = String.Empty;

            for (int i = 0; i < StaticData.EngineManager.BlowerManagerEngine.ListOfServices.Count; i++)
            {
                String        currentBlowerString = String.Empty;
                BlowerService cBlower             = StaticData.EngineManager.BlowerManagerEngine.ListOfServices[i];
                currentBlowerString = "blower(" + cBlower.PositionXNA.X + ", " + cBlower.PositionXNA.Y + ").";
                allBlowersString   += currentBlowerString + Environment.NewLine;
            }
            return(allBlowersString);
        }
Example #4
0
        public static List <IntPoint> GetBlowerPoly(BlowerService service, int distEffect = StaticData.BubbleWithBlowerRange)
        {
            Vector2 posCenter = service.PositionXNACenter;
            float   xUL, xUR, xBL, xBR, yUL, yUR, yBL, yBR;

            xUL = xUR = xBL = xBR = yUL = yUR = yBL = yBR = 0;
            int verticalGravity = 30;
            int closeBorder     = 30;

            switch (service.Dir)
            {
            case Direction.East:
                xUL = posCenter.X;
                yUL = posCenter.Y;

                xUR = posCenter.X + distEffect;
                yUR = posCenter.Y + verticalGravity;

                xBR = xUR;
                yBR = yUR + StaticData.LevelFarHeight;

                xBL = xUL;
                yBL = yUL + StaticData.LevelFarHeight;
                break;

            case Direction.West:
                xUL = posCenter.X - distEffect;
                yUL = posCenter.Y + verticalGravity;

                xUR = posCenter.X;
                yUR = posCenter.Y;

                xBR = xUR;
                yBR = yUR + StaticData.LevelFarHeight;

                xBL = xUL;
                yBL = yUL + StaticData.LevelFarHeight;
                break;

            default:
                break;
            }

            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)
            });
        }
Example #5
0
        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 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 GetAllBlowersGEVA(List <Visual2D> comps)
        {
            String allBlowersString = String.Empty;

            for (int i = 0; i < StaticData.EngineManager.BlowerManagerEngine.ListOfServices.Count; i++)
            {
                String        currentBlowerString = String.Empty;
                BlowerService cBlower             = StaticData.EngineManager.BlowerManagerEngine.ListOfServices[i];
                if (comps.Contains(cBlower))
                {
                    currentBlowerString = "blower(" + cBlower.PositionXNA.X + ", " + cBlower.PositionXNA.Y + ", " +
                                          (int)cBlower.Dir + ").";
                    allBlowersString += currentBlowerString + Environment.NewLine;
                }
            }
            return(allBlowersString);
        }
Example #8
0
 private void ManipulateAddingBlowers()
 {
     if (mouseState.LeftButton == ButtonState.Pressed)
     {
         if (_blower == null)
         {
             _blower = AddBlowersToEngine();
         }
     }
     else
     {
         if (_blower != null && mouseState.LeftButton == ButtonState.Released)
         {
             _blower = null;
         }
     }
 }
        public static string GetAllBlowersProlog(List <Point> listOfInterest)
        {
            String allBlowersString = String.Empty;

            for (int i = 0; i < StaticData.EngineManager.BlowerManagerEngine.ListOfServices.Count; i++)
            {
                String        currentBlowerString = String.Empty;
                BlowerService cBlower             = StaticData.EngineManager.BlowerManagerEngine.ListOfServices[i];
                if (IsInList(listOfInterest, cBlower.PositionXNACenter.X, cBlower.PositionXNACenter.Y))
                {
                    currentBlowerString = "blower(" + cBlower.PositionXNACenter.X + ", " + cBlower.PositionXNACenter.Y +
                                          ", " +
                                          (int)cBlower.Dir + ").";
                    allBlowersString += currentBlowerString + Environment.NewLine;
                }
            }
            return(allBlowersString);
        }