public void init(Settings settings) { if (tsStart == 0) { tsStart = Main.getCurrentTimestamp(); } if (playerGuid == null) { playerGuid = Guid.NewGuid().ToString(); } tsSessionStarts.Add(currentGameStart); sessionIdx = tsSessionStarts.Count - 1; if (currentPark == null && currentParkGuid.Length > 0) { currentPark = new ParkData(); currentPark.setGuid(currentParkGuid); } if (!parks.ContainsKey(currentPark.guid)) { parks.Add(currentPark.guid, currentPark); } currentPark.init(settings); }
public override List <string> loadByHandles() { uint currentDataVersionIdx = dataVersionIdx; dataVersionIdx = 0; // set to 0 to check data version from file List <string> msgs = base.loadByHandles(); Debug.LogMT("data version " + dataVersionIdx); if (dataVersionIdx == 0) { // related to dataVersionIdx = 0 in loadByHandles // backup old data and keep main data valid if no newer dataVersionIdx has been loaded // old park guid data will be ignored in the further process automatically fh.backupAll(dataVersionIdx); fh.deleteAll(); oldDataVersion = true; } dataVersionIdx = currentDataVersionIdx; List <string> parkGuidsToRemove = new List <string>(); foreach (string parkGuid in parks.Keys) { if (currentParkOnly == false || (currentParkGuid == parkGuid)) { msgs.AddRange(parks[parkGuid].loadByHandles()); if (parks[parkGuid].errorOnLoad || parks[parkGuid].oldDataVersion) { parkGuidsToRemove.Add(parkGuid); } else if (parks.ContainsKey(parkGuid) && currentParkGuid == parkGuid) { currentPark = parks[parkGuid]; } } } if (parkGuidsToRemove.Count > 0) { foreach (string parkGuid in parkGuidsToRemove) { parks.Remove(parkGuid); } } return(msgs); }
public void init(Settings settings) { if (tsStart == 0) tsStart = Main.getCurrentTimestamp(); if (playerGuid == null) playerGuid = Guid.NewGuid().ToString(); tsSessionStarts.Add(currentGameStart); sessionIdx = tsSessionStarts.Count - 1; if (currentPark == null && currentParkGuid.Length > 0) { currentPark = new ParkData(); currentPark.setGuid(currentParkGuid); } if (!parks.ContainsKey(currentPark.guid)) parks.Add(currentPark.guid, currentPark); currentPark.init(settings); }
public override List<string> loadByHandles() { uint currentDataVersionIdx = dataVersionIdx; dataVersionIdx = 0; // set to 0 to check data version from file List<string> msgs = base.loadByHandles(); Debug.LogMT("data version " + dataVersionIdx); if (dataVersionIdx == 0) { // related to dataVersionIdx = 0 in loadByHandles // backup old data and keep main data valid if no newer dataVersionIdx has been loaded // old park guid data will be ignored in the further process automatically fh.backupAll(dataVersionIdx); fh.deleteAll(); oldDataVersion = true; } dataVersionIdx = currentDataVersionIdx; List<string> parkGuidsToRemove = new List<string>(); foreach (string parkGuid in parks.Keys) { if (currentParkOnly == false || (currentParkGuid == parkGuid)) { msgs.AddRange(parks[parkGuid].loadByHandles()); if (parks[parkGuid].errorOnLoad || parks[parkGuid].oldDataVersion) { parkGuidsToRemove.Add(parkGuid); } else if (parks.ContainsKey(parkGuid) && currentParkGuid == parkGuid) { currentPark = parks[parkGuid]; } } } if (parkGuidsToRemove.Count > 0) { foreach (string parkGuid in parkGuidsToRemove) { parks.Remove(parkGuid); } } return msgs; }
protected override bool setObjByKey(string handle, string key, object obj) { bool success = base.setObjByKey(handle, key, obj); if (handle == "main") { switch (key) { case "playerGuid": playerGuid = obj.ToString(); break; case "parkGuids": List <object> parkGuids = obj as List <object>; foreach (object parkGuid in parkGuids) { if (currentParkOnly == false || (currentParkGuid == parkGuid.ToString())) { ParkData nPark = new ParkData(); nPark.setGuid(parkGuid.ToString()); parks.Add(nPark.guid, nPark); if (currentParkGuid == parkGuid.ToString()) { currentPark = nPark; } } else { parks.Add(parkGuid.ToString(), null); } } break; } } return(success); }
protected override bool setObjByKey(string handle, string key, object obj) { bool success = base.setObjByKey(handle, key, obj); if (handle == "main") { switch (key) { case "playerGuid": playerGuid = obj.ToString(); break; case "parkGuids": List<object> parkGuids = obj as List<object>; foreach (object parkGuid in parkGuids) { if (currentParkOnly == false || (currentParkGuid == parkGuid.ToString())) { ParkData nPark = new ParkData(); nPark.setGuid(parkGuid.ToString()); parks.Add(nPark.guid, nPark); if (currentParkGuid == parkGuid.ToString()) { currentPark = nPark; } } else { parks.Add(parkGuid.ToString(), null); } } break; } } return success; }