Esempio n. 1
0
        protected override void OnLoadStart()
        {
            gameSchedule          = new GameSchedule();
            listAlongGameSchedule = new List <AloneGameSchedule>();
            dicSchedule           = new Dictionary <int, AloneGameSchedule>();
            playerStatus          = new PlayerStatus();
            playerInventory       = new PlayerInventory();
            holostarSetting       = new HoloStarSetting();
            mobileOption          = new MobileOption();

            scheduleModel        = Model.First <ScheduleModel>();
            playerStatusModel    = Model.First <PlayerStatusModel>();
            playerInventoryModel = Model.First <PlayerInventoryModel>();
            settingModel         = Model.First <SettingModel>();
            holostarSettingModel = Model.First <HolostarSettingModel>();
            mobileOptionModel    = Model.First <MobileOptionModel>();

            CheckFile("Schedule");
            CheckFile("PlayerStatus");
            CheckFile("PlayerInventory");
            CheckFile("HoloStarSetting");
            CheckFile("MobileOption");
            SetLoadComplete();
        }
Esempio n. 2
0
        void CheckFile(string fileName)
        {
#if (UNITY_EDITOR)
            string path = Application.dataPath + "/Resources/Json/" + fileName + ".json";
#elif (UNITY_ANDROID)
            string sDirPath;
            sDirPath = Application.persistentDataPath + "/Json";
            DirectoryInfo di = new DirectoryInfo(sDirPath);
            if (di.Exists == false)
            {
                di.Create();
            }

            string path = Application.persistentDataPath + "/Json/" + fileName + ".json";
#endif
            FileInfo fi = new FileInfo(path);
            if (fi.Exists)
            {
                if (fileName == "PlayerStatus")
                {
                    playerStatus = LoadJsonFile <PlayerStatus>("PlayerStatus");
                    playerStatusModel.CharacterStatus = playerStatus;
                }
                else if (fileName == "Schedule")
                {
                    gameSchedule = LoadJsonFile <GameSchedule>("Schedule");
                    for (int i = 0; i < gameSchedule.alonGameShedule.Length; i++)
                    {
                        listAlongGameSchedule.Add(gameSchedule.alonGameShedule[i]);
                        dicSchedule.Add(i, gameSchedule.alonGameShedule[i]);
                    }
                    scheduleModel.DicSchedule = dicSchedule;
                }
                else if (fileName == "PlayerInventory")
                {
                    playerInventory = LoadJsonFile <PlayerInventory>("PlayerInventory");
                    playerInventoryModel.PlayerInventory   = playerInventory;
                    playerInventoryModel.ArrayBuyCharacter = playerInventory.buyCharacter;
                    playerInventoryModel.ArrayBuySkinNum   = playerInventory.buySkinNum;
                }
                else if (fileName == "HoloStarSetting")
                {
                    holostarSetting = LoadJsonFile <HoloStarSetting>("HoloStarSetting");
                    holostarSettingModel.HoloStarSetting = holostarSetting;
                }
                else if (fileName == "MobileOption")
                {
                    mobileOption = LoadJsonFile <MobileOption>("MobileOption");
                    mobileOptionModel.MobileOption = mobileOption;
                }
            }
            else
            {
                if (fileName == "PlayerStatus")
                {
                    CreatePlayerStatus();
                    playerStatusModel.CharacterStatus = playerStatus;
                }
                else if (fileName == "Schedule")
                {
                    CreateScheduleJson();

                    for (int i = 0; i < listAlongGameSchedule.Count; i++)
                    {
                        dicSchedule.Add(i, listAlongGameSchedule[i]);
                    }

                    scheduleModel.DicSchedule = dicSchedule;
                }
                else if (fileName == "PlayerInventory")
                {
                    CreatePlayerInventoryJson();
                    playerInventoryModel.PlayerInventory   = playerInventory;
                    playerInventoryModel.ArrayBuyCharacter = playerInventory.buyCharacter;
                    playerInventoryModel.ArrayBuySkinNum   = playerInventory.buySkinNum;
                }
                else if (fileName == "HoloStarSetting")
                {
                    CreateSettingJson();
                    holostarSettingModel.HoloStarSetting = holostarSetting;
                }
                else if (fileName == "MobileOption")
                {
                    CreateMobileOptionJson();
                    mobileOptionModel.MobileOption = mobileOption;
                }
            }
        }