示例#1
0
        public void LoadContent()
        {
            //TODO maybe clean this up maybe not

            var removeList = new List <Asteroid>();

            for (var i = 0; i < AsteroidList.Count; i++)
            {
                if (i % 2 == 0)
                {
                    AsteroidList[i].Model = _content.Load <Model>("Models/asteroid");
                }
                else
                {
                    AsteroidList[i].Model = _content.Load <Model>("Models/asteroid2");
                }
            }

            foreach (var asteroid in AsteroidList)
            {
                foreach (var ast in AsteroidList)
                {
                    if (!ast.Equals(asteroid) && Collider3D.Intersection(asteroid, ast))
                    {
                        removeList.Add(ast);
                    }
                }
            }
            foreach (var asteroid in removeList)
            {
                AsteroidList.Remove(asteroid);
            }
        }
示例#2
0
        public void Update(GameTime gameTime)
        {
            var removeList = new List <Asteroid>();

            foreach (var asteroid in AsteroidList)
            {
                asteroid.Update(gameTime);
            }
            foreach (var asteroid in AsteroidList)
            {
                if (asteroid.Position.X > 200)
                {
                    removeList.Add(asteroid);
                }
                foreach (var ast in AsteroidList)
                {
                    if (Collider3D.Intersection(asteroid, ast) && !ast.Equals(asteroid))
                    {
                        removeList.Add(ast);
                    }
                }
            }
            foreach (var asteroid in removeList)
            {
                AsteroidList.Remove(asteroid);
            }
            if (gameTime.TotalGameTime.Milliseconds % 60000 == 0)
            {
                InitializeChunk();
            }
        }
示例#3
0
        private void InitializeChunk()
        {
            var addList    = new List <Asteroid>();
            var removeList = new List <Asteroid>();

            for (var i = 0; i < 15; i++)
            {
                var rx = _random.Next(-200, -150);
                var rz = _random.Next(-100, 100);
                var r  = _random.Next(-2, 1);

                var vec = new Vector3(rx, 20, rz);
                var a   = new Asteroid(vec);

                if (r < 0)
                {
                    a.Model = _content.Load <Model>("Models/asteroid");
                }
                else if (r >= 0)
                {
                    a.Model = _content.Load <Model>("Models/asteroid2");
                }
                addList.Add(a);
            }

            foreach (var asteroid in AsteroidList)
            {
                foreach (var ast in AsteroidList)
                {
                    if (!ast.Equals(asteroid) && Collider3D.Intersection(asteroid, ast))
                    {
                        removeList.Add(ast);
                    }
                }
            }
            foreach (var asteroid in removeList)
            {
                addList.Remove(asteroid);
            }
            AsteroidList.AddRange(addList);
        }