Exemplo n.º 1
0
        /// <summary>
        /// Applies the appropriate effect depending on the type and displays a message
        /// </summary>
        /// <param name="p">Piranha object to apply the effect to (only for heals)</param>
        public void ApplyEffect(Piranha p)
        {
            if (!_isActive)
            {
                return;             // Prevent applying the effect more than once
            }
            switch (_type)
            {
            case PowerUpType.Heal5:
                if (p.Health + 5 >= 100)
                {
                    p.Health = 100;
                }
                else
                {
                    p.Health += 5;
                }
                Functions.Alert.Show("Health +5", Color.PaleGreen);
                break;

            case PowerUpType.Heal10:
                if (p.Health + 10 >= 100)
                {
                    p.Health = 100;
                }
                else
                {
                    p.Health += 10;
                }
                Functions.Alert.Show("Health +10", Color.PaleGreen);
                break;

            case PowerUpType.Heal25:
                if (p.Health + 25 >= 100)
                {
                    p.Health = 100;
                }
                else
                {
                    p.Health += 25;
                }
                Functions.Alert.Show("Health +25", Color.PaleGreen);
                break;

            case PowerUpType.NoChase:
                Functions.NoChaseActive = true;
                Functions.Alert.Show("No-chase activated", Color.RoyalBlue);
                break;

            case PowerUpType.Repel:
                Functions.RepelActive = true;
                Functions.Alert.Show("Repel activated", Color.LightPink);
                break;

            case PowerUpType.SlowFish:
                Functions.SlowFishActive = true;
                Functions.Alert.Show("Slow fish activated", Color.Yellow);
                break;

            case PowerUpType.SlowMines:
                Functions.SlowMinesActive = true;
                Functions.Alert.Show("Slow mines activated", Color.Salmon);
                break;
            }
            this._isActive = false;
            _effectEnd     = DateTime.Now + TimeSpan.FromSeconds(20);
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        public override void LoadContent()
        {
            if (Content == null)
            {
                Content = new ContentManager(ScreenManager.Game.Services, "Content");
            }
            // Save local copy of SpriteBatch, which can be used to draw textures.
            spriteBatch = ScreenManager.SpriteBatch;

            #region Load random things
            spriteFont       = Content.Load <SpriteFont>("Fonts/menufont");
            powerUpFont      = Content.Load <SpriteFont>("Fonts/PowerUpFont");
            refractionEffect = Content.Load <Effect>("Refraction");
            #endregion

            #region Load Sounds
            backgroundSound = Content.Load <SoundEffect>("Sounds/backgroundSound");
            whaleSound      = Content.Load <SoundEffect>("Sounds/whaleSound");
            biteSound       = Content.Load <SoundEffect>("Sounds/biteSound");
            hurtSound       = Content.Load <SoundEffect>("Sounds/hurtSound");
            powerUpSound    = Content.Load <SoundEffect>("Sounds/powerUpSound");
            #endregion

            #region Load Texture2D's
            gameBackground   = Content.Load <Texture2D>("gamebg");
            fog              = Content.Load <Texture2D>("fog");
            blank            = Content.Load <Texture2D>("blank");
            bloodTex         = Content.Load <Texture2D>("Sprites/Blood");
            waterfallTexture = Content.Load <Texture2D>("waterfall");
            piranha          = new Piranha(Content.Load <Texture2D>("Sprites/Piranha"));
            Texture2D fishTex = Content.Load <Texture2D>("Sprites/Fish");
            Texture2D mineTex = Content.Load <Texture2D>("Sprites/Mine");
            #endregion

            #region Assign values to global variables
            Functions.GameSize = new Point(ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
            Functions.Player   = piranha;
            #endregion

            #region Set-up other objects
            for (int x = 0; x < numFish[maxLevel - 1]; x++)
            {
                fish.Add(new Fish(fishTex, Functions.RandScreenPos()));
            }

            for (int x = 0; x < numMines[maxLevel - 1]; x++)
            {
                mines.Add(new Mine(mineTex));
            }

            foreach (Mine mine in mines)
            {
                fishAvoids.Add(mine);
            }
            fishAvoids.Add(piranha);

            powerUp = new PowerUp(PowerUpType.Heal5);
            #endregion

            #region Set up background sound
            backgroundSoundInstance          = backgroundSound.CreateInstance();
            backgroundSoundInstance.IsLooped = true;
            backgroundSoundInstance.Volume   = 0.1f;
            #endregion

            // Reset everything and prepare the game/level
            ResetGame();
            ScreenManager.Game.ResetElapsedTime();
        }