protected void ParseFinalRoomsUsed(ref string fileText) { string nextLine = FileReaderUtils.GetNextLine(ref fileText); while (nextLine != "++END++") { UsedFinalRoomRecord record; int corpID = 0; int roomIndex = 0; bool hasReadCorpId = false; foreach (char nextChar in nextLine) { if (char.IsDigit(nextChar)) { if (hasReadCorpId) { roomIndex = roomIndex * 10 + int.Parse(nextChar.ToString()); } else { corpID = corpID * 10 + int.Parse(nextChar.ToString()); } } else if (nextChar == '-') { hasReadCorpId = true; } } record.corpID = corpID; record.roomIndex = roomIndex; usedFinalRoomRecords.Add(record); nextLine = FileReaderUtils.GetNextLine(ref fileText); } }
protected void ParseShopInventory(ref string fileText) { shopInventorySchema = new List <ShopInventoryRecord>(); string nextLine = FileReaderUtils.GetNextLine(ref fileText); while (nextLine != "++END++") { string itemName = ""; int cost = 0; bool isCost = false; foreach (char nextChar in nextLine) { if (nextChar == '-') { isCost = true; } else if (isCost && Char.IsDigit(nextChar)) { cost = cost * 10 + int.Parse(nextChar.ToString()); } else { itemName += nextChar; } } ShopInventoryRecord newInventoryRecord; newInventoryRecord.cost = cost; newInventoryRecord.schemaName = itemName; shopInventorySchema.Add(newInventoryRecord); nextLine = FileReaderUtils.GetNextLine(ref fileText); } hasInventoryBeenRefeshed = true; ReadFromSaveFile(ref fileText); }
private string ReadFromSaveFile(ref string fileText) { string nextLine = FileReaderUtils.GetNextLine(ref fileText); switch (nextLine) { case "++OWNED OBJECTS++": { ParseOwnedObjects(ref fileText); break; } case "++SHOP INVENTORY++": { ParseShopInventory(ref fileText); break; } case "++MISSIONS++": { ParseAvailableMissions(ref fileText); break; } case "++REFRESH STATUS++": { ParseRefreshStatus(ref fileText); break; } case "++CREDITS++": //Is a single line entry, does not require an ending marker { ParseCredits(ref fileText); break; } case "++USED FINAL ROOMS++": { ParseFinalRoomsUsed(ref fileText); break; } case "++PROGRESS++": //Is a single line entry, does not require an ending marker { ParseProgress(ref fileText); break; } case "++ENDFILE++": { break; } } return(fileText); }
protected void ParseOwnedObjects(ref string fileText) { string nextLine = FileReaderUtils.GetNextLine(ref fileText); while (nextLine != "++END++") { AddSchema(nextLine); nextLine = FileReaderUtils.GetNextLine(ref fileText); } ReadFromSaveFile(ref fileText); }
private List <string> ParseCredits() { List <string> parsedCredits = new List <string>(); string creditListAsString = creditList.text; string nextCredit = FileReaderUtils.GetNextLine(ref creditListAsString); while (!nextCredit.Contains("++ENDFILE++")) { parsedCredits.Add(nextCredit); nextCredit = FileReaderUtils.GetNextLine(ref creditListAsString); } return(parsedCredits); }
protected void ParseAvailableMissions(ref string fileText) { availableMissions = new List <ExploitRecord>(); string nextLine = FileReaderUtils.GetNextLine(ref fileText); while (nextLine != "++END++") { string corpName = ""; int corpID = 0; int vulnerability = 0; bool isVunerabilityRecorded = false; bool isCorpIDRecorded = false; foreach (char nextChar in nextLine) { if (nextChar == '-') { if (!isCorpIDRecorded) { isCorpIDRecorded = true; } else { isVunerabilityRecorded = true; } } else if (Char.IsDigit(nextChar)) { if (!isCorpIDRecorded) { corpID = corpID * 10 + int.Parse(nextChar.ToString()); } else if (!isVunerabilityRecorded) { vulnerability = vulnerability * 10 + int.Parse(nextChar.ToString()); } } else { corpName += nextChar; } } ExploitRecord newExploitRecord; newExploitRecord.corpID = corpID; newExploitRecord.corpName = corpName; newExploitRecord.vulnerability = vulnerability; availableMissions.Add(newExploitRecord); nextLine = FileReaderUtils.GetNextLine(ref fileText); } hasMissionListBeenRefreshed = true; ReadFromSaveFile(ref fileText); }
private void ParseReference(string referenceText) { string nextLine = FileReaderUtils.GetNextLine(ref referenceText); while (nextLine != "++ENDFILE++") { Article newArticle; newArticle.title = nextLine; newArticle.content = FileReaderUtils.GetNextLine(ref referenceText); articles.Add(newArticle); Debug.Log("loaded article " + newArticle.title); nextLine = FileReaderUtils.GetNextLine(ref referenceText); } }
protected void ParseProgress(ref string fileText)//Is a single line entry, does not require an ending marker { string nextLine = FileReaderUtils.GetNextLine(ref fileText); int progress = 0; foreach (char nextChar in nextLine) { if (char.IsDigit(nextChar)) { progress = progress * 10 + int.Parse(nextChar.ToString()); } } this.progress = progress; ReadFromSaveFile(ref fileText); }
private void ParseRoomFile(string roomText) { string nextLine = FileReaderUtils.GetNextLine(ref roomText); switch (nextLine) { case "++LAYOUT++": { ParseLayout(ref roomText); break; } case "++PLACEMENTS++": { ParsePlacements(ref roomText); break; } case "++PATROL ROUTES++": { ParseRoutes(ref roomText); break; } case "++TERMINAL ASSIGNMENTS++": { ParseTerminalAssignements(ref roomText); break; } case "++SWITCH ASSIGNMENTS++": { ParseSwitchAssignments(ref roomText); break; } case "++LOOT VALUES++": { ParseLootValues(ref roomText); break; } case "++ENDFILE++": { return; } } }
private void ParseLootValues(ref string roomText) { string nextLine = FileReaderUtils.GetNextLine(ref roomText); while (nextLine != "++END++") { int newVal = 0; int x = 0; int z = 0; int lootValue; foreach (char nextChar in nextLine) { if (Char.IsDigit(nextChar)) { newVal *= 10; newVal += int.Parse(nextChar.ToString()); } else if (nextChar == ',') { x = newVal; newVal = 0; } else if (nextChar == '-') { z = newVal; newVal = 0; } } lootValue = newVal; if (missionObj != Vector3Int.down && missionObj.x == x && missionObj.z == z) { missionObj += Vector3Int.up * lootValue; } else { for (int i = 0; i < loot.Count; i++) { if (loot[i].x == x && loot[i].z == z) { loot[i] += Vector3Int.up * lootValue; } } } nextLine = FileReaderUtils.GetNextLine(ref roomText); } ParseRoomFile(roomText); }
private void ParseRefreshStatus(ref string fileText) { if (FileReaderUtils.GetNextLine(ref fileText) == "False") { hasInventoryBeenRefeshed = false; } else { hasInventoryBeenRefeshed = true; } if (FileReaderUtils.GetNextLine(ref fileText) == "False") { hasMissionListBeenRefreshed = false; } else { hasMissionListBeenRefreshed = true; } ReadFromSaveFile(ref fileText); }
private void ParseRoutes(ref string roomText) { string nextLine = FileReaderUtils.GetNextLine(ref roomText); while (nextLine != "++END++") { List <Vector3Int> patrolPoints = new List <Vector3Int>(); int newVal = 0; int x = 0; int z = 0; Vector3Int newPoint; foreach (char nextChar in nextLine) { if (Char.IsDigit(nextChar)) { newVal *= 10; newVal += int.Parse(nextChar.ToString()); } else if (nextChar == ',') { x = newVal; newVal = 0; } else if (nextChar == '-') { z = newVal; newVal = 0; newPoint = new Vector3Int(x, 0, z); patrolPoints.Add(newPoint); } } z = newVal; newVal = 0; newPoint = new Vector3Int(x, 0, z); patrolPoints.Add(newPoint); patrolRoutes.Add(patrolPoints); nextLine = FileReaderUtils.GetNextLine(ref roomText); } ParseRoomFile(roomText); }
private void ParseTerminalAssignements(ref string roomText) { terminalAssignments = new List <TerminalAssignment>(); isControlledByInternalTerminal = true; string nextLine = FileReaderUtils.GetNextLine(ref roomText); while (nextLine != "++END++") { int newVal = 0; int x = 0; int z = 0; TerminalAssignment newAssignement = new TerminalAssignment(); foreach (char nextChar in nextLine) { if (Char.IsDigit(nextChar)) { newVal *= 10; newVal += int.Parse(nextChar.ToString()); } else if (nextChar == ',') { x = newVal; newVal = 0; } else if (nextChar == '-') { z = newVal; newVal = 0; newAssignement.AddLocation(new Vector3Int(x, 0, z)); } } z = newVal; newAssignement.AddLocation(new Vector3Int(x, 0, z)); terminalAssignments.Add(newAssignement); nextLine = FileReaderUtils.GetNextLine(ref roomText); } ParseRoomFile(roomText); }
private void ParseSwitchAssignments(ref string roomText) { switchBridgeAssignments = new List <SwitchBridge.SwitchTileAssignment>(); string nextLine = FileReaderUtils.GetNextLine(ref roomText); while (nextLine != "++END++") { int newVal = 0; int x = 0; int z = 0; SwitchBridge.SwitchTileAssignment newAssignement = new SwitchBridge.SwitchTileAssignment(); foreach (char nextChar in nextLine) { if (Char.IsDigit(nextChar)) { newVal *= 10; newVal += int.Parse(nextChar.ToString()); } else if (nextChar == ',') { x = newVal; newVal = 0; } else if (nextChar == '-') { z = newVal; newVal = 0; newAssignement.AddLocation(new Vector3Int(x, 0, z)); } } z = newVal; newAssignement.AddLocation(new Vector3Int(x, 0, z)); switchBridgeAssignments.Add(newAssignement); nextLine = FileReaderUtils.GetNextLine(ref roomText); } ParseRoomFile(roomText); }
private void ParsePlacements(ref string roomText) { string nextLine = FileReaderUtils.GetNextLine(ref roomText); while (nextLine != "++END++") { int x = 0; int z = 0; while (nextLine != "++END++") { foreach (char nextChar in nextLine) { switch (nextChar) { case ' ': { x++; break; } case '-': { break; } case 'S': { deploymentPoint = new Vector3Int(x, 0, z); break; } case 'E': { enemies.Add(new Vector3Int(x, 0, z)); break; } case 'R': { RampCoordinates newCoords; newCoords.coord1 = new Vector3Int(x, 0, z); newCoords.coord2 = FindRampTop(x, z); rampCoordinates.Add(newCoords); break; } case 'U': { defences.Add(new Vector3Int(x, 0, z)); break; } case 'H': { securityHubs.Add(new Vector3Int(x, 0, z)); break; } case 'L': { loot.Add(new Vector3Int(x, 0, z)); break; } case 'O': { firewalls.Add(new Vector3Int(x, 0, z)); missionObj = new Vector3Int(x, 0, z); break; } case 'V': { loot.Add(new Vector3Int(x, 0, z)); firewalls.Add(new Vector3Int(x, 0, z)); break; } case 'T': { terminals.Add(new Vector3Int(x, 0, z)); break; } case 'W': { switchBridges.Add(new Vector3Int(x, 0, z)); break; } case 'P': { ports.Add(new Vector3Int(x, 0, z)); break; } case 'F': { firewalls.Add(new Vector3Int(x, 0, z)); break; } case 'I': { int y = 0; foreach (Vector3Int tile in tiles) { if (tile.x == x && tile.z == z) { y = tile.y; } } entrance = new Vector3Int(x, y, z); break; } case 'X': { exits.Add(new Vector3Int(x, 0, z)); break; } } } z++; x = 0; nextLine = FileReaderUtils.GetNextLine(ref roomText); } } ParseRoomFile(roomText); }
private void ParseLayout(ref string roomText) { string nextLine = FileReaderUtils.GetNextLine(ref roomText); int x = 0; int z = 0; while (nextLine != "++END++") { foreach (char nextChar in nextLine) { switch (nextChar) { case ' ': { x++; break; } case '-': { break; } case 'A': { switchTilesOn.Add(new Vector3Int(x, 0, z)); break; } case 'a': { switchTilesOff.Add(new Vector3Int(x, 0, z)); break; } case 'B': { switchTilesOn.Add(new Vector3Int(x, 1, z)); break; } case 'b': { switchTilesOff.Add(new Vector3Int(x, 1, z)); break; } case 'C': { switchTilesOn.Add(new Vector3Int(x, 2, z)); break; } case 'c': { switchTilesOff.Add(new Vector3Int(x, 2, z)); break; } case 'D': { switchTilesOn.Add(new Vector3Int(x, 3, z)); break; } case 'd': { switchTilesOff.Add(new Vector3Int(x, 3, z)); break; } default: { if (Char.IsDigit(nextChar)) { tiles.Add(new Vector3Int(x, int.Parse(nextChar.ToString()), z)); } break; } } } x = 0; z++; nextLine = FileReaderUtils.GetNextLine(ref roomText); } ParseRoomFile(roomText); }