private void SaveGameplayDialogues() { Dialogue dialogue = new Dialogue(dialogues[currDialogueIdx].id, dialogues[currDialogueIdx].name); DialogueMessage[] messages = new DialogueMessage[nodes.Count]; for (int i = 0; i < messages.Length; i++) { messages[i] = new DialogueMessage(nodes[i].nodeID, nodes[i].actorID, nodes[i].text); } // Making Message Hierarchy. for (int i = 0; i < connections.Count; i++) { int parentMsgID = connections[i].outPoint.ownerNode.nodeID; int childMsgID = connections[i].inPoint.ownerNode.nodeID; DialogueMessage parentMsg = Dialogue.GetMessageByID(messages, parentMsgID); parentMsg.childMsgIDs.Add(childMsgID); } dialogue.rootMessageIDs = new int[1]; dialogue.rootMessageIDs[0] = 0; dialogue.messages = messages; string filePath = DialogueManager.GetDialogueFilePath(dialogue.GetID()); BinaryIO.WriteToBinaryFile(filePath, dialogue); }
private void SaveDialogues() { string filePath = Application.dataPath + editorDialogueSavePath + "dialogueeditor.data"; DialogueEditorSaveData dialogueEditorSaveData = new DialogueEditorSaveData(dialogues.ToArray()); BinaryIO.WriteToBinaryFile(filePath, dialogueEditorSaveData); }
public static void GenerateDict() { var mappedDict = new Dictionary <int, long>(); var reverseMappedDict = new Dictionary <long, int>(); mappedDict[0] = 0; reverseMappedDict[0] = 0; var gpsFolders = Directory.GetDirectories(Parameters.AllTripsFolder); using (var pbar = new ProgressBar(gpsFolders.Length, "Parsing gps folder", ProgressBarOptions.Default)) { foreach (var gpsFolder in gpsFolders) { var gpsFiles = Directory.GetFiles(gpsFolder); using (var pbar2 = pbar.Spawn(gpsFiles.Length, "Parsing files", ProgressBarOptions.Default)) { foreach (var gpsFile in gpsFiles) { var json = File.ReadAllText(gpsFile); var trips = JsonConvert.DeserializeObject <List <List <long> > >(json); foreach (var allTrip in trips) { foreach (var trip in trips) { foreach (var node in trip) { if (reverseMappedDict.ContainsKey(node)) { continue; } mappedDict[mappedDict.Count] = node; reverseMappedDict[node] = reverseMappedDict.Count; } } } pbar2.Tick(); } } pbar.Tick(); } } BinaryIO.WriteToBinaryFile($"{Parameters.DictFolder}mapped.dict.bin", mappedDict); BinaryIO.WriteToBinaryFile($"{Parameters.DictFolder}rev_mapped.dict.bin", reverseMappedDict); }
private static void ReadSave(int step) { var reverseMappedDict = DictGenerator.LoadReverseMappedDict(); var allCSV = new List <string>(); var allRecord = new List <DictTripStruct>(); var baseFolderName = $"{Parameters.BaseFolder}map_matched_csv_{step}"; var innerFolders = Directory.GetDirectories(baseFolderName); foreach (var folder in innerFolders) { allCSV = allCSV.Concat(Directory.GetFiles(folder)).ToList(); } using (var pbar = new ProgressBar(allCSV.Count, $"Step {step} CSV Files", new ProgressBarOptions())) { foreach (var csvFile in allCSV) { using (var reader = new StreamReader(csvFile)) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { var records = csv.GetRecords <TripRow>(); foreach (var record in records) { record.FormatPriors(); var s = new TripStruct { priors = record.GetPriors(), destination = record.destination }; var d = GetDictFromRow(s, reverseMappedDict); allRecord.Add(d); } } pbar.Tick(); } } GC.Collect(); BinaryIO.WriteToBinaryFile($"{Parameters.BinFolder}trips_rows_{step}.bin", allRecord); }