Пример #1
0
        public PlanetData[] Generate(int count, IPlanetGenerationSettings settings)
        {
            var planets              = new PlanetData[count];
            var orbitRadiusVariance  = settings.MaxOrbitDistanceX - settings.MinOrbitDistanceX;
            var radiusVariance       = settings.MaxRadius - settings.MinRadius;
            var displacementVariance = settings.MaxAngularDisplacement - settings.MinAngularDisplacement;
            var stepFactor           = 1f / planets.Length;

            for (var i = 0; i < planets.Length; i++)
            {
                var item = planets[i] = new PlanetData();
                var step = i + 1;
                item.OrbitRadius         = settings.MinOrbitDistanceX + orbitRadiusVariance * stepFactor * step;
                item.Radius              = settings.MinRadius + radiusVariance * stepFactor * step;
                item.OrbitScaleX         = settings.OrbitScaleY;
                item.AngularDisplacement = settings.MinAngularDisplacement +
                                           settings.MaxAngularDisplacement * stepFactor * step;
            }

            return(planets);
        }
Пример #2
0
 public Vector2 Resolve(PlanetData planetData, float time, IPlanetGenerationSettings settings)
 {
     return(new Vector2(planetData.OrbitRadius * Mathf.Sin(time * planetData.AngularDisplacement),
                        planetData.OrbitRadius * Mathf.Cos(time * planetData.AngularDisplacement) *
                        settings.OrbitScaleY));
 }