Example #1
0
        public override void Update(GameTime gameTime)
        {
            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                _particleEngine.EngineEnable = true;
                _particleEngine.Position     = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
            }
            else
            {
                _particleEngine.EngineEnable = false;
            }

            _particleEngine.Update();
        }
Example #2
0
        /// <summary>
        /// Update game state and all content.  Should be called once every redraw, possibly called
        /// more often than the draws but only if it exceeds time between frame draws.
        /// </summary>
        /// <param name="gameTime">Current time information of the application</param>
        protected override void Update(GameTime gameTime)
        {
            cDevConsole.Update(gameTime);
            cSparkles.Update(gameTime);

            cShowingLbl.Text = String.Format("Showing {0} Particles", cSparkles.ParticleList.Count);
            cShowingLbl.Update(gameTime);
            cSettingsCont.Update(gameTime);
            cAddParitclesBtn.Update(gameTime);
            cNumParticlesLbl.Update(gameTime);
            cNumParticlesTxt.Update(gameTime);
            cHeightLbl.Update(gameTime);
            cHeightMinTxt.Update(gameTime);
            cHeightMaxTxt.Update(gameTime);
            cWidthLbl.Update(gameTime);
            cWidthMinTxt.Update(gameTime);
            cWidthMaxTxt.Update(gameTime);
            cRedLbl.Update(gameTime);
            cRedMinTxt.Update(gameTime);
            cRedMaxTxt.Update(gameTime);
            cGreenLbl.Update(gameTime);
            cGreenMinTxt.Update(gameTime);
            cGreenMaxTxt.Update(gameTime);
            cBlueLbl.Update(gameTime);
            cBlueMinTxt.Update(gameTime);
            cBlueMaxTxt.Update(gameTime);
            cLifeLbl.Update(gameTime);
            cLifeMinTxt.Update(gameTime);
            cLifeMaxTxt.Update(gameTime);
            cDelayLbl.Update(gameTime);
            cDelayMinTxt.Update(gameTime);
            cDelayMaxTxt.Update(gameTime);
            cXDistLbl.Update(gameTime);
            cXDistMinTxt.Update(gameTime);
            cXDistMaxTxt.Update(gameTime);
            cYDistLbl.Update(gameTime);
            cYDistMinTxt.Update(gameTime);
            cYDistMaxTxt.Update(gameTime);
            cRotateLbl.Update(gameTime);
            cRotateMinTxt.Update(gameTime);
            cRotateMaxTxt.Update(gameTime);
            cRotateAfterBtn.Update(gameTime);
            cAlphaFadeBtn.Update(gameTime);

            //Use monogame update
            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            _particleEngine.Position = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);

            _particleEngine.Update();
        }
Example #4
0
        protected override void Update(GameTime gameTime)
        {
            KeyboardState CurrKeys = Keyboard.GetState();
            MouseState    CurrMouse = Mouse.GetState();
            Particle2D    BulletInfo, EnemyInfo;
            List <int>    ParticlesToRemove = new List <int>();
            int           Ctr, Cnt;

            if (cAliveSince == 0)
            {
                cAliveSince = (uint)gameTime.TotalGameTime.TotalSeconds;
            }

            if (cLastAsteroid < gameTime.TotalGameTime.TotalMilliseconds)               //Create new asteroid
            {
                if ((cSpawnNum % 3 != 0) && (cEnemyKills >= cAsteroids.ParticleList.Count))
                {
                    for (Ctr = 0; Ctr < 1 + (cEnemyKills / 20); Ctr++)
                    {
                        CreateNewAsteroid(100, new Vector2(-1, -1));
                    }
                }
                else
                {
                    Vector2 StartPos;

                    StartPos.X = (float)(cRandom.NextDouble() * cGraphDevMgr.GraphicsDevice.Viewport.Width);
                    StartPos.Y = cRandom.Next(-2, 1) * 60;

                    if (StartPos.Y == 0)
                    {
                        StartPos.Y = cGraphDevMgr.GraphicsDevice.Viewport.Height;
                    }

                    CreateNewHunter(60, StartPos);
                }

                cSpawnNum++;
                cLastAsteroid = gameTime.TotalGameTime.TotalMilliseconds + 2000;
            }

            //Check for player input
            Ctr = (int)(500 - cEnemyKillsMax);             //Calculate the minimum time between shots
            if (Ctr > 400)
            {
                Ctr = 400;
            }
            else if (Ctr < 100)
            {
                Ctr = 50;
            }

            if (((CurrKeys.IsKeyDown(Keys.Space) == true) || (CurrMouse.LeftButton == ButtonState.Pressed)) && (cLastShot < gameTime.TotalGameTime.TotalMilliseconds - Ctr))
            {
                PlayerFireBullet();

                cLastShot = gameTime.TotalGameTime.TotalMilliseconds;
            }

            if ((CurrKeys.IsKeyDown(Keys.OemTilde) == true) && (cPriorKeyState.IsKeyDown(Keys.OemTilde) == false))
            {
                cDevConsole.ToggleVisible();
            }

            cUFOs.Update(gameTime);
            cAsteroids.Update(gameTime);
            cEnemyBullets.Update(gameTime);
            cPlayerBullets.Update(gameTime);
            cPlayerShip.Update(gameTime, CurrKeys, CurrMouse);
            cSparkles.Update(gameTime);
            cDevConsole.Update(gameTime, CurrKeys, CurrMouse);

            //Collision detection
            cPlayerShip.ImageTint = Color.White;
            for (Cnt = 0; Cnt < cAsteroids.ParticleList.Count; Cnt++)
            {
                EnemyInfo = (Particle2D)cAsteroids.ParticleList[Cnt];

                //Are bullts hitting the asteroid?
                for (Ctr = 0; Ctr < cPlayerBullets.ParticleList.Count; Ctr++)
                {
                    BulletInfo = (Particle2D)cPlayerBullets.ParticleList[Ctr];

                    if (BulletInfo.TestCollision(EnemyInfo.GetCollisionRegions()) == true)
                    {
                        CreateParticleBurst(new Vector2(EnemyInfo.TopLeft.X + (EnemyInfo.Width / 2), EnemyInfo.TopLeft.Y + (EnemyInfo.Height / 2)), 25 * EnemyInfo.Height / 6, EnemyInfo.Height / 3, Color.SaddleBrown, cTextureDict[Textures.Dust]);

                        //Spawn little asteroids
                        if (EnemyInfo.Height > 50)
                        {
                            Vector2 TopLeft;

                            TopLeft.X = EnemyInfo.TopLeft.X + (EnemyInfo.Width / 2) - (EnemyInfo.Width * 0.35f);
                            TopLeft.Y = EnemyInfo.TopLeft.Y + (EnemyInfo.Height / 2) - (EnemyInfo.Height * 0.35f);

                            CreateNewAsteroid((int)(EnemyInfo.Width * 0.7f), TopLeft);
                            CreateNewAsteroid((int)(EnemyInfo.Width * 0.7f), TopLeft);
                        }

                        //Destroy shot and large asteroid
                        ParticlesToRemove.Add(Cnt);
                        cPlayerBullets.ParticleList.RemoveAt(Ctr);
                        cEnemyKills++;

                        break;                         //Exit inner loop so each bullet ony gets 1 asteroid
                    }
                }

                //Is the asteroid hitting the player?
                if (EnemyInfo.TestCollision(cPlayerShip) == true)
                {
                    cPlayerShip.ImageTint = Color.Red;

                    CreateParticleBurst(new Vector2(EnemyInfo.TopLeft.X + (EnemyInfo.Width / 2), EnemyInfo.TopLeft.Y + (EnemyInfo.Height / 2)), 25 * EnemyInfo.Height / 6, EnemyInfo.Height / 3, Color.SaddleBrown, cTextureDict[Textures.Dust]);

                    //Spawn little asteroids
                    if (EnemyInfo.Height > 50)
                    {
                        Vector2 TopLeft;

                        TopLeft.X = EnemyInfo.TopLeft.X + (EnemyInfo.Width / 2) - (EnemyInfo.Width * 0.35f);
                        TopLeft.Y = EnemyInfo.TopLeft.Y + (EnemyInfo.Height / 2) - (EnemyInfo.Height * 0.35f);

                        CreateNewAsteroid((int)(EnemyInfo.Width * 0.7f), TopLeft);
                        CreateNewAsteroid((int)(EnemyInfo.Width * 0.7f), TopLeft);
                    }

                    //Destroy asteroid
                    ParticlesToRemove.Add(Cnt);

                    PlayerHit(gameTime);
                }
            }

            for (Cnt = ParticlesToRemove.Count - 1; Cnt >= 0; Cnt--)
            {
                cAsteroids.ParticleList.RemoveAt(ParticlesToRemove[Cnt]);
            }
            ParticlesToRemove.Clear();

            for (Cnt = 0; Cnt < cUFOs.ParticleList.Count; Cnt++)
            {
                EnemyInfo = (Particle2D)cUFOs.ParticleList[Cnt];

                //Are bullts hitting the UFO?
                for (Ctr = 0; Ctr < cPlayerBullets.ParticleList.Count; Ctr++)
                {
                    BulletInfo = (Particle2D)cPlayerBullets.ParticleList[Ctr];

                    if (BulletInfo.TestCollision(EnemyInfo.GetCollisionRegions()) == true)
                    {
                        //Destroy shot and UFO
                        cPlayerBullets.ParticleList.RemoveAt(Ctr);
                        ParticlesToRemove.Add(Cnt);
                        cEnemyKills++;

                        CreateParticleBurst(new Vector2(EnemyInfo.TopLeft.X + (EnemyInfo.Width / 2), EnemyInfo.TopLeft.Y + (EnemyInfo.Height / 2)), 200, Color.OrangeRed);

                        break;                         //Exit inner loop so each bullet ony gets 1 enemy
                    }
                }

                //Is the UFO hitting the player?
                if (EnemyInfo.TestCollision(cPlayerShip) == true)
                {
                    cPlayerShip.ImageTint = Color.Red;

                    PlayerHit(gameTime);
                }
            }

            for (Cnt = ParticlesToRemove.Count - 1; Cnt >= 0; Cnt--)
            {
                cUFOs.ParticleList.RemoveAt(ParticlesToRemove[Cnt]);
            }

            for (Cnt = 0; Cnt < cEnemyBullets.ParticleList.Count; Cnt++)
            {
                BulletInfo = (Particle2D)cEnemyBullets.ParticleList[Cnt];

                //Is the bullet hitting the player?
                if (BulletInfo.TestCollision(cPlayerShip) == true)
                {
                    cEnemyBullets.ParticleList.RemoveAt(Cnt);

                    PlayerHit(gameTime);
                }
            }

            cPriorKeyState = CurrKeys;

            //Use monogame update
            base.Update(gameTime);
        }