AncientChinaPuzzle4.AncientChinaPuzzle4.Update C# (CSharp) Method

Update() protected method

Allows the game to run logic such as updating the world, checking for collisions, gathering input, and playing audio.
protected Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime Provides a snapshot of timing values.
return void
        protected override void Update(GameTime gameTime)
        {
            _timer -= gameTime.ElapsedGameTime.TotalSeconds;

            if (_timer < 0)
                this.Exit();

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            MouseState aMouse = Mouse.GetState();

            if (aMouse.LeftButton == ButtonState.Pressed && idleMouse.LeftButton == ButtonState.Released)
            {
                if ((aMouse.X > firstDoor.X && aMouse.X < firstDoor.X + 200) &&
                    (aMouse.Y > firstDoor.Y && aMouse.Y < firstDoor.Y + 400))
                {
                    if (roomLocation == 8 && wrongWayCount == 0)
                        this.Exit();
                    else if (wrongWayCount == 0)
                    {
                        if (correctWaySequence[roomLocation] == 0)
                        {
                            roomLocation++;
                        }
                        else
                        {
                            roomLocation++;
                            wrongWayCount++;
                        }
                    }
                    else
                    {
                        roomLocation++;
                        wrongWayCount++;
                    }

                    ShuffleArrows();
                }
                else if ((aMouse.X > secondDoor.X && aMouse.X < secondDoor.X + 210) &&
                    (aMouse.Y > secondDoor.Y && aMouse.Y < secondDoor.Y + 400))
                {
                    if (roomLocation == 8 && wrongWayCount == 0)
                        this.Exit();
                    else if (wrongWayCount == 0)
                    {
                        if (correctWaySequence[roomLocation] == 1)
                        {
                            roomLocation++;
                        }
                        else
                        {
                            roomLocation++;
                            wrongWayCount++;
                        }
                    }
                    else
                    {
                        roomLocation++;
                        wrongWayCount++;
                    }

                    ShuffleArrows();
                }
                else if ((aMouse.X > thirdDoor.X && aMouse.X < thirdDoor.X + 200) &&
                    (aMouse.Y > secondDoor.Y && aMouse.Y < secondDoor.Y + 400))
                {
                    if (roomLocation == 8 && wrongWayCount == 0)
                        this.Exit();
                    else if (wrongWayCount == 0)
                    {
                        if (correctWaySequence[roomLocation] == 2)
                        {
                            roomLocation++;
                        }
                        else
                        {
                            roomLocation++;
                            wrongWayCount++;
                        }
                    }
                    else
                    {
                        roomLocation++;
                        wrongWayCount++;
                    }

                    ShuffleArrows();
                }
                else if ((aMouse.X > 0 && aMouse.X < 100) &&
                    (aMouse.Y > 500 && aMouse.Y < 600))
                {
                    if (roomLocation == 0)
                        wrongWayCount = 0;
                    else
                    {
                        if (wrongWayCount > 0)
                        {
                            roomLocation--;
                            wrongWayCount--;
                        }
                        else
                            roomLocation--;
                    }

                    ShuffleArrows();
                }
            }
            // TODO: Add your update logic here

            idleMouse = aMouse;

            base.Update(gameTime);
        }