// Event handler for when the Credits menu entry is selected.
        void CreditsMenuEntrySelected(object sender, EventArgs e)
        {
            //playing the sound
            SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);

            ScreenManager.AddScreen(new CreditsMenuScreen());
        }
        void armorMenuEntrySelected(object sender, EventArgs e)
        {
            if (Global.Money >= _priceArmor)
            {
                if (_droneFleet._armor < 5)
                {
                    _droneArmorLevel++;
                    Global.Money -= _priceArmor;
                    this._droneFleet._armor++;
                    SetMenuEntryText();
                    ShopText.Remove(2);
                    ShopText.Add(2, "Your Drone has now:\n" + _droneFleet._armor.ToString() + " Armor\n\nFor every Upgrade in Armor,\nthe incoming Damage is reduced \nby Damage*Armor/10.");
                }
                else
                {
                    ShopText.Remove(2);
                    ShopText.Add(2, "Your Drone has now:\n" + _droneFleet._armor.ToString() + "\n\nThis is the maximum armor capacity!");
                }

                //playing the sound
                SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);
            }
            else
            {
                //playing the sound
                SoundEngine.Play2D("MenuDenieSound", Global.SpeakerVolume / 10, false);
            }
        }
        void TutorialMenuEntrySelected(object sender, EventArgs e)
        {
            //playing the sound
            SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);

            LoadingScreen.Load(ScreenManager, true, new TutorialScreen());
        }
Exemple #4
0
 // Event handler for when the user selects ok on the "are you sure
 // you want to quit" message box. This uses the loading screen to
 // transition from the game back to the main menu screen.
 void ConfirmQuitMessageBoxAccepted(object sender, EventArgs e)
 {
     LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(), new MainMenuScreen());
     //LoadingScreen.Load(ScreenManager, false, null, new MainMenuScreen());
     //ScreenManager.Game.Exit();
     //playing the sound
     SoundEngine.Play2D("GoBack", Global.SpeakerVolume / 10, false);
 }
Exemple #5
0
        // Event handler for when the Quit Game menu entry is selected.
        void QuitGameMenuEntrySelected(object sender, EventArgs e)
        {
            const string     message = "Are you sure you want to abandon your Mission?";
            MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);

            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;
            ScreenManager.AddScreen(confirmQuitMessageBox);
            //playing the sound
            SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);
        }
        protected override void OnCancel()
        {
            SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);

            const string message = "Are you sure you want to exit?";

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmExitMessageBox);
        }
        void rocketMenuEntrySelected(object sender, EventArgs e)
        {
            if (Global.Money >= 500)
            {
                Global.Money           -= 500;
                Global.NumberOfRockets += 1;

                SetMenuEntryText();
                SetShopText();

                //playing the sound
                SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);
            }
            else
            {
                //playing the sound
                SoundEngine.Play2D("MenuDenieSound", Global.SpeakerVolume / 10, false);
            }
        }
        public void PlaySound(/*Vector3 sourcePosition,*/ bool resume, bool playLooped = false, bool playPaused = false, bool allowMultipleInstances = false, bool allowSoundEffects = false)
        {
            if (allowMultipleInstances || (!allowMultipleInstances && (Sound == null || Sound != null && (Sound.Finished || IsPaused))))
            {
                // Vector3D sourcePos = SoundHelperIK.Vector3ToVector3D(GameplayCamera.GetOffsetFromWorldCoords(sourcePosition));

                if (resume && IsPaused)
                {
                    IsPaused = false;
                    return;
                }

                // Sound = SoundEngine.Play3D(Source, sourcePos.X, sourcePos.Y, sourcePos.Z, playLooped, false, false);
                Sound = SoundEngine.Play2D(Source, playLooped, true, allowSoundEffects);

                if (Sound == null)
                {
                    return;
                }

                // Attempt to avoid popping..
                Sound.Volume = 0f;

                if (!playPaused)
                {
                    Sound.Paused = false;
                }

                Sound.Volume = Source.DefaultVolume;

                if (Length == 0)
                {
                    //Length = Source.PlayLength;
                    Length = Sound.PlayLength;
                }
                if (allowSoundEffects)
                {
                    SoundEffect = Sound.SoundEffectControl;
                }
            }
        }
        void sShieldMenuEntrySelected(object sender, EventArgs e)
        {
            if (Global.Money >= _priceStationShield)
            {
                _StationShieldLevel++;
                Global.Money -= _priceStationShield;

                this._station._maxShield += 500;

                SetMenuEntryText();
                SetShopText();

                //playing the sound
                SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);
            }
            else
            {
                //playing the sound
                SoundEngine.Play2D("MenuDenieSound", Global.SpeakerVolume / 10, false);
            }
        }
        // Event handler for when the Damage menu entry is selected.
        void damageMenuEntrySelected(object sender, EventArgs e)
        {
            if (Global.Money >= _priceDMG)
            {
                _droneDamageLevel++;
                Global.Money -= _priceDMG;

                Global.DroneDmg        += 10;
                Global.DroneBulletColor = new Color(_rand.Next(100, 200), _rand.Next(100, 200), _rand.Next(100, 200), 255);
                SetMenuEntryText();
                SetShopText();

                //playing the sound
                SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);
            }
            else
            {
                //playing the sound
                SoundEngine.Play2D("MenuDenieSound", Global.SpeakerVolume / 10, false);
            }
        }
        // Event handler for when the Health menu entry is selected.
        void healthMenuEntrySelected(object sender, EventArgs e)
        {
            if (Global.Money >= _priceDroneHealth)
            {
                _droneHealthLevel++;
                Global.Money -= _priceDroneHealth;

                this._droneFleet._maxHealth += 100;
                _droneFleet.GetActiveDrone().health += 100;

                SetMenuEntryText();
                SetShopText();

                //playing the sound
                SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);
            }
            else
            {
                //playing the sound
                SoundEngine.Play2D("MenuDenieSound", Global.SpeakerVolume / 10, false);
            }
        }
 protected override void OnCancel()
 {
     //playing the sound
     SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);
     ScreenManager.AddScreen(new MainMenuScreen());
 }
 // Event handler for when the Gameplay menu entry is selected.
 void GameplayMenuEntrySelected(object sender, EventArgs e)
 {
     Global.DemoMode = "Gameplay";
     SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);
     LoadingScreen.Load(ScreenManager, true, new DemoTutorialScreen());
 }
 // Event handler for when the Play Game menu entry is selected.
 void PlayGameMenuEntrySelected(object sender, EventArgs e)
 {
     //playing the sound
     SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);
 }
        public override void HandleInput(InputState input)
        {
            // mouse click on menu?
            if (input.IsLeftMouseButtonNewPressed())
            {
                Vector2 cornerA;
                Vector2 cornerD;
                for (int i = 0; i < MenuEntries.Count; i++)
                {
                    //calculating 2 diagonal corners of current menuEntry (upper left, bottom right)
                    cornerA    = MenuEntries[i].Position;
                    cornerA.Y -= MenuEntries[i].GetHeight() / 2f;

                    cornerD    = MenuEntries[i].Position;
                    cornerD.Y += MenuEntries[i].GetHeight() / 2f;
                    cornerD.X += MenuEntries[i].GetWidth();

                    if (cornerA.X < input.MousePosition.X && cornerA.Y < input.MousePosition.Z)
                    {
                        if (cornerD.X > input.MousePosition.X && cornerD.Y > input.MousePosition.Z)
                        {
                            // doesnt buy stuff with first click on it
                            if (selectedEntry == i)
                            {
                                OnSelectEntry(selectedEntry);
                            }

                            //playing the sound
                            if (selectedEntry != i)
                            {
                                SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);
                            }

                            // menuEntry needs one click
                            selectedEntry = i;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            // Move to the previous menu entry?
            if (input.IsMenuUp())
            {
                //playing the sound
                SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);

                selectedEntry--;

                if (selectedEntry < 0)
                {
                    selectedEntry = MenuEntries.Count - 1;
                }
            }
            // Move to the next menu entry?
            if (input.IsMenuDown())
            {
                //playing the sound
                SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);

                selectedEntry++;

                if (selectedEntry >= MenuEntries.Count)
                {
                    selectedEntry = 0;
                }
            }
            // Accept or cancel the menu.
            if (input.IsMenuSelect())
            {
                OnSelectEntry(selectedEntry);
            }
            else if (input.IsMenuCancel() || input.IsNewKeyPress(Keys.B))
            {
                OnCancel();
            }
        }
        public override void HandleInput(InputState input)
        {
            // mouse click on menu?
            if (input.IsLeftMouseButtonNewPressed())
            {
                Vector2 cornerA;
                Vector2 cornerD;
                for (int i = 0; i < MenuEntries.Count; i++)
                {
                    //calculating 2 diagonal corners of current menuEntry (upper left, bottom right)
                    cornerA    = MenuEntries[i].Position;
                    cornerA.Y -= MenuEntries[i].GetHeight() / 2f;

                    cornerD    = MenuEntries[i].Position;
                    cornerD.Y += MenuEntries[i].GetHeight() / 2f;
                    cornerD.X += MenuEntries[i].GetWidth();

                    if (cornerA.X < input.MousePosition.X && cornerA.Y < input.MousePosition.Z)
                    {
                        if (cornerD.X > input.MousePosition.X && cornerD.Y > input.MousePosition.Z)
                        {
                            // menuEntry needs one click
                            selectedEntry = i;
                            if (optionMenuEntries[selectedEntry].Equals(back))
                            {
                                OnSelectEntry(selectedEntry);
                            }
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            // Move to the previous menu entry?
            if (input.IsMenuUp())
            {
                //playing the sound
                SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);

                selectedEntry--;

                if (selectedEntry < 0)
                {
                    selectedEntry = MenuEntries.Count - 1;
                }
            }

            // Move to the next menu entry?
            if (input.IsMenuDown())
            {
                //playing the sound
                SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);

                selectedEntry++;

                if (selectedEntry >= MenuEntries.Count)
                {
                    selectedEntry = 0;
                }
            }

            //cancel the menu.
            if (input.IsMenuSelect())
            {
                OnSelectEntry(selectedEntry);
            }
            else if (input.IsMenuCancel())
            {
                OnCancel();
            }

            // checks for increase or decrease
            if (lastSelectedEntry == selectedEntry)
            {
                if (input.IsNewKeyPress(Keys.Left) || input.IsLeftMouseButtonNewPressed())
                {
                    OnSelectEntryDecrease(selectedEntry);
                }

                if (input.IsNewKeyPress(Keys.Right) || input.IsRightMouseButtonNewPressed())
                {
                    OnSelectEntryIncrease(selectedEntry);
                }
            }
        }
        public override void HandleInput(InputState input)
        {
            if (!_enter)
            {
                // mouse click on menu?
                if (input.IsLeftMouseButtonNewPressed())
                {
                    Vector2 cornerA;
                    Vector2 cornerD;
                    for (int i = 0; i < MenuEntries.Count; i++)
                    {
                        //calculating 2 diagonal corners of current menuEntry (upper left, bottom right)
                        cornerA    = MenuEntries[i].Position;
                        cornerA.Y -= MenuEntries[i].GetHeight() / 2f;

                        cornerD    = MenuEntries[i].Position;
                        cornerD.Y += MenuEntries[i].GetHeight() / 2f;
                        cornerD.X += MenuEntries[i].GetWidth();

                        if (cornerA.X < input.MousePosition.X && cornerA.Y < input.MousePosition.Z)
                        {
                            if (cornerD.X > input.MousePosition.X && cornerD.Y > input.MousePosition.Z)
                            {
                                // menuEntry needs a double click

                                /*
                                 * if (selectedEntry == i)
                                 * {
                                 *  OnSelectEntry(selectedEntry);
                                 * }
                                 * else selectedEntry = i;
                                 */

                                // menuEntry needs one click
                                selectedEntry = i;
                                OnSelectEntry(selectedEntry);
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                }

                // Move to the previous menu entry?
                if (input.IsMenuUp())
                {
                    //playing the sound
                    SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);

                    selectedEntry--;

                    if (selectedEntry < 0)
                    {
                        selectedEntry = MenuEntries.Count - 1;
                    }
                }

                // Move to the next menu entry?
                if (input.IsMenuDown())
                {
                    //playing the sound
                    SoundEngine.Play2D("MenuAcceptSound", Global.SpeakerVolume / 10, false);

                    selectedEntry++;

                    if (selectedEntry >= MenuEntries.Count)
                    {
                        selectedEntry = 0;
                    }
                }

                // Accept or cancel the menu.
                if (input.IsMenuSelect())
                {
                    Global.MusicEngine.StopAllSounds();
                    Global.Music = Global.MusicEngine.Play2D("Unrelenting", Global.MusicVolume / 10, false);
                    OnSelectEntry(selectedEntry);
                }
                else if (input.IsMenuCancel())
                {
                    OnCancel();
                    Global.MusicEngine.StopAllSounds();
                    Global.Music = Global.MusicEngine.Play2D("Unrelenting", Global.MusicVolume / 10, false);
                }
            }
        }
 // Event handler for when the user selects ok on the "are you sure
 // you want to exit" message box.
 void ConfirmExitMessageBoxAccepted(object sender, EventArgs e)
 {
     //playing the sound
     SoundEngine.Play2D("OkClick", Global.SpeakerVolume / 10, false);
     ScreenManager.Game.Exit();
 }