Esempio n. 1
0
    public void SetName(string input)
    {
        IsTypeOfPlanet type = this.gameObject.GetComponent <IsTypeOfPlanet>();

        if (type != null)
        {
            if (type.IsRocky)
            {
                var RockSetting = this.gameObject.GetComponent <MotherPlanet>().shapeGenerator.settings;
                textTranslation = RockSetting.radius + 0.1f;
            }

            if (type.IsGassy)
            {
                float GasValue = this.gameObject.transform.localScale.x;
                textTranslation = GasValue / 1.7f;
            }
        }


        name = input;
        if (name != null)
        {
            txt = Resources.Load("PlanetNameText/PlanetName") as GameObject;
            Vector3 newpos = this.gameObject.transform.position;
            //newpos = newpos + new Vector3(0f,0.2f,0f);
            txt = Instantiate(txt, newpos, this.gameObject.transform.rotation);
            //txt.transform.SetParent(this.gameObject.transform, false);
            txt.AddComponent <PlanetNameMovement>();
            txt.GetComponent <PlanetNameMovement>().SetPlanet(this.gameObject, textTranslation);
            txt.GetComponent <TextMesh>().text = name;
        }
    }
Esempio n. 2
0
    public void SetMass()
    {
        IsTypeOfPlanet type = this.gameObject.GetComponent <IsTypeOfPlanet>();

        if (type != null)
        {
            if (type.IsRocky)
            {
                weightMultiplier = 18f;
                var RockSetting = this.gameObject.GetComponent <MotherPlanet>().shapeGenerator.settings;
                //float interval = (0.599485f-0.3692803f);
                float scaling = 2f - (0.25f - RockSetting.radius) * 4f;
                scaling           = scaling < 0f ? 0.1f : scaling;
                weightMultiplier *= scaling;
                Debug.Log("Rock" + weightMultiplier);
            }

            if (type.IsGassy)
            {
                //jupiter är genomsnittligt 1/4 av jordens densitet
                weightMultiplier = 5f;
                float GasInterval = 0.599485f - 0.786532f;
                float GasValue    = this.gameObject.transform.localScale.x;
                print(GasValue);
                float scaling = Mathf.Exp((GasValue - GasInterval) / GasInterval) / 3f;
                weightMultiplier *= scaling * 400;
                Debug.Log("Gas" + weightMultiplier);
            }
        }


        rigidBody = this.gameObject.GetComponent <Rigidbody>();
        if (rigidBody == null)
        {
            rigidBody = this.gameObject.AddComponent <Rigidbody>();
        }
        rigidBody.useGravity = false;
        mass            = rigidBody.mass;
        rigidBody.mass *= weightMultiplier;
        mass           *= weightMultiplier;

        /*
         * print("Setmass:");
         * print(mass);
         * print(rigidBody.mass);
         * print(weightMultiplier);
         */
    }