Example #1
0
        /// <summary>
        /// Set the Shoes's position to the position of the Guy if the collision delay timer is completed and the Guy and Shoes are not currently linked.
        /// </summary>
        /// <param name="shoes">A reference to the Shoes.</param>
        private void setShoesPositionToGuyUponCollisionIfPossible(Shoes shoes)
        {
            if (PositionRect.Intersects(shoes.PositionRect) && !delayCollisionWithShoesAndGuy && !areGuyAndShoesCurrentlyLinked)
            {
                velocity                      = new Vector2(0f, 0f);
                shoes.velocity                = new Vector2(0f, 0f);
                shoes.Position                = new Vector2(Position.X, Position.Y + 40);
                isGuyBeingShot                = false;
                shoes.stopPlayerInput         = true;
                idleAnimationLockIsOn         = false;
                delayCollisionWithShoesAndGuy = true;
                areGuyAndShoesCurrentlyLinked = true;
                shoes.swapTexture(areGuyAndShoesCurrentlyLinked);
                SoundEffectHandler.stopShoesRunningEffect();

                if (shoes.directionShoesAreRunning == State.Running_Left || shoes.directionShoesAreRunning == State.Idle_Left)
                {
                    shoes.changeSpriteOfTheShoes("Idle_Left", true);
                    changeSpriteOfTheGuy("Empty");
                }
                else if (shoes.directionShoesAreRunning == State.Running_Right || shoes.directionShoesAreRunning == State.Idle_Right)
                {
                    shoes.changeSpriteOfTheShoes("Idle_Right", true);
                    changeSpriteOfTheGuy("Empty");
                }
            }
        }
Example #2
0
 private PositionRect AdjustPtzHFlip(PositionRect ptz, SceneItemFilters filters)
 {
     if (filters?.Filters != null && filters.Filters.Any(s => s.Type == SceneItemFilterType.HFlip))
     {
         return(new PositionRect(1 - ptz.Width - ptz.Left, ptz.Top, ptz.Width, ptz.Height));
     }
     return(ptz);
 }
Example #3
0
        /// <summary>
        /// Load the next level if the player has reached the end of the level and the Guy and Shoes are linked.
        /// </summary>
        /// <param name="shoes">A reference to the Shoes.</param>
        private void loadNextLevelIfPossible(Shoes shoes)
        {
            if (PositionRect.Intersects(currentLevel.goalRectangle) && areGuyAndShoesCurrentlyLinked &&
                (currentMouseState.RightButton != ButtonState.Pressed && previousMouseState.RightButton == ButtonState.Released))
            {
                shoes.stopPlayerInputDueToLevelCompletion = true;
            }

            // The victory screen will show here. Prompt player to continue to the next level.
            if (currentKeyboardState.IsKeyUp(Keys.Enter) && previousKeyboardState.IsKeyDown(Keys.Enter) &&
                shoes.stopPlayerInputDueToLevelCompletion &&
                !fadeHandler.FadingOut &&
                !fadeHandler.HoldingWhileFaded &&
                !fadeHandler.FadingIn)
            {
                // If the player hasn't completed all of the Main Game levels or the Bonus Levels, keep loading them. Otherwise, exit to main menu.
                if ((!Level.bonusLevelsSelected && Level.currentLevel + 1 <= 5) || (Level.bonusLevelsSelected && Level.currentLevel + 1 <= 12))
                {
                    // Begin fading out the sceen.
                    fadeHandler.fadeToBlack();
                }
                else
                {
                    // Exit to main menu.
                    Level.exitGame = true;
                }
            }

            // Once the screen is completely faded out, hold the fade for the specified time.
            if (fadeHandler.fadeToBlackTimer.TimerCompleted)
            {
                fadeHandler.holdFadeOut();
            }

            // Once the amount of time to hold the screen has passed, load the next level.
            if (fadeHandler.holdWhileFadedTimer.TimerCompleted)
            {
                fadeHandler.fadeFromBlack();
                currentLevel.LoadLevel();
                shoes.Position = currentLevel.getPlayerStartingPosition();
                shoes.stopPlayerInputDueToLevelCompletion = false;
            }

            // Once the screen is done fading in, reset the FadeHandler.
            if (fadeHandler.fadeFromBlackTimer.TimerCompleted)
            {
                fadeHandler.resetFadeHandler();
            }
        }
Example #4
0
        private double GetRange(Rect pdf, Rect title, PositionRect positionRect)
        {
            switch (positionRect)
            {
            case PositionRect.X1:
                return(Math.Abs(pdf.x1 - title.x1));

            case PositionRect.X2:
                return(Math.Abs(pdf.x2 - title.x2));

            case PositionRect.Y1:
                return(Math.Abs(pdf.y1 - title.y1));

            case PositionRect.Y2:
                return(Math.Abs(pdf.y2 - title.y2));

            default:
                throw new Exception("calculation range of pdfstring with title error.");
            }
        }
Example #5
0
        /// <summary>
        /// Sets the current and previous Tile that the Character is colliding with.
        /// </summary>
        protected void setCurrentAndPreviousCollisionTiles()
        {
            PreviousCollidingTile = CurrentCollidingTile;

            int leftTile   = (int)Math.Floor((float)positionRect.Left / Level.impassableTileRecs[0].Width);
            int rightTile  = (int)Math.Ceiling(((float)positionRect.Right / Level.impassableTileRecs[0].Width)) - 1;
            int topTile    = (int)Math.Floor((float)positionRect.Top / Level.impassableTileRecs[0].Height);
            int bottomTile = (int)Math.Ceiling(((float)positionRect.Bottom / Level.impassableTileRecs[0].Height)) - 1;

            for (int y = topTile; y <= bottomTile; ++y)
            {
                for (int x = leftTile; x <= rightTile; ++x)
                {
                    if ((x > 0 && x < 79 && y > 0 & y < 44) && PositionRect.Intersects(Level.tiles[y, x].SourceRect))
                    {
                        currentTileCollidingWith = Level.tiles[y, x];
                        tileCollRect             = Level.tiles[y, x].SourceRect;
                    }
                }
            }
        }
Example #6
0
 public List <PdfString> RegexExtractByPositionWithRangePage(PDFDoc doc, string pattern, int startPage, int endPage, Rect rect, PositionRect positionRect = PositionRect.Y2, double range = 2.0)
 {
     return(GetNearbyPdfString(RegexSearchByPageRange(doc, pattern, startPage, endPage), rect, positionRect, range));
 }
Example #7
0
 public List <PdfString> RegexExtractByPositionWithAllPage(PDFDoc doc, string pattern, Rect rect, PositionRect positionRect = PositionRect.Y2, double range = 2.0)
 {
     return(GetNearbyPdfString(RegexSearchAllPages(doc, pattern), rect, positionRect, range));
 }
Example #8
0
        public List <PdfString> GetNearbyPdfString(List <PdfString> pdfStringAll, Rect rect, PositionRect positionRect, double range)
        {
            List <PdfString> pdfStringFilter = new List <PdfString>();

            foreach (var pdf in pdfStringAll)
            {
                if (pdf == null)
                {
                    continue;
                }

                if (GetRange(pdf.Position, rect, positionRect) > range)
                {
                    continue;
                }

                pdfStringFilter.Add(pdf);
            }

            PdfString.PdfStringComparer comparerType = PdfString.GetComparer();

            if (positionRect.Equals(PositionRect.Y2) || positionRect.Equals(PositionRect.Y1))
            {
                comparerType.WhichComparison = PdfString.PdfStringComparer.ComparisonType.Horizontal;
            }
            else if (positionRect.Equals(PositionRect.X1) || positionRect.Equals(PositionRect.X2))
            {
                comparerType.WhichComparison = PdfString.PdfStringComparer.ComparisonType.Vertical;
            }

            pdfStringFilter.Sort(comparerType);
            return(pdfStringFilter);
        }