示例#1
0
        public void Update(bool isMuteButton, GameTime gameTime)
        {
            MouseState mouse = Mouse.GetState();

            rectangle = new Rectangle((int)(position.X), (int)(position.Y), (int)(Size.X), (int)(Size.Y));
            Point mousePos = new Point(mouse.X, mouse.Y);

            if ((rectangle.Contains(mousePos) && mouse.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released) || clickDetected)
            {
                clickDetected = true;
                if (normalClocks.CallTimer(gameTime) && !isMuteButton)
                {
                    IsClicked     = true;
                    clickDetected = false;
                }
                else
                {
                    if (isMuteButton && muteClocks.CallTimer(gameTime))
                    {
                        IsClicked     = true;
                        clickDetected = false;
                    }
                }
            }
            else
            {
                IsClicked = false;
            }
            oldMouseState = mouse;
        }
示例#2
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)
        {
            //sets the mouse handle
            Mouse.WindowHandle = Window.Handle;

            //loading logic
            if (!loadingThread.IsAlive)
            {
                if ((justFinshed) && (!isDoneLoading))
                {
                    save          = new SaveGame("C:/Users/" + Environment.UserName + "/Documents/RubikCube/save.xml", "root");
                    isDoneLoading = true;
                    Debug.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); //should upgrade to DebbugBorders (~~~) but too afraid to StuckOverflow the game.
                }
                //load bools from save file
                foreach (Tuple <string, string> b in save.LoadBools())
                {
                    if (b.Item1 == "isFirstTime")
                    {
                        isFirstTime = Convert.ToBoolean(b.Item2);
                    }
                }

                // checks if the loading & the Clocks are done
                if (justFinshed && clocks.CallTimer(gameTime))
                {
                    MediaPlayer.Resume();
                    if (isFirstTime)
                    {
                        save.AddBool("isFirstTime", "false");
                    }
                    justFinshed = false;
                }
                //neccesary updates
                button.BtnMute.Update(true, gameTime);
                button.BtnUnMute.Update(true, gameTime);
                MuteEvent();
                gameState.Update(gameTime, GraphicsDevice, music);
            }
            else
            {
                //loading animation
                loading.Update(gameTime);
                //pause media player to prevent bugs
                if (MediaPlayer.State != MediaState.Paused)
                {
                    MediaPlayer.Pause();
                }
            }
            base.Update(gameTime);
        }