private void SetDateTime(int type, string value) { DateTime dateTime = sunRotation.GetDateTime(); int val; if (Int32.TryParse(value, out val)) { try { if (type == 0) { dateTime = new DateTime(val, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second); } else if (type == 1) { dateTime = new DateTime(dateTime.Year, val, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second); } else if (type == 2) { dateTime = new DateTime(dateTime.Year, dateTime.Month, val, dateTime.Hour, dateTime.Minute, dateTime.Second); } else if (type == 3) { dateTime = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, val, dateTime.Minute, dateTime.Second); } else if (type == 4) { dateTime = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, val, dateTime.Second); } sunRotation.SetDateTime(dateTime); } catch (ArgumentOutOfRangeException) {} } if (type < 3) { UpdateInputs(date_panel); } else { UpdateInputs(time_panel); } }
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); }