Esempio n. 1
0
    void SpawnPlanet(Transform pos)
    {
        int        index       = Random.Range(0, planets.Length);
        GameObject go          = Instantiate(planet, pos.position, pos.rotation);
        Texture2D  tex         = pg.GenerateImage();
        float      scale       = Random.Range(4f, 6f);
        float      mass        = Map(scale, 4f, 6f, 25000, 50000);
        float      gravityDist = Map(scale, 4f, 6f, 115f, 175f);

        go.GetComponent <GravityBody>().gravityDistance = gravityDist;
        go.GetComponent <Rigidbody2D>().mass            = mass;
        go.transform.localScale = new Vector3(scale, scale, scale);
        go.GetComponent <SpriteRenderer>().sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.one * 0.5f);
        pc++;
    }