Пример #1
0
        /// <summary>
        /// playerをシリアライズしたJsonをファイルに書き込む
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public static string MakeSaveDataJSON(PlayerSettings player)
        {
            string json = JsonMapper.ToJson(player);

            using (FileStream stream = new FileStream("Assets/" + SAVE_DATA_FOLDER_NAME + "/" + PLAYER_DATA_FILE_NAME, FileMode.Create, FileAccess.Write))
            {
                using (StreamWriter writer = new StreamWriter(stream))
                {
                    writer.Write(json);
                }
            }
            return json;
        }
Пример #2
0
        /// <summary>
        /// ゲームの一番最初に呼んで、セーブデータの読み込みなどをする
        /// </summary>
        public static void Initialilze()
        {
            if (PlayerSettings != null) return;

            LoadSaveData();

            EquipedPartsList = new List<PartsID>();
            for(var i = 0;i < System.Enum.GetValues(typeof(PartsPlace)).Length;i++)
            {
                EquipedPartsList.Add(PartsID.None);
            }
            PlayerSettings = new PlayerSettings()
            {
                Name = "8823",
                HPLevel = 8,
                SpeedLevel = 2,
                Money = 2000,
                SenarioID = 2,
                PartsSettingList = new List<PartsSetting>() { new PartsSetting(PartsID.DoubleMachineGun, 3, 300, 6), new PartsSetting(PartsID.Beam, 4, 11301, 7), new PartsSetting(PartsID.MachineGun, 4, 32, 5), new PartsSetting(PartsID.Booster, 3, 500, 2), new PartsSetting(PartsID.Bomb, 5, 100, 2) },
                AILevels = new List<AISetting>() { new AISetting("AI1", 7), new AISetting("AI2", 3) },
            };
        }
Пример #3
0
 /// <summary>
 /// jsonをデシリアライズしたものをPlaerSettingsに代入する
 /// </summary>
 /// <param name="json"></param>
 public static void LoadSaveDataJson(string json)
 {
     PlayerSettings jdata = JsonMapper.ToObject<PlayerSettings>(json);
     PlayerSettings = jdata;
 }