コード例 #1
0
        private void GeneratingAsteroids(IDraw system)
        {
            Random posRandom = new Random();
            Random velRandom = new Random();
            int asteroidsCount = posRandom.Next(10, 30);
            for (int i = 0; i < asteroidsCount; i++)
            {
                float size = posRandom.Next(100, 500);
                float mass = size * 10;
                float astSize = (float)(500 - size) / 500;
                astSize = 0.15f * astSize;
                astSize = 0.3f - astSize;
                Asteroid ast = new Asteroid(Content.Load<Texture2D>("Asteroids/" +
                    asteroidTextures[new Random().Next(0, asteroidTextures.Length)]),
                    new Vector2(posRandom.Next(100, 1900), posRandom.Next(100, 1900)), new Vector2(astSize), mass);
                ast.Size = size;
                ast.Name = ConstructName();
                ast.Velocity = new Vector2((float)velRandom.Next(-3, 4) / 10, (float)velRandom.Next(-3, 4) / 10);

                if (system is SolarSystem)
                {
                    system.ToSolarSystem().Objects.Add(ast);
                }
                else
                {
                    system.ToBlackHoleSystem().Objects.Add(ast);
                }
            }
        }