public void StartLevel(int level) { level = 1; Debug.Log("Starting level " + (level + 1)); if (level > 3) { Debug.Log("No more levels :("); return; } currentLevel = level + 1; ClearMap(); var path = Application.dataPath + "/Json/MapData/Maps/Level" + currentLevel + ".json"; var jsonString = File.ReadAllText(path); MapDataJson MapDataJson = JsonUtility.FromJson <MapDataJson>(jsonString); MapData data = new MapData(); path = Application.dataPath + "/" + MapDataJson.spawnData; data.spawnData = new SpawnData(File.ReadAllText(path)); SpawnManager.instance.waves = data.spawnData.waves; SpawnManager.instance.StartSpawning(); data.meshes = JsonHelper.getJsonArray <BlockadeMesh>(File.ReadAllText(Application.dataPath + "/" + MapDataJson.meshes)); currentLevel = level; CreateMap(data.meshes); }
public async Task <IActionResult> GetTypesMapData(int poiTypeId) { MapDataJson dataJson = new MapDataJson(); var poiType = await _mappingService.GetTypeByIdAsync(poiTypeId); if (poiType == null || poiType.DepartmentId != DepartmentId) { Unauthorized(); } foreach (var poi in poiType.Pois) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = poiType.Image; info.Marker = poiType.Marker; info.Title = poiType.Name; info.InfoWindowContent = ""; info.Latitude = poi.Latitude; info.Longitude = poi.Longitude; info.Color = poiType.Color; dataJson.Pois.Add(info); } return(Json(dataJson)); }
// 맵 데이터를 불러오는 함수 public void LodingMapData() { if (File.Exists(Application.persistentDataPath + "/datajson.json")) { string loadjson = File.ReadAllText(Application.persistentDataPath + "/datajson.json"); MapDataJson mapdata = new MapDataJson(); mapdata = JsonUtility.FromJson <MapDataJson>(loadjson); MapDataStr = mapdata.data; } minimap.ShowMiniMap(MapDataStr, 0, 0, 1); CallCreateMap(); //SaveStrData(MapdataToString()); }
// 맵 데이터를 json형식으로 저장하는 함수 public void SaveDataJson() { //Stopwatch sw = new Stopwatch(); //sw.Start(); MapDataJson bbbb = new MapDataJson(); bbbb.data = MapDataStr; string json = JsonUtility.ToJson(bbbb); File.WriteAllText(Application.persistentDataPath + "/datajson.json", json); saveDone = true; //sw.Stop(); //UnityEngine.Debug.Log("저장시간 " + sw.ElapsedMilliseconds.ToString()); }
public async Task <IActionResult> GetMapData(MapSettingsInput input) { MapDataJson dataJson = new MapDataJson(); var calls = await _callsService.GetActiveCallsByDepartmentAsync(DepartmentId); var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false); var stations = await _departmentGroupsService.GetAllStationGroupsForDepartmentAsync(DepartmentId); var lastUserActionlogs = await _actionLogsService.GetLastActionLogsForDepartmentAsync(DepartmentId); var personnelNames = await _departmentsService.GetAllPersonnelNamesForDepartmentAsync(DepartmentId); var unitStates = await _unitsService.GetAllLatestStatusForUnitsByDepartmentIdAsync(DepartmentId); var userLocationPermission = await _permissionsService.GetPermissionByDepartmentTypeAsync(DepartmentId, PermissionTypes.CanSeePersonnelLocations); if (userLocationPermission != null) { var userGroup = await _departmentGroupsService.GetGroupForUserAsync(UserId, DepartmentId); int?groupId = null; if (userGroup != null) { groupId = userGroup.DepartmentGroupId; } var roles = await _personnelRolesService.GetRolesForUserAsync(UserId, DepartmentId); var allowedUsers = _permissionsService.GetAllowedUsers(userLocationPermission, DepartmentId, groupId, ClaimsAuthorizationHelper.IsUserDepartmentAdmin(), ClaimsAuthorizationHelper.IsUserDepartmentAdmin(), roles); lastUserActionlogs.RemoveAll(x => !allowedUsers.Contains(x.UserId)); } if (input.ShowDistricts) { foreach (var station in stations) { if (!String.IsNullOrWhiteSpace(station.Geofence)) { GeofenceJson geofence = new GeofenceJson(); geofence.Name = station.Name; geofence.Color = station.GeofenceColor; geofence.Fence = station.Geofence; dataJson.Geofences.Add(geofence); } } } if (input.ShowStations) { foreach (var station in stations) { try { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = "Station"; info.Title = station.Name; info.InfoWindowContent = station.Name; if (station.Address != null) { string coordinates = await _geoLocationProvider.GetLatLonFromAddress(string.Format("{0} {1} {2} {3}", station.Address.Address1, station.Address.City, station.Address.State, station.Address.PostalCode)); if (!String.IsNullOrEmpty(coordinates)) { info.Latitude = double.Parse(coordinates.Split(char.Parse(","))[0]); info.Longitude = double.Parse(coordinates.Split(char.Parse(","))[1]); dataJson.Markers.Add(info); } } else if (!String.IsNullOrWhiteSpace(station.Latitude) && !String.IsNullOrWhiteSpace(station.Longitude)) { info.Latitude = double.Parse(station.Latitude); info.Longitude = double.Parse(station.Longitude); dataJson.Markers.Add(info); } } catch (Exception ex) { //Logging.LogException(ex); } } } if (input.ShowCalls) { foreach (var call in calls) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = "Call"; info.Title = call.Name; info.InfoWindowContent = call.NatureOfCall; if (!String.IsNullOrEmpty(call.GeoLocationData)) { try { info.Latitude = double.Parse(call.GeoLocationData.Split(char.Parse(","))[0]); info.Longitude = double.Parse(call.GeoLocationData.Split(char.Parse(","))[1]); dataJson.Markers.Add(info); } catch { } } else if (!String.IsNullOrEmpty(call.Address)) { string coordinates = await _geoLocationProvider.GetLatLonFromAddress(call.Address); if (!String.IsNullOrEmpty(coordinates)) { info.Latitude = double.Parse(coordinates.Split(char.Parse(","))[0]); info.Longitude = double.Parse(coordinates.Split(char.Parse(","))[1]); } dataJson.Markers.Add(info); } } } if (input.ShowUnits) { foreach (var unit in unitStates) { if (unit.Latitude.HasValue && unit.Latitude.Value != 0 && unit.Longitude.HasValue && unit.Longitude.Value != 0) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = "Engine_Responding"; info.Title = unit.Unit.Name; info.InfoWindowContent = ""; info.Latitude = double.Parse(unit.Latitude.Value.ToString()); info.Longitude = double.Parse(unit.Longitude.Value.ToString()); dataJson.Markers.Add(info); } } } if (input.ShowPersonnel) { foreach (var person in lastUserActionlogs) { if (!String.IsNullOrWhiteSpace(person.GeoLocationData)) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = "Person"; var name = personnelNames.FirstOrDefault(x => x.UserId == person.UserId); if (name != null) { info.Title = name.Name; info.InfoWindowContent = ""; } else { info.Title = ""; info.InfoWindowContent = ""; } var infos = person.GeoLocationData.Split(char.Parse(",")); if (infos != null && infos.Length == 2) { info.Latitude = double.Parse(infos[0]); info.Longitude = double.Parse(infos[1]); dataJson.Markers.Add(info); } } } } if (input.ShowPOIs) { var poiTypes = await _mappingService.GetPOITypesForDepartmentAsync(DepartmentId); foreach (var poiType in poiTypes) { foreach (var poi in poiType.Pois) { MapMakerInfo info = new MapMakerInfo(); info.ImagePath = poiType.Image; info.Marker = poiType.Marker; info.Title = poiType.Name; info.InfoWindowContent = ""; info.Latitude = poi.Latitude; info.Longitude = poi.Longitude; info.Color = poiType.Color; dataJson.Pois.Add(info); } } } return(Json(dataJson)); }