コード例 #1
0
        public void Update(GameTime gameTime)
        {
            EnemyShotManager.Update(gameTime);

            for (int x = Enemies.Count - 1; x >= 0; x--)
            {
                Enemies[x].Update(gameTime);
                if (Enemies[x].IsActive() == false)
                {
                    Enemies.RemoveAt(x);
                }
                else
                {
                    if ((float)rand.Next(0, 1000) / 100 <= shipShotChance)
                    {
                        Vector2 fireLoc = Enemies[x].EnemySprite.Location;
                        fireLoc += Enemies[x].gunOffset;
                        //fire the shot at the direction of the player
                        Vector2 shotDirection =
                            playerManager.playerSprite.Center - fireLoc;

                        shotDirection.Normalize();
                        EnemyShotManager.FireShot(fireLoc, shotDirection, false);
                    }
                }
            }
            //Increases Difficulty
            if (playerManager.PlayerScore >= 1500)
            {
                HardState(gameTime);
                EnemyShotManager.Update(gameTime);
            }

            if (playerManager.PlayerScore >= 2500)
            {
                VeryHardState(gameTime);
                EnemyShotManager.Update(gameTime);
            }

            if (playerManager.PlayerScore >= 5000)
            {
                ImpossibleState(gameTime);
                EnemyShotManager.Update(gameTime);
            }

            if (Active)
            {
                updateWaveSpawns(gameTime);
            }
        }
コード例 #2
0
        public void Update(GameTime gameTime)
        {
            PlayerShotManager.Update(gameTime);
            lastmouseState = mouseState;
            mouseState     = Mouse.GetState();
            if (MousePosition != new Vector2(lastmouseState.X, lastmouseState.Y))
            {
                ;
            }

            if (!Destroyed)
            {
                //if destroyed then all those below will not be updated
                shotTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
                playerSprite.Velocity.Normalize();
                playerSprite.Velocity *= playerSpeed;
                playerSprite.Update(gameTime);
                playerSprite.Velocity = Vector2.Zero;
            }
        }