Example #1
0
 public override void Update()
 {
     //check collision with buttons
     if (CollisionChecker.Collision(new RectCollider(new Rectangle(480, 200, x1, 30))
                                    , new ParticleCollider(Globals.currentMouseState.Position)))
     {
         this.Draw();
         Globals.spriteBatch.Begin();
         Globals.spriteBatch.Draw(blank, new Rectangle(300, 270, 250, 40), Color.Violet);
         Globals.spriteBatch.End();
     }
     if (Back.Collide(Globals.currentMouseState.Position))
     {
         if (Globals.currentMouseState.LeftButton == ButtonState.Pressed &&
             Globals.previousMouseState.LeftButton == ButtonState.Released)
         {
             manager.AlmostCurrentScenes.Add("Background");
             manager.AlmostCurrentScenes.Add("Main Menu");
             manager.FocusOn("Main Menu");
             manager.transitioningScenes = true;
         }
     }
 }
Example #2
0
        public override void Update()
        {
            if (active != null)
            {
                Visual.Update();
                if (Globals.nextBlock.p >= Globals.wave.get_data_p() + Globals.wave.get_data_size())
                {
                    Globals.wave.reset();
                }
            }
            if (focused)
            {
                //SCROLL UPDATE
                songbar.Update();
                int Offset = songbar.ScaledMove();

                //BUTTON UPDATE
                foreach (SongButton song in Songs)
                {
                    song.Move(new Vector2(-Offset, 0));
                    song.Update();
                }


                Point pos = Globals.currentMouseState.Position;
                foreach (SongButton s in Songs)
                {
                    //Checks for mouse hovering over songbuttons
                    if (s.Collide(pos))//check collision
                    {
                        if (Globals.currentMouseState.LeftButton == ButtonState.Released &&
                            clicked == s &&//THIS METHOD MAKES SURE YOU CANNOT RESELECT THE SAME SONG
                            Math.Pow((pressedpoint - Globals.currentMouseState.Position).X, 2) + Math.Pow((pressedpoint - Globals.currentMouseState.Position).Y, 2) < 10000)
                        {
                            if (active != s)
                            {
                                active = s;
                                bg     = s.texture;
                                if (Globals.wave != null)
                                {
                                    Globals.wave.reset();         //reset previous song
                                }
                                Globals.wave      = active.music; //new song
                                Globals.waveAudio = new Audio(Globals.wave, 0);
                                Visual            = new Visualizer(Globals.wave);
                            }
                        }
                        if (Globals.currentMouseState.LeftButton == ButtonState.Pressed &&
                            Globals.previousMouseState.LeftButton == ButtonState.Released)
                        {
                            clicked      = s;
                            pressedpoint = Globals.currentMouseState.Position;
                        }
                        if (Globals.currentMouseState.LeftButton == ButtonState.Released)
                        {
                            clicked = null;
                        }

                        s.Glow();//applies a glow effect
                    }
                }
                //DRAGGING SCREEN     move the screen with mouse/touchscreen
                if (Globals.currentMouseState.LeftButton == ButtonState.Pressed &&
                    0 < Globals.currentMouseState.Position.Y &&
                    Globals.currentMouseState.Position.Y < Options.Resolutions.Y * 4 / 5 &&
                    !songbar.pressed)
                {
                    if (Globals.currentMouseState.Position.X - Globals.previousMouseState.Position.X > 250)//added to avoid bug when click, release,click
                    {
                        dragspeed = 1;
                    }
                    else if (Globals.currentMouseState.Position.X - Globals.previousMouseState.Position.X < -250)
                    {
                        dragspeed = -1;
                    }
                    else
                    {
                        dragspeed = (Globals.currentMouseState.Position.X - Globals.previousMouseState.Position.X) / 4;
                    }
                }
                if (Globals.currentMouseState.LeftButton == ButtonState.Released)
                {
                    if (dragspeed > 0)
                    {
                        dragspeed -= .4;
                        if (dragspeed < .3)
                        {
                            dragspeed = 0;
                        }
                    }
                    else if (dragspeed < 0)
                    {
                        dragspeed += .4;
                        if (dragspeed > -.3)
                        {
                            dragspeed = 0;
                        }
                    }
                }
                songbar.bar.X -= (int)dragspeed;
                songbar.Update();

                //Button update-check for collisions
                if (Globals.previousMouseState.LeftButton == ButtonState.Pressed && Globals.currentMouseState.LeftButton == ButtonState.Released)
                {
                    if (Play.Collide(pos))
                    {
                        //this.manager.RegisterScene("Play", new LevelScene());
                        this.manager.AlmostCurrentScenes.Add("Background");
                        this.manager.AlmostCurrentScenes.Add("Level");
                        Globals.pathToCurrentMap         = active.dmlfile;
                        Globals.songname                 = active.title;
                        this.manager.transitioningScenes = true;
                        this.manager.FocusOn("Level");
                    }
                    if (Back.Collide(pos))
                    {
                        this.manager.AlmostCurrentScenes.Add("Background");
                        this.manager.AlmostCurrentScenes.Add("Main Menu");
                        this.manager.FocusOn("Main Menu");
                        this.manager.transitioningScenes = true;
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Update the elements of the scene that respond to input from the user.
        /// </summary>
        public override void Update()
        {
            base.Update();

            // Update the buttons.
            ChooseFolderButton.Update();
            AcceptButton.Update();
            DenyButton.Update();

            // Scroll the background back and forth.
            backgroundOffset += 0.2 * Math.Sin(LocalTime / 5000);

            // If we've already selected a folder (i.e. the user pressed okay in the dialog box)
            if (currentState == SceneStates.AfterFolderChosen)
            {
                // If the user denied the path they selected.
                if (DenyButton.IsClicked())
                {
                    chosenPath = null;

                    currentState = SceneStates.BeforeFolderChosen;
                    AcceptButton.FadeOut();
                    DenyButton.FadeOut();
                }
                // If the user accepted the path they selected.
                else if (AcceptButton.IsClicked())
                {
                    Options.SongFolder = chosenPath;
                    new UserInfoLoader().Write();

                    AcceptButton.FadeOut();
                    DenyButton.FadeOut();

                    // Transition to the main menu.
                    manager.AlmostCurrentScenes.Add("Background");
                    manager.AlmostCurrentScenes.Add("Main Menu");
                    manager.FocusOn("Main Menu");
                    manager.transitioningScenes = true;

                    // Organize the songs folder.
                    SongFolderOrganizer.Organize();
                }
            }

            // If the user presses the Choose Folder button and they haven't already chosen a folder.
            if (currentState == SceneStates.BeforeFolderChosen && ChooseFolderButton.Collide(Globals.currentMouseState.Position) &&
                Globals.currentMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && // Freakin name collisions
                Globals.previousMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released)
            {
                var dialog = new FolderBrowserDialog();
                dialog.Description = "Choose a Song Folder for Phosphaze";

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    chosenPath = dialog.SelectedPath;

                    currentState = SceneStates.AfterFolderChosen;
                    AcceptButton.FadeIn();
                    DenyButton.FadeIn();
                }
            }
        }