Exemplo n.º 1
0
    private void Start()
    {
        planetNr  = 0;
        exactName = OverallUtility.simplify(gameObject.ToString());

        added = false;
        //planet = gameObject.GetComponentInParent<Planet>();
    }
Exemplo n.º 2
0
    public void load(DataPlanet data, bool withLocation, Vector3 center)
    {
        if (data == null)
        {
            data = SaveSystem.loadPlanet(number);
        }
        foreach (Transform child in transform)
        {
            string childName = OverallUtility.simplify(child.gameObject.ToString());
            if (childName != "planet" && childName != "particles")
            {
                Destroy(child.gameObject);
            }
        }
        radiusAroudSun = data.radiusAroudSun;
        planetRadius   = data.planetRadius;
        speed          = data.speed;
        angle          = data.angle;
        number         = data.number;
        cratersAdded   = data.cratersAdded;
        blocking       = data.blocking;
        buildings      = new List <Building>();
        buildings.Clear();
        if (withLocation == true)
        {
            gameObject.transform.position = data.position;
            gameObject.transform.rotation = data.rotation;
        }
        Rigidbody planetRgb = gameObject.GetComponent <Rigidbody>();

        planetRgb.constraints = RigidbodyConstraints.FreezeAll;
        if (data.buildings != null)
        {
            foreach (DataBuilding datBil in data.buildings)
            {
                GameObject building = Instantiate(GameObject.Find(datBil.exactName), datBil.position + center, datBil.rotation);
                building.transform.parent = gameObject.transform;
                Rigidbody rgb = building.GetComponent <Rigidbody>();
                rgb.constraints = RigidbodyConstraints.FreezeAll;
                print(building.GetComponent <Building>());
                buildings.Add(building.GetComponent <Building>());
            }
        }

        planetRgb.constraints = RigidbodyConstraints.None;
    }