Пример #1
0
        //종료 직전 모델 데이터 json 으로 저장
        protected void OnDestroy()
        {
            holostarSettingModel.HoloStarSetting.musicSetting.isMusicPlay = false;
            SaveJson("PlayerInventory", playerInventoryModel.PlayerInventory);
            SaveJson("HoloStarSetting", holostarSettingModel.HoloStarSetting);
            CalanderEvent calanderEvent = new CalanderEvent();

            calanderEvent.alarmEvents = calendarModel.AlarmEvents.ToArray();
            SaveJson("Calendar", calanderEvent);
        }
Пример #2
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();
            calanderEvent         = new CalanderEvent();

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

            CheckFile("PlayerInventory");
            CheckFile("HoloStarSetting");
            CheckFile("Calendar");
            SetLoadComplete();
        }
Пример #3
0
        void CheckFile(string fileName)
        {
            string path = Application.dataPath + "/Resources/Json/" + fileName + ".json";

#if (UNITY_EDITOR)
            path = Application.dataPath + "/Resources/Json/" + fileName + ".json";
#elif (UNITY_STANDALONE_WIN)
            path = Application.dataPath + "/StreamingAssets/Json/" + fileName + ".json";
#elif (UNITY_ANDROID)
            string sDirPath;
            sDirPath = Application.persistentDataPath + "/Json";
            DirectoryInfo di = new DirectoryInfo(sDirPath);
            if (di.Exists == false)
            {
                di.Create();
            }

            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;
                }
                else if (fileName == "HoloStarSetting")
                {
                    holostarSetting = LoadJsonFile <HoloStarSetting>("HoloStarSetting");
                    holostarSettingModel.HoloStarSetting = holostarSetting;
                }
                else if (fileName == "Calendar")
                {
                    calanderEvent             = LoadJsonFile <CalanderEvent>("Calendar");
                    calendarModel.AlarmEvents = calanderEvent.alarmEvents.ToList();
                }
            }
            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;
                }
                else if (fileName == "HoloStarSetting")
                {
                    CreateSettingJson();
                    holostarSettingModel.HoloStarSetting = holostarSetting;
                }
            }
        }
Пример #4
0
        public void ReceiveCalendar(string json)
        {
            try
            {
                _num          = 0;
                alarmCursor   = 0;
                alarmList     = new List <AlarmEvent>();
                calanderEvent = new CalanderEvent();
                CalendarList calendarList = JsonUtility.FromJson <CalendarList>(json);
                Debug.Log(json);
                for (int i = 0; i < calendarList.data.Count; i++)
                {
                    Debug.LogError(calendarList.data.Count);
                    long time = new System.DateTime(int.Parse(calendarList.data[i].year),
                                                    int.Parse(calendarList.data[i].month),
                                                    int.Parse(calendarList.data[i].day),
                                                    int.Parse(calendarList.data[i].hour),
                                                    int.Parse(calendarList.data[i].minute),
                                                    int.Parse(calendarList.data[i].second), DateTime.Now.Kind).Ticks;


                    AlarmEvent alarmEvent = new AlarmEvent();
                    alarmEvent.title = calendarList.data[i].title;
                    alarmEvent.tick  = time;


                    alarmList.Add(alarmEvent);
                }

                IComparer <AlarmEvent> sort = new Sorting();
                alarmList.Sort(sort);

                calanderEvent.alarmEvents = alarmList.ToArray();
                string temp = JsonUtility.ToJson(calanderEvent);
                //Android.AndroidTrasferMgr.Instance.ShowToast("처음 : " + temp);

                calendarModel.AlarmEvents.Clear();
                for (int i = 0; i < alarmList.Count; i++)
                {
                    calendarModel.AlarmEvents.Add(alarmList[i]);
                }


                if (alarmList.Count > 0)
                {
                    //기존
                    //Android.AndroidTrasferMgr.Instance.BluetoothSendMsg(temp, Constants.SENDMSGTYPE.CALENDAR);

                    //테스트
                    Android.AndroidTrasferMgr.Instance.BluetoothSendMsg("start", Constants.SENDMSGTYPE.CALENDAR);

                    for (int i = 0; i < alarmList.Count; i++)
                    {
                        string evt = JsonUtility.ToJson(alarmList[i]);
                        Debug.Log("이벤트 : " + evt);
                        Android.AndroidTrasferMgr.Instance.BluetoothSendMsg(evt, Constants.SENDMSGTYPE.CALENDAR);
                    }

                    Android.AndroidTrasferMgr.Instance.BluetoothSendMsg("end", Constants.SENDMSGTYPE.CALENDAR);
                }

                Message.Send <CreateJosnFileMsg>(new CreateJosnFileMsg("calander", temp));
            }

            catch
            {
                Debug.LogError("Json Catch");
            }
        }