Example #1
0
        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);
        }
Example #2
0
 public void LoadDefaultSaveUnitToCurrent()
 {
     SaveUnit.GetDefaultSaveUnit().SetAsCurrent();
 }
Example #3
0
        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();
        }