public NebulaFieldsWorker(StarGenerator starGenerator, Settings spreadContract, GalaxyMap map, System.Windows.Forms.TextBox textbox = null)
        {
            stars         = new List <Star>();
            StarGenerator = starGenerator;
            Contract      = spreadContract;

            StarsPerPlayer      = Contract.StarsPerPlayer;
            minDistance         = Contract.minDistance;
            distanceBetweenSuns = Contract.distanceBetweenSuns;
            starsInRow          = Contract.starsInRow;
            xAxis = Contract.xAxis;

            Textbox = textbox;
            Map     = map;

            //used to get the IDs of the neighbouring stars
            neighbours.Add((-starsInRow) - 1);
            neighbours.Add((-starsInRow));
            neighbours.Add((-starsInRow) + 1);

            neighbours.Add(-1);
            neighbours.Add(1);

            neighbours.Add(starsInRow - 1);
            neighbours.Add(starsInRow);
            neighbours.Add(starsInRow + 1);
        }
    private void Start()
    {
        // get references
        backgroundSphere = transform.Find("BackgroundSphere").GetComponent <MeshRenderer>();
        nebulaMat        = backgroundSphere.sharedMaterial;
        planetAnchor     = transform.Find("PlanetAnchor");
        MeshRenderer planetMR = planetAnchor.GetComponentInChildren <MeshRenderer>();

        //planetMat = new Material(planetMR.sharedMaterial);
        planetMat         = new Material(planetMaterials[Random.Range(0, planetMaterials.Length)]);
        planetMR.material = planetMat;

        if (regeneratePointStars)
        {
            Texture2D pointStars = StarGenerator.GeneratePointStars(width, starDensity, starBrightness, backgroundColor);
            backgroundSphere.material.mainTexture = pointStars;

            // save the texture
            SaveTextureAsPNG(pointStars, "pointStars");
        }

        RandomizeNebula();
        RandomizePlanet();

        //CaptureBackground();
        StartCoroutine(CaptureNextFrame());
    }
        public SpiralWorker(StarGenerator starGenerator,
                            GalaxyMap map,
                            System.Windows.Forms.TextBox textbox = null,
                            int _starsPerArm            = 1000,
                            int _nebulaPerArm           = 1000,
                            int _Arms                   = 8,
                            float _spin                 = 1.8f,
                            double _armspread           = 0.03d,
                            double _nebulaspread        = 0.03d,
                            double _starsAtCenterRatio  = 0.6d,
                            double _nebulaAtCenterRatio = 0.6d,
                            float _mapSize              = 500.0f
                            )
        {
            StarGenerator = starGenerator;
            //stars = _stars;
            Map = map;

            Textbox = textbox;

            starsPerArm         = _starsPerArm;
            nebulaPerArm        = _nebulaPerArm;
            Arms                = _Arms;
            spin                = _spin;
            armspread           = _armspread;
            nebulaspread        = _nebulaspread;
            starsAtCenterRatio  = _starsAtCenterRatio;
            nebulaAtCenterRatio = _nebulaAtCenterRatio;
            mapSize             = _mapSize;
        }
Exemple #4
0
        public static SpaceSystem GeneratePlanetarySystem()
        {
            SpaceSystem system = new SpaceSystem();

            string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

            string Designation1 = $"{alphabet[RandomNumberGenerator.Range(0, 25)]}{alphabet[RandomNumberGenerator.Range(0, 25)]}";
            string Designation2 = $"{RandomNumberGenerator.Range(0, 999)}";

            system.Name  = $"{Designation1}-{Designation2}";
            system.Speed = 5f;

            system.Bodies = new IBody[RandomNumberGenerator.Range(1, maxPlanets)];

            system.Star      = StarGenerator.Generate();
            system.Name      = system.Name;
            system.Bodies[0] = system.Star;

            for (int i = 1; i < system.Bodies.Length; i++)
            {
                system.Bodies[i] = generatePlanet($"{system.Name} {i}", system.Star);
            }

            return(system);
        }
        public static StellarSystem Generate(int x, int y)
        {
            var output = new StellarSystem();

            output.X            = x;
            output.Y            = y;
            output.SystemNature = SystemNatureGenerator.Generate();

            //Add Primary
            output.Stars.Add(StarGenerator.Generate(1));

            //Add Secondary Star
            if (output.SystemNature == SystemNature.Binary ||
                output.SystemNature == SystemNature.Trinary)
            {
                output.Stars.Add(StarGenerator.Generate(2));
            }

            //Add Third Star
            if (output.SystemNature == SystemNature.Trinary)
            {
                output.Stars.Add(StarGenerator.Generate(3));
            }



            return(output);
        }
Exemple #6
0
        public SolarSystemGenerator(PlanetSystemGenerator planetSystemGenerator, StarGenerator starGenerator,
                                    SolarSystemNameGenerator solarSystemNameGenerator)
        {
            _planetSystemGenerator = planetSystemGenerator;
            _starGenerator         = starGenerator;

            _solarSystemNameGenerator = solarSystemNameGenerator;
        }
        public SpreadController(StarGenerator starGenerator, Settings settings, GalaxyMap map)
        {
            Settings = settings;
            InitializeComponent();

            StarGenerator = starGenerator;
            Map           = map;
        }
Exemple #8
0
 public SpiralController(StarGenerator starGenerator, Settings settings, GalaxyMap map)
 {
     InitializeComponent();
     StarGenerator = starGenerator;
     //stars = _stars;
     //DrawAreaSize = panel1.Width;
     readConfig2(settings);
     DrawAreaSize = panel1.Width;
     Map          = map;
     Settings     = settings;
 }
Exemple #9
0
    // Update is called once per frame
    void Update()
    {
        if (_target == null)
        {
            StarGenerator starGenerator = FindObjectOfType <StarGenerator>();

            if (starGenerator != null && starGenerator.GeneratedStars.Count > 0)
            {
                _target = starGenerator.GeneratedStars[starGenerator.GeneratedStars.Count - 1];
            }
        }
        else
        {
            Vector3 toPosition   = _target.transform.position;
            Vector3 fromPosition = Camera.main.transform.position;
            fromPosition.z = 0f;
            Vector3 dir = (toPosition - fromPosition).normalized;



            float borderSize = Screen.height / 10f;

            Vector3 targetPositionScreenPoint = Camera.main.WorldToScreenPoint(_target.transform.position);
            bool    isOffscreen = targetPositionScreenPoint.x <= borderSize || targetPositionScreenPoint.x >= Screen.width - borderSize || targetPositionScreenPoint.y <= borderSize || targetPositionScreenPoint.y >= Screen.height - borderSize;

            if (isOffscreen)
            {
                Vector3 cappedTargetScreenPosition = targetPositionScreenPoint;
                cappedTargetScreenPosition.x = Mathf.Clamp(cappedTargetScreenPosition.x, borderSize, Screen.width - borderSize);
                cappedTargetScreenPosition.y = Mathf.Clamp(cappedTargetScreenPosition.y, borderSize, Screen.height - borderSize);
                _rect.position = cappedTargetScreenPosition.NewZ(0);
                if (_thisImage.sprite != _offScreenSprite)
                {
                    _thisImage.sprite = _offScreenSprite;
                }

                float angle = Vector2.SignedAngle(Vector2.up, dir);
                _rect.localEulerAngles = new Vector3(0, 0, angle);
            }
            else
            {
                _rect.position = targetPositionScreenPoint.NewZ(0);
                if (_thisImage.sprite != _onScreenSprite)
                {
                    _thisImage.sprite = _onScreenSprite;
                }

                float angle = 0;
                _rect.localEulerAngles = new Vector3(0, 0, angle);
            }
        }
    }
    void Start()
    {
        platformWidths = new float[objectPools.Length];

        for (int i = 0; i < objectPools.Length; i++)
        {
            platformWidths[i] = objectPools[i].pooledObject.GetComponent <BoxCollider2D>().size.x;
        }

        minimumHeight = transform.position.y;
        maximumHeight = maximumHeightPoint.position.y;

        starGenerator = FindObjectOfType <StarGenerator>();
    }
Exemple #11
0
    private void Awake()
    {
        platformGenerator = new PlatformGenerator(platforms);
        platformGenerator.CreatePlatforms();

        starGenerator = new StarGenerator(stars, player.gameObject);
        starGenerator.CreateStars(starDensity);

        cloudGenerator = new CloudGenerator(clouds, player.gameObject);
        cloudGenerator.CreateClouds(cloudDensity);


        killZone = GameObject.FindWithTag("Kill Zone");
    }
Exemple #12
0
 public void Awake()
 {
     lineRenderer = GetComponent <LineRenderer>();
     beginUIElements.SetActive(true);
     aboutUIElements.SetActive(false);
     endUIElements.SetActive(false);
     playerScoreUI  = endUIElements.GetComponentInChildren <PlayerScoreUI>();
     microphoneData = Singleton <MicrophoneData> .Instance;
     microphoneData.SetAudioSource(GetComponent <AudioSource>());
     microphoneData.SetMicrophone(0);
     calibratePitch        = false;
     calibrationAverage    = 0;
     calibrationSamples    = 0;
     menuGameInstance      = Instantiate(menuGame);
     starGeneratorInstance = Instantiate(starGenerator);
     starGeneratorInstance.transform.parent = mainCamera.transform;
 }
        public static StellarSystem Generate(int x, int y)
        {
            var output = new StellarSystem();

            output.X            = x;
            output.Y            = y;
            output.SystemNature = SystemNatureGenerator.Generate();

            //Add Primary
            IStar primary = StarGenerator.Generate(1);

            output.Stars.Add(primary);
            output.CombinedLuminosity = primary.Luminosity;

            //Add Secondary Star
            if (output.SystemNature == SystemNature.Binary ||
                output.SystemNature == SystemNature.Trinary)
            {
                IStar star = StarGenerator.Generate(2, output.Stars[0]);
                output.Stars.Add(star);
            }

            //Add Third Star
            if (output.SystemNature == SystemNature.Trinary)
            {
                output.Stars.Add(StarGenerator.Generate(3, output.Stars[0]));
            }

            //Generate primary star bodies
            SystemBodiesGenerator.Generate(output, 0);

            if (output.Stars.Count > 1)
            {
                SystemBodiesGenerator.Generate(output, 1);
            }

            if (output.Stars.Count > 2)
            {
                SystemBodiesGenerator.Generate(output, starToGenerate: 2);
            }

            return(output);
        }
Exemple #14
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        SceneManager.sceneLoaded += SceneChanged;

        if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("new_game"))
        {
        }
        else if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("main"))
        {
            generator = GetComponent <StarGenerator>();
            InitGame();
        }
    }
Exemple #15
0
    void SceneChanged(Scene scene, LoadSceneMode mode)
    {
        if (mode != LoadSceneMode.Single)
        {
            return;
        }

        if (scene == SceneManager.GetSceneByName("new_game"))
        {
            newGame = GameObject.Find("NewGameManager").GetComponent <NewGameManager>();
        }

        if (scene == SceneManager.GetSceneByName("options_menu"))
        {
            options = GameObject.Find("OptionsManager").GetComponent <OptionsMenuManager>();
        }

        if (scene == SceneManager.GetSceneByName("options_menu"))
        {
        }
        else if (scene == SceneManager.GetSceneByName("new_game"))
        {
            starData    = (options.getData()).ToList();
            playerCount = int.Parse(starData[2]) + 1;
        }

        if (scene == SceneManager.GetSceneByName("new_game"))
        {
        }
        else if (scene == SceneManager.GetSceneByName("main"))
        {
            newData   = (newGame.getData()).ToList();
            generator = GetComponent <StarGenerator>();
            InitGame();
        }
    }
 void Awake()
 {
     //set ref. to this
     current = this;
 }
Exemple #17
0
 void Start()
 {
     starGenerator = FindObjectOfType <StarGenerator>();
     audioSource   = GetComponent <AudioSource>();
 }