Exemplo n.º 1
0
        /// <summary>
        /// Advances to the next screen based on the current difficulty and whether or not the user has won.
        /// </summary>
        /// <param name="isWon">Whether or not the user has won the current level.</param>
        private void MoveToNextScreen(bool isWon)
        {
            ScreenManager.AddScreen(new BackgroundScreen("pauseBackground"), null);

            if (isWon)
            {
                switch (gameDifficultyLevel)
                {
                case DifficultyMode.Easy:
                case DifficultyMode.Medium:
                    ScreenManager.AddScreen(
                        new LevelOverScreen("You Finished Level: " + gameDifficultyLevel.ToString(),
                                            ++gameDifficultyLevel), null);
                    break;

                case DifficultyMode.Hard:
                    ScreenManager.AddScreen(new LevelOverScreen("You Win", null), null);
                    break;
                }
            }
            else
            {
                ScreenManager.AddScreen(new LevelOverScreen("You Lose", null), null);
            }

            AudioManager.StopMusic();
            AudioManager.StopSound("BeeBuzzing_Loop");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handler for finalizing the honey deposit to the vat.
        /// </summary>
        /// <param name="result"></param>
        public void EndHoneyDeposit(IAsyncResult result)
        {
            int HoneyAmount = jar.DecreaseHoneyByPercent(100);

            vat.IncreaseHoney(HoneyAmount);
            AudioManager.StopSound("DepositingIntoVat_Loop");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Respond to "Exit" Item Selection
        /// </summary>
        /// <param name="playerIndex"></param>
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            HighScoreScreen.SaveHighscore();

            ScreenManager.Game.Exit();

            AudioManager.StopSound("MenuMusic_Loop");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Handle the beekeeper's collision with beehive components.
        /// </summary>
        /// <returns>True if the beekeeper collides with a beehive and false otherwise.</returns>
        /// <remarks>This method is also responsible for allowing bees to regenerate when the beekeeper is not
        /// intersecting with a specific hive.</remarks>
        private bool HandleBeeKeeperBeehiveCollision()
        {
            bool isCollidingWithBeehive = false;

            Beehive collidedBeehive = null;

            // Goes over all the beehives
            foreach (Beehive beehive in beehives)
            {
                // If the beekeeper intersects with the beehive
                if (beeKeeper.Bounds.HasCollision(beehive.Bounds))
                {
                    if (movementVector == Vector2.Zero)
                    {
                        collidedBeehive        = beehive;
                        isCollidingWithBeehive = true;
                    }
                }
                else
                {
                    beehive.AllowBeesToGenerate = true;
                }
            }

            if (collidedBeehive != null)
            {
                // The beehive has honey, the jar can carry more honey, and the beekeeper is not stung
                if (collidedBeehive.HasHoney && jar.CanCarryMore && !beeKeeper.IsStung)
                {
                    // Take honey from the beehive and put it in the jar
                    collidedBeehive.DecreaseHoney(1);
                    jar.IncreaseHoney(1);
                    beeKeeper.IsCollectingHoney = true;
                    AudioManager.PlaySound("FillingHoneyPot_Loop");
                }
                else
                {
                    beeKeeper.IsCollectingHoney = false;
                }

                // Bees are not allowed to regenerate while the beekeeper is colliding with their beehive
                isCollidingWithBeehive = true;
                collidedBeehive.AllowBeesToGenerate = false;
            }
            else
            {
                beeKeeper.IsCollectingHoney = false;
                AudioManager.StopSound("FillingHoneyPot_Loop");
            }

            return(isCollidingWithBeehive);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Respond to "Play" Item Selection
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void StartGameMenuEntrySelected(object sender, EventArgs e)
        {
            foreach (GameScreen screen in ScreenManager.GetScreens())
            {
                screen.ExitScreen();
            }

            ScreenManager.AddScreen(new BackgroundScreen("Instructions"), null);
            ScreenManager.AddScreen(new LoadingAndInstructionScreen(), null);



            AudioManager.StopSound("MenuMusic_Loop");
        }
Exemplo n.º 6
0
        /// <summary>
        /// Respond to "Play" Item Selection
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void StartGameMenuEntrySelected(object sender, EventArgs e)
        {
            foreach (GameScreen screen in ScreenManager.GetScreens())
            {
                screen.ExitScreen();
            }

#if WINDOWS_PHONE
            ScreenManager.AddScreen(new BackgroundScreen("Instructions"), null);
#elif XBOX
            ScreenManager.AddScreen(new BackgroundScreen("InstructionsXbox"), null);
#else
            ScreenManager.AddScreen(new BackgroundScreen("InstructionsPC"), null);
#endif

            ScreenManager.AddScreen(new LoadingAndInstructionScreen(), null);

            AudioManager.StopSound("MenuMusic_Loop");
        }
Exemplo n.º 7
0
        /// <summary>
        /// Respond to "Exit" Item Selection
        /// </summary>
        /// <param name="playerIndex"></param>
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            isExiting = true;

            AudioManager.StopSound("MenuMusic_Loop");
        }
Exemplo n.º 8
0
        /// <summary>
        /// Renders the beekeeper.
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Draw(GameTime gameTime)
        {
            if (!(gamePlayScreen.IsActive))
            {
                base.Draw(gameTime);
                return;
            }

            // Make sure not to draw the beekeeper while flashing
            if (isStung || isFlashing)
            {
                if (stungDrawingCounter != stungDrawingInterval)
                {
                    if (isDrawnLastStungInterval)
                    {
                        return;
                    }
                }
            }

            spriteBatch.Begin();

            // if stung we want to show another animation
            if (isStung)
            {
                spriteBatch.Draw(Game.Content.Load <Texture2D>("Textures/hit"), position, Color.White);
                spriteBatch.End();
                return;
            }

            // If collecting honey, draw the appropriate animation
            if (IsCollectingHoney)
            {
                AnimationDefinitions[BeekeeperCollectingHoneyAnimationKey].Draw(spriteBatch, position,
                                                                                SpriteEffects.None);
                spriteBatch.End();
                return;
            }


            if (isDepositingHoney)
            {
                if (VirtualThumbsticks.LeftThumbstick != Vector2.Zero)
                {
                    isDepositingHoney = false;
                    AudioManager.StopSound("DepositingIntoVat_Loop");
                }

                // We want the deposit duration to sync with the deposit
                // animation
                // So we manage the timing ourselves
                if (depositHoneyUpdatingTimer != TimeSpan.Zero &&
                    depositHoneyUpdatingTimer + depositHoneyUpdatingInterval < gameTime.TotalGameTime)
                {
                    depositHoneyTimerCounter++;
                    depositHoneyUpdatingTimer = TimeSpan.Zero;
                }

                AnimationDefinitions[BeekeeperDesposingHoneyAnimationKey].Draw(spriteBatch, position,
                                                                               SpriteEffects.None);

                if (depositHoneyTimerCounter == honeyDepositFrameCount - 1)
                {
                    isDepositingHoney = false;
                    depositHoneyCallback.Invoke(null);
                    AnimationDefinitions[BeekeeperDesposingHoneyAnimationKey].PlayFromFrameIndex(0);
                }

                spriteBatch.End();
                return;
            }

            bool             hadDirectionChanged = false;
            WalkingDirection tempDirection       = direction;

            DetermineDirection(ref tempDirection, ref smokeAdjustment);

            // Indicate the direction has changed
            if (tempDirection != direction)
            {
                hadDirectionChanged = true;
                direction           = tempDirection;
            }

            if (hadDirectionChanged)
            {
                // Update the animation
                lastFrameCounter = 0;
                AnimationDefinitions[LegAnimationKey].PlayFromFrameIndex(lastFrameCounter + (int)direction);
                AnimationDefinitions[ShootingAnimationKey].PlayFromFrameIndex(lastFrameCounter + (int)direction);
                AnimationDefinitions[BodyAnimationKey].PlayFromFrameIndex(lastFrameCounter + (int)direction);
            }
            else
            {
                // Because our animation is 8 cells, but the row is 16 cells,
                // we need to reset the counter after 8 rounds

                if (lastFrameCounter == 8)
                {
                    lastFrameCounter = 0;
                    AnimationDefinitions[LegAnimationKey].PlayFromFrameIndex(lastFrameCounter + (int)direction);
                    AnimationDefinitions[ShootingAnimationKey].PlayFromFrameIndex(
                        lastFrameCounter + (int)direction);
                    AnimationDefinitions[BodyAnimationKey].PlayFromFrameIndex(lastFrameCounter + (int)direction);
                }
                else
                {
                    lastFrameCounter++;
                }
            }


            AnimationDefinitions[LegAnimationKey].Draw(spriteBatch, position, 1f, SpriteEffects.None);


            if (needToShootSmoke)
            {
                // Draw the body
                AnimationDefinitions[ShootingAnimationKey].Draw(spriteBatch, position, 1f, SpriteEffects.None);

                // If true we need to draw smoke
                if (smokeAdjustment != Vector2.Zero)
                {
                    AnimationDefinitions[SmokeAnimationKey].Draw(spriteBatch, position + smokeAdjustment, 1f,
                                                                 GetSpriteEffect(VirtualThumbsticks.LeftThumbstick));
                }
            }
            else
            {
                AnimationDefinitions[BodyAnimationKey].Draw(spriteBatch, position, 1f, SpriteEffects.None);
            }
            spriteBatch.End();

            base.Draw(gameTime);
        }