示例#1
0
 // Start is called before the first frame update
 void Start()
 {
     randomHash        = this.GetInstanceID();
     rnd               = new System.Random(randomHash);
     lastTimeGenerated = System.DateTime.Now;
     player            = GameObject.Find("Player");
     prefabs           = GameObject.Find("PrefabStorage").GetComponent <PrefabsStorage>();
 }
示例#2
0
    void Start()
    {
        lastTimeDownGrade = System.DateTime.Now;
        //this.name = "Planet";
        prefabs = GameObject.Find("PrefabStorage").GetComponent <PrefabsStorage>();



        if (this.name == "Asteroid" || this.tag == "Asteroid")
        {
            this.StartingMass = Constants.AsteroidStartingMass;
            this.GetComponent <Rigidbody2D>().AddForce(Constants.GravityPower * new Vector3(rnd.Next(), rnd.Next(), rnd.Next()).normalized);
        }

        // подсветка включается только у планет и звезд. поэтому отключаем сейчас
        if (this.tag == "Player" && this.name == "Asteroid")
        {
            this.GetComponent <Outline>().enabled = false;
        }


        this.maxDistance = Constants.MaxGravitationalDistance;

        SetupRigidbody2D();


        SetupColliders();

        SetupMeshRenderer();
        SetupTrailRenderer();

        SetupMapPoint();


        //Add this gravitational body to the list, so that all other gravitational bodies can be effected by it
        attractableBodies.Add(rb);
    }