public void GenerateNewMap(WorldData worldData) { _currentNode = GenerateGraph(worldData); _blob = CreateNewMapBlob(); SaveMap(); _currentNode.ToggleEdgeVisibility(true); }
public void LoadMap(MapBlob blob) { _blob = blob; // Temp foreach (KeyValuePair <string, MapNodeData> kvp in blob.MapNodes) { MapNode mapNode = CreateMapNode(kvp.Key); mapNode.InitializeFromData(kvp.Value, MapNodeTappedCallback); } for (int i = 0, count = blob.MapEdges.Count; i < count; i++) { MapEdge mapEdge = CreateMapEdge(blob.MapEdges[i].P0, blob.MapEdges[i].P1); mapEdge.Initialize(blob.MapEdges[i]); } _currentNode = _mapNodes[blob.CurrentNode]; _currentNode.ToggleEdgeVisibility(true); }
private MapBlob CreateNewMapBlob() { MapBlob blob = new MapBlob(); Dictionary <string, MapNodeData> mapNodeData = new Dictionary <string, MapNodeData>(); foreach (KeyValuePair <string, MapNode> kvp in _mapNodes) { mapNodeData.Add(kvp.Key, kvp.Value.GetData()); } List <MapEdgeData> mapEdgeData = new List <MapEdgeData>(); for (int i = 0, count = _mapEdges.Count; i < count; i++) { mapEdgeData.Add(_mapEdges[i].GetData()); } blob.MapNodes = mapNodeData; blob.MapEdges = mapEdgeData; blob.CurrentNode = _currentNode.NodeId; return(blob); }
public void SaveMapData(MapBlob blob) { _characterBlob.MapBlob = blob; SavePlayerData(); }