public static string GetAllRocketsProlog(List <Point> listOfInterest)
        {
            String allServicesString = String.Empty;

            for (int i = 0; i < StaticData.EngineManager.RocketsCarrierManagerEngine.GetListOfServices().Count; i++)
            {
                String currentString         = String.Empty;
                RocketCarrierService service = StaticData.EngineManager.RocketsCarrierManagerEngine.GetListOfServices()[i];
                if (service.CanCatchCookie)
                {
                    if (IsInList(listOfInterest, service.PositionXNACenter.X, service.PositionXNACenter.Y))
                    {
                        if (!service.IsActivated)
                        {
                            currentString = "rocket_void(" + (int)service.PositionXNACenter.X + ", " +
                                            (int)service.PositionXNACenter.Y +
                                            ", " + (int)service.Dir + ").";
                            allServicesString += currentString + Environment.NewLine;
                        }
                        else
                        {
                            currentString = "rocket_catched(" + (int)service.PositionXNACenter.X + ", " +
                                            (int)service.PositionXNACenter.Y +
                                            ", " + (int)service.Dir + ").";
                            allServicesString += currentString + Environment.NewLine;
                        }
                    }
                }
            }
            return(allServicesString);
        }
示例#2
0
        private RocketCarrierService AddRocketToEngine()
        {
            RocketCarrierService rocket = new RocketCarrierService(new Vector3(mouseState.X, mouseState.Y, 0),
                                                                   Direction.East);

            StaticData.EngineManager.RocketsCarrierManagerEngine.AddNewService(rocket);
            return(rocket);
        }
        public static string GetAllRocketsPositionsOnly()
        {
            String allServicesString = String.Empty;

            for (int i = 0; i < StaticData.EngineManager.RocketsCarrierManagerEngine.GetListOfServices().Count; i++)
            {
                String currentString         = String.Empty;
                RocketCarrierService service = StaticData.EngineManager.RocketsCarrierManagerEngine.GetListOfServices()[i];
                currentString      = "rocket(" + service.PositionXNA.X + ", " + service.PositionXNA.Y + ").";
                allServicesString += currentString + Environment.NewLine;
            }
            return(allServicesString);
        }
示例#4
0
        public override void ExcecuteAction()
        {
            var rockets = StaticData.EngineManager.RocketsCarrierManagerEngine.GetListOfServices();

            foreach (var rocketCarrierService in rockets)
            {
                if (rocketCarrierService.CanCatchCookie)
                {
                    if (rocketCarrierService.IsActivated)
                    {
                        RocketPressed = rocketCarrierService;
                        rocketCarrierService.IsClicked = true;
                    }
                }
            }
        }
        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);
        }
示例#6
0
 private void ManipulateAddingRockets()
 {
     if (mouseState.LeftButton == ButtonState.Pressed)
     {
         if (_rocket == null)
         {
             _rocket = AddRocketToEngine();
         }
     }
     else
     {
         if (_rocket != null && mouseState.LeftButton == ButtonState.Released)
         {
             _rocket = null;
         }
     }
 }
        public static string GetAllRocketsGEVA()
        {
            String allServicesString = String.Empty;

            for (int i = 0; i < StaticData.EngineManager.RocketsCarrierManagerEngine.GetListOfServices().Count; i++)
            {
                String currentString         = String.Empty;
                RocketCarrierService service = StaticData.EngineManager.RocketsCarrierManagerEngine.GetListOfServices()[i];
                if (service.CanCatchCookie)
                {
                    if (!service.IsActivated)
                    {
                        currentString = "rocket(" + (int)service.PositionXNA.X + ", " + (int)service.PositionXNA.Y +
                                        ", " + (int)service.Dir + ").";
                        allServicesString += currentString + Environment.NewLine;
                    }
                }
            }
            return(allServicesString);
        }
        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);
                }
                // }
            }
        }
        public static void FindRocketTwoBorderPoints(RocketCarrierService rocket, out Vector2 p1, out Vector2 p2)
        {
            Vector2 bXNA       = rocket.PositionXNA2D;
            Vector2 bXNACenter = rocket.PositionXNACenter2D;
            int     halfWidth  = rocket.Width / 2 - 5;

            switch (rocket.Dir)
            {
            case Direction.West:
            case Direction.East:
                p1 = bXNA + new Vector2(0, rocket.Height / 2);
                p2 = bXNA + new Vector2(rocket.Width, rocket.Height / 2);
                break;

            case Direction.NorthWest:
            case Direction.SouthEast:
                p1 = bXNACenter + new Vector2(-halfWidth, -halfWidth);
                p2 = bXNACenter + new Vector2(+halfWidth, +halfWidth);
                break;

            case Direction.North:
            case Direction.South:
                p1 = bXNACenter + new Vector2(0, -halfWidth);
                p2 = bXNACenter + new Vector2(0, rocket.Width - halfWidth);
                break;

            case Direction.NorthEast:
            case Direction.SouthWest:
                p1 = bXNACenter + new Vector2(-halfWidth, +halfWidth);
                p2 = bXNACenter + new Vector2(+halfWidth, -halfWidth);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#10
0
        public static List <List <IntPoint> > GetRocketPoly(RocketCarrierService service)
        {
            Vector2 posCenter = service.PositionXNACenter2D;
            float   xUL, xUR, xBL, xBR, yUL, yUR, yBL, yBR;

            xUL = xUR = xBL = xBR = yUL = yUR = yBL = yBR = 0;

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

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

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

                xBL = posCenter.X;
                yBL = posCenter.Y + 900;
                break;

            case Direction.SouthEast:
                xUL = posCenter.X;
                yUL = posCenter.Y;

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

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

                xBL = posCenter.X;
                yBL = posCenter.Y + 900;
                break;

            case Direction.South:
                xUL = posCenter.X - 20;
                yUL = posCenter.Y - 20;

                xUR = posCenter.X + 20;
                yUR = posCenter.Y - 20;

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

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

                break;

            case Direction.SouthWest:
                xUL = posCenter.X;
                yUL = posCenter.Y;

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

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

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

            case Direction.West:
                xUL = posCenter.X - 900;
                yUL = posCenter.Y;

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

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

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

            case Direction.NorthWest:
                xUL = posCenter.X - 900;
                yUL = posCenter.Y - 900;

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

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

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

            case Direction.North:
                xUL = posCenter.X - 20;
                yUL = posCenter.Y - 900;

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

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

                xBL = posCenter.X - 20;
                yBL = posCenter.Y + 900;
                break;

            case Direction.NorthEast:
                xUL = posCenter.X;
                yUL = posCenter.Y;

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

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

                xBL = posCenter.X;
                yBL = posCenter.Y + 900;
                break;
            }
            List <List <IntPoint> > polys = new List <List <IntPoint> >()
            {
                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)
                }
            };

            ProjectionHandler.RemoveRocketsPolysIntersectionWithPlanes(service, ref polys);
            return(polys);
        }
        private static List <IntPoint> GetInverseCutPolygon(Vector2 cutP, RocketEntityPoly rocketEntityPoly)
        {
            RocketCarrierService rocket = rocketEntityPoly.CompObj as RocketCarrierService;

            return(GetInverseCutPolygon(cutP, rocket.PositionXNACenter2D));
        }
        public static void FindRocketTwoBorderPoints(RocketEntityPoly rocketEntity, out Vector2 p1, out Vector2 p2)
        {
            RocketCarrierService rocket = (rocketEntity.CompObj as RocketCarrierService);

            FindRocketTwoBorderPoints(rocket, out p1, out p2);
        }
示例#13
0
 public List <IntPoint> GetDefRocketPoly(RocketCarrierService service)
 {
     return(DefinitiveCompPolyHandler.GetDefComponentIntersection(service.PositionXNACenter2D,
                                                                  service.Width));
 }