示例#1
0
 private void SpawnAsteroids()
 {
     if (level.Enemies.Count < ASTEROID_MAX_SPAWN_NUM) {// = 15 -5
         float radius = 3000;
         Asteroid a = new Asteroid(new Vector3(NextDouble(random, -radius, radius)
             , 0, NextDouble(random, -radius, radius)), level.sun.Position, 0.05f, "Models\\Asteroid");
         //Asteroids[i].Scale = 0.02f;//0.1f;
         //a.SetModelEffect(shadowEffect, true);					// set effect to each modelmeshpart
         a.IsActive = true;
         a.RenderBoudingSphere = false;
         level.Enemies.Add(a);
         level.Models.Add(a);
     }
 }
示例#2
0
        public override void Update(GameTime gameTime)
        {
            float elapsed = (float)gameTime.TotalGameTime.TotalSeconds;
            count++;
            /*if (count % 1001 >= 0 && Asteroids.Count == 0) {
                spawned = false;
                count = 0;
            }
            if (!spawned) {
                AddAsteroids(15, 2000);
                for (int i = 0; i < Asteroids.Count; i++) {
                    Asteroids[i].IsActive = true;
                    Asteroids[i].RenderBoudingSphere = false;
                    Asteroids[i].SetModelEffect(shadowEffect, true);
                    Models.Add(Asteroids[i]);
                }
                spawned = true;
            }*/
            if (Asteroids.Count < 15) {// = 15 -5
                float radius = 3000;
                Asteroid a = new Asteroid(new Vector3(NextDouble(random, -radius, radius), 0, NextDouble(random, -radius, radius)), star.Position, 0.05f, "Models\\Asteroid");
                //Asteroids[i].Scale = 0.02f;//0.1f;
                a.SetModelEffect(shadowEffect, true);					// set effect to each modelmeshpart
                a.IsActive = true;
                a.RenderBoudingSphere = false;
                Asteroids.Add(a);
                Models.Add(a);
            }

            base.Update(gameTime);

            //camera.UpdateChaseTarget(Vector3.Zero);
            //camera.UpdateChaseTarget(tmpCameraPos);
            camera.Update(gameTime);
            renderer.Update(gameTime);
            LightPosition = renderer.Lights[0].Position;

            Sky.Update(gameTime);
            sun.Update(gameTime);
            sunCircle.Position = renderer.Lights[0].Position;
            sunCircle.Update(gameTime);

            foreach (Object o in Models) {
                if (o.IsActive) o.Update(gameTime);
            }
            /*foreach (Object a in Asteroids) {
                if (a.IsActive) a.Update(gameTime);
            }*/
            foreach (Drawable b in Bullets) {
                if (b.IsActive) b.Update(gameTime);
            }

            if (planet.IsActive) planet.Update(gameTime);

            //discoidEffect.Update(gameTime);

            //shieldEffect.Position = Satellite.Position;
            //shieldEffect.Update(gameTime);

            //explosionTest.Update(gameTime);
            //bigExplosion.Update(gameTime);
            lb.Update(gameTime);

            Collide();

            effectManager.Update(gameTime);
        }