private SaveUnit SaveSaveFile(int number, SaveUnit su) { string fileName = GetSaveFileName(number); byte[] raw = MessagePackSerializer.Serialize(su); System.IO.Directory.CreateDirectory(Path.GetDirectoryName(fileName)); System.IO.File.WriteAllBytes(fileName, raw); return(su); }
public void LoadDefaultSaveUnitToCurrent() { SaveUnit.GetDefaultSaveUnit().SetAsCurrent(); }
public static void LoadDefaultSaveUnitToCurrent(DefaultEnvironmentData defaultEnvironment = null) { var su = SaveUnit.GetEmptySaveUnit(); //初期環境のセットアップ if (defaultEnvironment != null) { var structure = su.s_GameContext.s_NestData.Structure; structure.NestElements.AddRange(defaultEnvironment.GeneralPathRoads); //エサ備蓄 su.s_GameContext.s_NestData.StoredFood = defaultEnvironment.StoredFood; //道 var initialRoad = new IShapeRoadData() { Position = defaultEnvironment.InitialRoadPosition, Direction = EnumRoadHVDirection.Vertical }; structure.NestElements.Add(initialRoad); NestSystem.ParseNodePath(defaultEnvironment.InitialRoadBindNodePath, out string guid, out string name); structure.ElementEdges.Add(new NestPathElementEdgeData() { ElementGuidA = initialRoad.Guid, ElementGuidB = guid, NodeNameA = defaultEnvironment.InitialRoadNodeName, NodeNameB = name }); //砂糖山 var sugarStack = new MtSugarData() { Position = defaultEnvironment.SugarStackPosition }; structure.NestElements.Add(sugarStack); NestSystem.ParseNodePath(defaultEnvironment.SugarStackBindNodePath, out guid, out name); structure.ElementEdges.Add(new NestPathElementEdgeData() { ElementGuidA = sugarStack.Guid, ElementGuidB = guid, NodeNameA = defaultEnvironment.SugarStackNodeName, NodeNameB = name }); //アリ var ants = su.s_GameContext.s_NestData.Ants; for (int i = 0; i < defaultEnvironment.BuilderAntCount; i++) { ants.Add(new BuilderAntData()); } for (int i = 0; i < defaultEnvironment.ErgateAntCount; i++) { ants.Add(new ErgateAntData()); } for (int i = 0; i < defaultEnvironment.UnemployedAntCount; i++) { ants.Add(new UnemployedAntData()); } } su.SetAsCurrent(); }