Ejemplo n.º 1
0
    private void CreateScene(SceneData data)
    {
        // Reset landmark visibility and heatmap
        landmarkVisibility.ResetColors();
        heatmap.ResetMap();

        // Delete all existing buildings
        foreach (Transform child in transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        // Delete all existing bars
        foreach (Transform child in barParent)
        {
            GameObject.Destroy(child.gameObject);
        }

        // Load saved buildings and bars, and location and time
        int[]        buildingsIndexes = data.GetBuildingsIndexes();
        Vector3[]    positions        = data.GetPositions();
        Quaternion[] rotations        = data.GetRotations();
        Vector3[]    scales           = data.GetScales();
        Vector3      landmarkPosition = data.GetLandmarkPosition();

        Vector3[] barPositions = data.GetBarPositions();
        float     sunSpeed     = data.GetSunSpeed();
        double    latitude     = data.GetLatitude();
        double    longitude    = data.GetLongitude();
        float     UTCHours     = data.GetUTCHours();
        DateTime  dateTime     = data.GetDateTime();

        // Create saved buildings and bars
        bool isTowerLandmark = true;

        for (int i = 0; i < buildingsIndexes.Length; i++)
        {
            GameObject building = Instantiate(buildingPrefabs[buildingsIndexes[i]], positions[i], rotations[i]);
            building.transform.SetParent(transform);
            building.transform.localScale = scales[i];
            if (building.transform.position == landmarkPosition)
            {
                landmarkVisibility.SetLandmark(building);
                isTowerLandmark = false;
            }
        }
        if (isTowerLandmark)
        {
            landmarkVisibility.SetLandmark(GameObject.Find("Eiffel Tower"));
        }
        for (int i = 0; i < barPositions.Length; i++)
        {
            GameObject bar = Instantiate(barPrefab, barPositions[i], Quaternion.identity);
            bar.transform.SetParent(barParent);
        }

        // Set time and location
        sunRotation.SetSpeed(sunSpeed);
        sunRotation.SetLatitude(latitude);
        sunRotation.SetLongitude(longitude);
        sunRotation.SetUTC(UTCHours);
        sunRotation.SetDateTime(dateTime);
    }