Beispiel #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            levelOne.Update(gameTime);
            levelTwo.Update(gameTime);
            levelThree.Update(gameTime);
            levelFour.Update(gameTime);
            levelFive.Update(gameTime);
            levelSix.Update(gameTime);
            levelSeven.Update(gameTime);
            levelEight.Update(gameTime);
            levelNine.Update(gameTime);
            levelTen.Update(gameTime);
            levelEle.Update(gameTime);
            levelTwe.Update(gameTime);
            levelTteen.Update(gameTime);
            levelFourteen.Update(gameTime);
            levelFifteen.Update(gameTime);
            levelSixteen.Update(gameTime);
            levelSeventeen.Update(gameTime);

            bool notPlayed = true;

            switch (levelNumber)
            {
            case 3:

                if (theOne.posX == 320)
                {
                    notPlayed = true;
                }
                else if (theOne.posX == 500)
                {
                    notPlayed = true;
                }
                else if (theOne.posX == 600)
                {
                    notPlayed = true;
                }
                else if (theOne.posX == 860)
                {
                    notPlayed = true;
                }

                if (theOne.posX < 140)
                {
                    levelThree.convoNumber = 1;
                }
                else if (theOne.posX < 320)
                {
                    levelThree.convoNumber = 2;
                    if (notPlayed)
                    {
                        level3Inst.Play();
                        notPlayed = false;
                    }
                }
                else if (theOne.posX < 500)
                {
                    levelThree.convoNumber = 3;
                    if (notPlayed)
                    {
                        level3Inst.Play();
                        notPlayed = false;
                    }
                }
                else if (theOne.posX < 680)
                {
                    levelThree.convoNumber = 4;
                    if (notPlayed)
                    {
                        level3Inst.Play();
                        notPlayed = false;
                    }
                }
                else if (theOne.posX < 860)
                {
                    levelThree.convoNumber = 5;
                    if (notPlayed)
                    {
                        level3Inst.Play();
                        notPlayed = false;
                    }
                }
                break;

            case 4:
            case 5:
                if (theOne.posX < 200)
                {
                    levelFive.convoSpeed = 1;
                }
                else if (theOne.posX < 400)
                {
                    levelFive.convoSpeed = 2;
                }
                else if (theOne.posX < 600)
                {
                    levelFive.convoSpeed = 3;
                }
                break;
            }


            if (transition)
            {
                transitionPos.X -= 6;
            }
            if (transitionPos.X + transitionBackground.Width <= 0)
            {
                transition      = false;
                transitionPos.X = 0;
                transitionPos.Y = 0;
                if (levelNumber == 10)
                {
                    MediaPlayer.Play(sunshine);
                    MediaPlayer.Volume      = 0.1f;
                    MediaPlayer.IsRepeating = false;
                }
            }


            if (theOne.posX < 0)
            {
                theOne.posX = 0;
            }


            if (CheckIntersection())
            {
                if (typingInst.State == SoundState.Playing)
                {
                    typingInst.Stop();
                }
                if (level7Inst.State == SoundState.Playing)
                {
                    level7Inst.Stop();
                }

                theOne.posX          = (int)startPos.X;
                theOne.posY          = (int)startPos.Y;
                levelNumber         += 1;
                levelFour.convoSpeed = 1;
                levelFive.convoSpeed = 1;
                transition           = true;
            }


            if (!transition)
            {
                // TODO: Add your update logic here
                if (Keyboard.GetState().IsKeyDown(Keys.A))
                {
                    walkingRight = false;
                    theOneSprLeft.Update();
                    theOne.posX -= 2;
                }

                Random rand = new Random();
                if (Keyboard.GetState().IsKeyUp(Keys.D))
                {
                    if (typingInst.State == SoundState.Playing)
                    {
                        typingInst.Stop();
                    }
                }


                if (Keyboard.GetState().IsKeyDown(Keys.D))
                {
                    if (levelNumber >= 2)
                    {
                        if (levelNumber != 3)
                        {
                            if (textStillToType)
                            {
                                if (typingInst.State != SoundState.Playing)
                                {
                                    typingInst.Play();
                                }
                            }
                            else
                            {
                                if (typingInst.State == SoundState.Playing)
                                {
                                    typingInst.Stop();
                                }
                            }
                        }
                    }
                    walkingRight = true;
                    switch (levelNumber)
                    {
                    case 2:

                        if (!transition)
                        {
                            textStillToType = !levelTwo.textDone;
                            levelTwo.UpdateText();
                        }
                        break;

                    case 4:
                        if (!transition)
                        {
                            textStillToType = !levelFour.textDone;
                            levelFour.UpdateConvo();
                            levelFour.UpdateText();
                        }
                        break;

                    case 5:
                        if (!transition)
                        {
                            textStillToType = !levelFive.textDone;
                            levelFive.UpdateConvo();
                            levelFive.UpdateText();
                        }
                        break;

                    case 6:
                        if (!transition)
                        {
                            textStillToType = !levelSix.textDone;
                            levelSix.UpdateText();
                        }
                        break;

                    case 7:
                        if (!transition)
                        {
                            textStillToType = !levelSeven.textDone;
                            levelSeven.UpdateText();
                        }
                        break;

                    case 8:
                        if (!transition)
                        {
                            textStillToType = !levelEight.textDone;
                            levelEight.UpdateText();
                        }
                        break;

                    case 9:
                        if (!transition)
                        {
                            textStillToType = !levelNine.textDone;
                            levelNine.UpdateText();
                        }
                        break;

                    case 10:
                        if (!transition)
                        {
                            textStillToType = !levelTen.textDone;
                            levelTen.UpdateText();
                        }
                        break;

                    case 11:
                        if (!transition)
                        {
                            textStillToType = !levelEle.textDone;
                            levelEle.UpdateText();
                        }
                        break;

                    case 12:
                        if (!transition)
                        {
                            textStillToType = !levelTwe.textDone;
                            levelTwe.UpdateText();
                        }
                        break;

                    case 13:
                        if (!transition)
                        {
                            textStillToType = !levelTteen.textDone;
                            levelTteen.UpdateText();
                        }
                        break;

                    case 14:
                        if (!transition)
                        {
                            textStillToType = !levelFourteen.textDone;
                            levelFourteen.UpdateText();
                        }
                        break;

                    case 15:
                        if (!transition)
                        {
                            textStillToType = !levelFifteen.textDone;
                            levelFifteen.UpdateText();
                        }
                        break;

                    case 16:
                        if (!transition)
                        {
                            textStillToType = !levelSixteen.textDone;
                            levelSixteen.UpdateText();
                        }
                        break;

                    case 17:
                        if (!transition)
                        {
                            textStillToType = !levelSeventeen.textDone;
                            levelSeventeen.UpdateText();
                        }
                        break;
                    }


                    theOneSprRight.Update();
                    theOne.posX += 2;
                }
            }
            base.Update(gameTime);
        }