public ActionResult RefreshMap(double lat, double lon) { var point = string.Format("POINT({1} {0})", lat, lon); MapDataModel mdm = MapManager.GetMapData(Convert.ToInt32(Session["UserId"]), point, 1000); return(Json(mdm.objectList)); }
public MapDataModel Load(string file) { MapDataModel result = new MapDataModel(); FileInfo fileInfo = new FileInfo(file); if (fileInfo.Exists) { lock (_lock) { try { MapDataModel mapDataList = new MapDataModel(); using (Stream stream = fileInfo.OpenRead()) using (StreamReader streamReader = new StreamReader(stream)) using (JsonReader jsonReader = new JsonTextReader(streamReader)) { JsonSerializer jsonSerializer = new JsonSerializer(); mapDataList = jsonSerializer.Deserialize <MapDataModel>(jsonReader); } result = mapDataList; } catch (Exception e) { Debug.WriteLine(e); } } } return(result); }
public override DatabaseEntry Copy() { MapDataModel map = new MapDataModel(key, sizeX, sizeY); map.mapName = mapName; for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { map.tileBoard[x, y] = tileBoard[x, y]; } } foreach (MapCoords coords in enemySpawnLocations) { map.enemySpawnLocations.Add(coords); } foreach (MapCoords coords in playerSpawnLocations) { map.playerSpawnLocations.Add(coords); } return(map); }
public void SaveMap() { MapDataModel currData = editor.currBoard; currData.mapName = input.text; currData.ChangeKey(currData.mapName); Globals.campaign.GetMapDataContainer().mapDB.AddEntry(currData); }
public MapFromImageParser(MapModel map) { _map = map; _mapData = new MapDataModel { Data = null }; _mapImage = new Bitmap(GConfig.D.MapFileFolderPathRelativ + map.FileName); }
public void InitBOard() { currBoard = new MapDataModel("new_map", 15, 15); for (int x = 0; x < currBoard.sizeX; x++) { for (int y = 0; y < currBoard.sizeY; y++) { currBoard.tileBoard[x, y] = tileDatabase.Tiles.DbKeys()[0]; } } PrintBoard(); }
public void LoadMap(string key) { string mapName = key; ClearBoard(); mapDataModel = currCampaign.GetMapDataContainer().mapDB.GetData(mapName); sizeX = mapDataModel.sizeX; sizeY = mapDataModel.sizeY; mapNameField.text = key; sizeXField.text = mapDataModel.sizeX + ""; sizeYField.text = mapDataModel.sizeY + ""; PrintMap(); }
// Use this for initialization void Start() { Globals.currState = GameState.Base; SaveStateBase stat = (SaveStateBase)(SaveLoadManager.LoadFile(FilePath.CurrentSaveFilePath)); campaign = stat.campaign; contentContainer = campaign.contentLibrary; baseUI.campaign = campaign; baseMap = Globals.campaign.GetMapDataContainer().mapDB.GetCopy(stat.baseID); atlas = Resources.Load <SpriteAtlas>(FilePath.TileSetAtlas); PrintBoard(); inputFSM = new InputFSM(new BlockUserInputState()); }
public void NewMap() { ClearBoard(); sizeX = int.Parse(sizeXField.text); sizeY = int.Parse(sizeYField.text); string mapName = mapNameField.text; mapDataModel = new MapDataModel(mapName, sizeX, sizeY); mapDataModel.mapName = mapName; for (int x = 0; x < sizeX; x++) { for (int y = 0; y < sizeY; y++) { mapDataModel.tileBoard[x, y] = GetDefaultTileType(); } } PrintMap(); }
public void PrintBoard() { MapDataModel model = Globals.campaign.GetMapDataContainer().mapDB.GetData(cs.mapname); board = new GameObject[model.sizeX, model.sizeY]; tileeffects = new GameObject[model.sizeX, model.sizeY]; mapsizeX = model.sizeX; mapsizeY = model.sizeY; for (int x = 0; x < model.sizeX; x++) { for (int y = 0; y < model.sizeY; y++) { GameObject tempTile = Instantiate <GameObject>(tilespritePrefab, spawnPoint); board[x, y] = tempTile; tempTile.transform.position = Globals.GridToWorld(x, y); // change the tile sprite tempTile.GetComponent <SpriteRenderer>().sprite = Globals.GetSprite(FilePath.TileSetAtlas, model.tileBoard[x, y]); } } }
private List <Tuple <MapTile, MapTile, MapTile> > BuildSpawnListByTeam(MapDataModel MapData) { var spawnList = new List <Tuple <MapTile, MapTile, MapTile> >(); var spawnTile = MapData.Data.Single(a => a.Type == TileType.Path1Team1Start); var wayTile = MapData.Data.SingleOrDefault(a => a.Type == TileType.Path1Team1Way); var endTile = MapData.Data.Single(a => a.Type == TileType.Path1Team1end); spawnList.Add(new Tuple <MapTile, MapTile, MapTile>(spawnTile, wayTile, endTile)); try { var spawnTileoMapTile = MapData.Data.Single(a => a.Type == TileType.Path2Team1Start); var wayTileo = MapData.Data.SingleOrDefault(a => a.Type == TileType.Path2Team1Way); var endTileo = MapData.Data.Single(a => a.Type == TileType.Path2Team1end); spawnList.Add(new Tuple <MapTile, MapTile, MapTile>(spawnTileoMapTile, wayTileo, endTileo)); } catch { } try { var spawnTileoMapTile = MapData.Data.Single(a => a.Type == TileType.Path3Team1Start); var wayTileo = MapData.Data.SingleOrDefault(a => a.Type == TileType.Path3Team1Way); var endTileo = MapData.Data.Single(a => a.Type == TileType.Path3Team1end); spawnList.Add(new Tuple <MapTile, MapTile, MapTile>(spawnTileoMapTile, wayTileo, endTileo)); } catch { } try { var spawnTileoMapTile = MapData.Data.Single(a => a.Type == TileType.Path4Team1Start); var wayTileo = MapData.Data.SingleOrDefault(a => a.Type == TileType.Path4Team1Way); var endTileo = MapData.Data.Single(a => a.Type == TileType.Path4Team1end); spawnList.Add(new Tuple <MapTile, MapTile, MapTile>(spawnTileoMapTile, wayTileo, endTileo)); } catch { } return(spawnList); }
public void Load(string fullPath) { MapData = new MapDataIO().Load(fullPath); }
private MapDataList() { MapData = new MapDataModel(); MapData.Nodes = new List <Node>(); MapData.Edges = new List <Edge>(); }
void Start() { _instance = this; //Just a testing thing if (Globals.campaign == null) { Debug.Log("DEPENDICIES INJECTED"); GenerateDemoCampaign dcm = new GenerateDemoCampaign(); Globals.campaign = dcm.campaign; campaign = dcm.campaign; party = campaign.currentparty; currentMission = campaign.GetMissionData("test_mission_00"); currentMission.started = false; SavedFileMission state = new SavedFileMission(campaign, currentMission); FilePath.CurrentSaveFilePath = SaveLoadManager.GenerateSaveStateFilePath(state.campaign.GetFileName()); SaveLoadManager.AutoSaveCampaignProgress(state); } else { campaign = Globals.campaign; party = campaign.currentparty; } //Actual initialization starts here Globals.currState = GameState.Combat; SavedFileMission file = SaveLoadManager.LoadFile(FilePath.CurrentSaveFilePath) as SavedFileMission; currentMission = file.currentMission; currMap = Globals.campaign.GetMapDataContainer().mapDB.GetCopy(currentMission.mapName); if (currentMission.started) { for (int x = 0; x < currMap.sizeX; x++) { for (int y = 0; y < currMap.sizeY; y++) { currMap.tileBoard[x, y] = file.TileTypeStates[x, y].GetKey(); } } } inputFSM = new InputFSM(new BlockUserInputState()); atlas = Resources.Load <SpriteAtlas>(FilePath.TileSetAtlas); GenerateBoard(); //we are loading a mission if (currentMission.started) { StartBattleFromLoad(); for (int x = 0; x < currMap.sizeX; x++) { for (int y = 0; y < currMap.sizeY; y++) { pathfinding.tiles[x, y].tileGO.ChangeTileType(file.TileTypeStates[x, y]); foreach (TileEffect effect in file.TileEffectStates[x, y]) { if (effect is AuraTileEffect) { //pathfinding.tiles[x, y].AddTileEffect(effect.Copy() as AuraTileEffect); } else { pathfinding.tiles[x, y].AddTileEffect(effect.Copy() as TileEffect); } } } } turnManager.globalTurnSpeed = file.currentTurnSpeed; } else // we starting a new mission { Globals.cutsceneData = null; InitBattledata(); //ui.TurnOffInfoPanels(); currentMission.started = true; } }
public void Save(MapDataModel mapData, string fileInfo) { string json = JsonConvert.SerializeObject(mapData); File.WriteAllText(fileInfo, json); }