Resume() public méthode

Resumes playback for a SoundEffectInstance.
Only has effect on a SoundEffectInstance in a paused state.
public Resume ( ) : void
Résultat void
        //method for mouse on main menu
        public Rectangle MouseClicked(int x, int y, Game1 game, ref int currentLevel, ref List<Enemy> enemies, ref List<PickUpItem> Items, ref List<Projectile> projectiles, ref int timer, ContentManager Content, ref Character player, ref string wepUnl, ref bool songPlaying, ref SoundEffectInstance song) {
            Rectangle mouseClickRect = new Rectangle(x, y, 1, 1);
            Rectangle startbuttonRect = new Rectangle((int)startButtonPosition.X, (int)startButtonPosition.Y, 300, 108);
            Rectangle exitbuttonRect = new Rectangle((int)exitButtonPosition.X, (int)exitButtonPosition.Y, 600, 192);

            if (gameState == "StartMenu") {
                //player clicks start
                if (mouseClickRect.Intersects(startbuttonRect)) {
                    try {
                        gameState = "Case";
                        CheckGameState();
                    } catch (GameStateNotFoundException) {
                        
                        gameState = "Case";
                    }

                }
                //player exits game
                else if (mouseClickRect.Intersects(exitbuttonRect)) {
                    game.Exit();
                }
                // player clicked on options
                else if (mouseClickRect.Intersects(optionsButtonPosition)) {
                    try {
                        gameState = "OptionsMenu";
                        lastState = "StartMenu";
                        CheckGameState();
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                } else if (mouseClickRect.Intersects(levelSelectButtonPosition)) {
                    try {
                        gameState = "LevelSelect";
                        lastState = "StartMenu";
                        CheckGameState();
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                }
            }
            //level select menu
            else if (gameState == "LevelSelect") {
                // back button clicked
                if (mouseClickRect.Intersects(backButtonPosition)) {
                    try {
                        gameState = lastState;
                        CheckGameState();
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                        lastState = "";
                    }
                } else if (mouseClickRect.Intersects(levelRect[0]) || mouseClickRect.Intersects(levelRect[1]) || mouseClickRect.Intersects(levelRect[2]) || mouseClickRect.Intersects(levelRect[3]) || mouseClickRect.Intersects(levelRect[4]) || mouseClickRect.Intersects(levelRect[5]) || mouseClickRect.Intersects(levelRect[6]) || mouseClickRect.Intersects(levelRect[7])) {
                    Shooting.CreateWeapons(Content);
                    if (mouseClickRect.Intersects(levelRect[0]) && levelClears[0] != 0) {
                        currentLevel = 1;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    } else if (mouseClickRect.Intersects(levelRect[1]) && levelClears[1] != 0) {
                        currentLevel = 2;
                        Shooting.weapons[2].IsAcquired = true;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    } else if (mouseClickRect.Intersects(levelRect[2]) && levelClears[2] != 0) {
                        currentLevel = 3;
                        Shooting.weapons[2].IsAcquired = true;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    } else if (mouseClickRect.Intersects(levelRect[3]) && levelClears[3] != 0) {
                        currentLevel = 4;
                        Shooting.weapons[2].IsAcquired = true;
                        Shooting.weapons[3].IsAcquired = true;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    } else if (mouseClickRect.Intersects(levelRect[4]) && levelClears[4] != 0) {
                        currentLevel = 5;
                        Shooting.weapons[2].IsAcquired = true;
                        Shooting.weapons[3].IsAcquired = true;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    }
                    else if (mouseClickRect.Intersects(levelRect[5]) && levelClears[5] != 0)
                    {
                        currentLevel = 6;
                        Shooting.weapons[2].IsAcquired = true;
                        Shooting.weapons[3].IsAcquired = true;
                        Shooting.weapons[4].IsAcquired = true;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    }
                    else if (mouseClickRect.Intersects(levelRect[6]) && levelClears[6] != 0)
                    {
                        currentLevel = 7;
                        Shooting.weapons[2].IsAcquired = true;
                        Shooting.weapons[3].IsAcquired = true;
                        Shooting.weapons[4].IsAcquired = true;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    }
                    else if (mouseClickRect.Intersects(levelRect[7]) && levelClears[7] != 0)
                    {
                        currentLevel = 8;
                        Shooting.weapons[2].IsAcquired = true;
                        Shooting.weapons[3].IsAcquired = true;
                        Shooting.weapons[4].IsAcquired = true;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    }

                }
            }
            //Death screen 
            else if (gameState == "Death") {
                if (mouseClickRect.Intersects(exitbuttonRect)) {
                    gameState = "StartMenu";
                    CheckGameState();
                }
            }//Victory state for beating the game
            else if (gameState == "Victory") {
                if (mouseClickRect.Intersects(rightStartButton)) {
                    gameState = "StartMenu";
                    CheckGameState();
                }
            }//Page for the Case story 
            else if (gameState == "Case") {
                if (mouseClickRect.Intersects(rightStartButton)) {
                    SkillSystem.CreateSkills(Content, player);
                    Shooting.CreateWeapons(Content);
                    player.Health = player.MaxHealth;
                    player.Stamina = 100;
                    wepUnl = "";
                    player.Weapon = Shooting.weapons[1];
                    player.FrameLevel = 1;
                    currentLevel = 1;
                    enemies.Clear();
                    Items.Clear();
                    projectiles.Clear();
                    timer = 0;
                    gameState = "LevelSwitch";
                    CheckGameState();
                }
            }
               //puased screen
               else if (gameState == "Paused") {
                if (mouseClickRect.Intersects(exitbuttonRect)) {
                    saveLevelClears();
                    song.Stop();
                    songPlaying = false;
                    gameState = "StartMenu";
                    CheckGameState();
                } else if (mouseClickRect.Intersects(optionsButtonPosition)) {
                    try {
                        gameState = "OptionsMenu";
                        lastState = "Paused";
                        CheckGameState();
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                } else if (mouseClickRect.Intersects(resumeButtonPosition)) {
                    try {
                        song.Resume();
                        gameState = "Playing";
                        CheckGameState();
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                }
            }

            //options screen method
            else if (gameState == "OptionsMenu") {
                // back button clicked
                if (mouseClickRect.Intersects(backButtonPosition)) {
                    try {
                        gameState = lastState;
                        CheckGameState();
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                        lastState = "";
                    }
                }
                // sounds button clicked
                else if (mouseClickRect.Intersects(soundsButtonPosition)) {
                    try {
                        gameState = "SoundsMenu";
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                }
                // graphics button clicked
                else if (mouseClickRect.Intersects(graphicsButtonPosition)) {
                    try {
                        gameState = "GraphicsMenu";
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                }
                // controls button clicked
                else if (mouseClickRect.Intersects(controlButtonPosition)) {
                    try {
                        gameState = "Controls";
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                }
            }

            // Sounds menu
            else if (gameState == "SoundsMenu") {
                if (mouseClickRect.Intersects(backButtonPosition)) {
                    try {
                        gameState = "OptionsMenu";
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                }
            }


            // Controls menu
            else if (gameState == "Controls") {
                if (mouseClickRect.Intersects(controlBackButtonPosition)) {
                    try {
                        gameState = "OptionsMenu";
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                }
            }
            // graphics menu
            else if (gameState == "GraphicsMenu") {
                if (mouseClickRect.Intersects(backButtonPosition)) {
                    try {
                        gameState = "OptionsMenu";
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                }
            }
            return mouseClickRect;
        }
 public bool updateState(KeyboardState State, KeyboardState oldState, ref bool songPlaying, ref SoundEffectInstance song) {
     if (gameState == "Playing" && State.IsKeyDown(Keys.Escape) && oldState.IsKeyUp(Keys.Escape)) {
         try {
             song.Pause();
             gameState = "Paused";
             CheckGameState();
         } catch (GameStateNotFoundException e) {
             Console.WriteLine(e.ToString());
             gameState = "";
         }
         return false;
     } else if (gameState == "Paused") {
         if (State.IsKeyDown(Keys.Escape) && oldState.IsKeyUp(Keys.Escape)) {
             try {
                 song.Resume();
                 gameState = "Playing";
                 CheckGameState();
             } catch (GameStateNotFoundException e) {
                 Console.WriteLine(e.ToString());
                 gameState = "";
             }
         }
         return false;
     }
     if (gameState == "Loading" && isLoading) {
         isLoading = true;
         return true;
     }
     return false;
 }
Exemple #3
0
        public static void playSoundLoop(string filename, ContentManager Content)
        {
            int index = 1;
                if (loopInstance != null)
                    loopInstance.Stop();
                if (lookUpTable.ContainsKey(filename))
                {

                    lookUpTable.TryGetValue(filename, out index);
                    loopInstance = mySounds.ElementAt(index);
                    if (loopInstance.State == SoundState.Paused)
                    {
                        loopInstance.Resume();
                    }
                    else if (loopInstance.State == SoundState.Stopped)
                    {
                        loopInstance.Play();
                    }
                }
                else
                {
                    soundEngine = Content.Load<SoundEffect>(filename);
                    loopInstance = soundEngine.CreateInstance();
                    mySounds.Add(loopInstance);

                    lookUpTable.Add(filename, numSounds);
                    numSounds++;
                    loopInstance.IsLooped = true;
                    loopInstance.Volume = 0.5f;
                    loopInstance.Play();
                }
        }