Example #1
0
        /// <summary>
        /// Reset the Guy to the Shoes' position if the player has clicked the right mouse button.
        /// </summary>
        /// <param name="shoes">A reference to the Shoes.</param>
        private void resetGuyToShoesCurrentPositionIfPossible(Shoes shoes)
        {
            if (!(currentMouseState.RightButton == ButtonState.Pressed) &&
                previousMouseState.RightButton == ButtonState.Pressed &&
                !areGuyAndShoesCurrentlyLinked &&
                !Utilities.movementLockedDueToActivePauseScreen)
            {
                isGuyBeingShot                = false;
                usingLauncher                 = false;
                idleAnimationLockIsOn         = false;
                areGuyAndShoesCurrentlyLinked = true;
                shoes.swapTexture(areGuyAndShoesCurrentlyLinked);
                Position = new Vector2(shoes.Position.X, shoes.Position.Y);
                velocity = new Vector2(0f, 0f);
                delayLaunchAfterLauncherCollisionTimer.stopTimer();
                delayBetweenLaunchesTimer.stopTimer();

                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
        /// <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 #3
0
        /// <summary>
        /// Shoot the Guy if the player clicks the left mouse button.
        /// </summary>
        /// <param name="shoes">A reference to the Shoes.</param>
        private void shootGuyIfPossible(Shoes shoes)
        {
            if (currentMouseState.LeftButton == ButtonState.Released && previousMouseState.LeftButton == ButtonState.Pressed && !isGuyBeingShot && !shoes.stopPlayerInputDueToLevelCompletion && !Utilities.movementLockedDueToActivePauseScreen)
            {
                if (!delayCollisionWithGuyAndShoesTimer.TimerStarted)
                {
                    delayCollisionWithGuyAndShoesTimer.startTimer();
                }

                isGuyBeingShot = true;
                useGravity     = true;
                delayCollisionWithShoesAndGuy = true;
                velocity  = Utilities.Vector2FromAngle(MathHelper.ToRadians(angleBetweenGuyAndMouseCursor)) * powerOfLauncherBeingUsed;
                velocity *= -1;
                areGuyAndShoesCurrentlyLinked = false;
                shoes.swapTexture(areGuyAndShoesCurrentlyLinked);                 // Changes the texture/size of the shoes because the Guy is being shot.

                if (shoes.directionShoesAreRunning == State.Running_Left)
                {
                    shoes.changeSpriteOfTheShoes("Running_Left", false);
                    changeSpriteOfTheGuy("BeingShot_Left");
                }
                else if (shoes.directionShoesAreRunning == State.Idle_Left)
                {
                    shoes.changeSpriteOfTheShoes("Idle_Left", false);
                    changeSpriteOfTheGuy("BeingShot_Left");
                }
                else if (shoes.directionShoesAreRunning == State.Running_Right)
                {
                    shoes.changeSpriteOfTheShoes("Running_Right", false);
                    changeSpriteOfTheGuy("BeingShot_Right");
                }
                else if (shoes.directionShoesAreRunning == State.Idle_Right)
                {
                    shoes.changeSpriteOfTheShoes("Idle_Right", false);
                    changeSpriteOfTheGuy("BeingShot_Right");
                }
            }
        }