コード例 #1
0
        public static Tank Load(string path, Vector3 position, Quaternion rotation)
        {
            string   json  = File.ReadAllText(path);
            JSONTech jTech = JsonConvert.DeserializeObject <JSONTech>(json);

            return(jTech.ToTech(position, rotation));
        }
コード例 #2
0
        public static void Save(Tank tech, string folder)
        {
            if (!Directory.Exists(folder))
            {
                Console.WriteLine("PreciseSnapshot : Specified path \"" + folder + "\" doesn't exists !");
                return;
            }
            string json = JsonConvert.SerializeObject(JSONTech.FromTech(tech), Formatting.Indented);

            File.WriteAllText(Path.Combine(folder, tech.name + ".json"), json, Encoding.UTF8);
        }
コード例 #3
0
            public static JSONTech FromTech(Tank tech)
            {
                var jTech = new JSONTech {
                    Name   = tech.name,
                    Blocks = new List <JSONBlock>()
                };

                foreach (var block in tech.blockman.IterateBlocks())
                {
                    jTech.Blocks.Add(JSONBlock.FromBlock(block));
                }

                return(jTech);
            }