Exemplo n.º 1
0
    public static GameObject CreateAsteroid(Vector3 _position)
    {
        GameObject asteroidObject = new GameObject("Asteroid");

        asteroidObject.transform.position = _position;
        //planetObject.transform.parent = transform;
        //newPlanet.AddComponent<Planet> ();

        int size = Random.Range(2, 4);


        asteroidObject.transform.localScale = new Vector3(size, size, size);

        ///	planet = newPlanet.GetComponent<Planet> ();
        int   pixWidth  = 18;
        int   pixHeight = 18;
        int   scale     = 1;
        float xOrg      = 0;
        float yOrg      = 0;
        int   _seed     = Random.Range(0, 500);

        //planetMesh = SolarBodyGeneration.GetSphereMesh ();
        asteroidObject.AddComponent <MeshFilter> ().mesh = SolarBodyGeneration.RandomisedIcoSphere();
        MeshRenderer mr = asteroidObject.AddComponent <MeshRenderer> ();

        mr.material.mainTexture = Noise.CalculateSeamlessNoise(pixWidth, pixHeight, scale, xOrg, yOrg, _seed, PlanetColour.GetBarrenColour());



        return(asteroidObject);
    }