//開啟時,一次加回超時的疲勞值 private void OnEnable() { //讀檔 TimeManager.timeData = Save_LoadSystem.LoadTimeData(); if (TimeManager.timeData == null) { TimeManager.timeData = new TimeManager.TimeData(); } //總經過時間.秒數/恢復所需時間.秒數 =疲勞值恢復數量 TimeSpan duration = TimeManager.timeData.NextAPrestoreTime - TimeManager.NowTime; Debug.Log("中途時間 " + duration); Debug.Log("下個AP時間 " + TimeManager.timeData.NextAPrestoreTime.ToString()); int _ap = Mathf.FloorToInt((float)duration.TotalSeconds / (TimeManager.NextAP_Gap * 60)); Debug.Log("<color=red>這期間恢復了 " + _ap + " 疲勞</color>"); //AP上限 if (_ap >= 0) { GM.playerData.AP += _ap; if (GM.playerData.AP >= 5) { GM.playerData.AP = 5; } } }
private void Awake() { Debug.Log("Load TimeData!"); //讀檔 timeData = Save_LoadSystem.LoadTimeData(); if (timeData == null) { timeData = new TimeData(); } }
//開啟時,一次加回超時的任務 private void OnEnable() { //讀檔 TimeManager.timeData = Save_LoadSystem.LoadTimeData(); if (TimeManager.timeData == null) { TimeManager.timeData = new TimeManager.TimeData(); } //總經過時間.秒數/任務產生所需時間.秒數 =任務增加數量 TimeSpan duration = TimeManager.timeData.NextMissionTime - TimeManager.NowTime; Debug.Log("任務中途時間 " + duration); Debug.Log("下個任務時間 " + TimeManager.timeData.NextMissionTime.ToString()); int _mis = Mathf.FloorToInt((float)duration.TotalSeconds / (TimeManager.NextMissionGap * 60)); Debug.Log("<color=red>這期間恢復了 " + _mis + " 個任務</color>"); //產生任務 if (_mis >= 0) { //目前任務數量 int _missinonCount = MissionManager.instance.GetComponents <MissionClass>().Length; //任務上限 _mis = ((_missinonCount + _mis) > 5) ? (5 - _missinonCount) : _mis; //增加任務 for (int i = 0; i < _mis; i++) { //生產任務 int _type = UnityEngine.Random.Range(0, 30); RamdomAddMission((_type % _missionTypeTotalCount) + 1); } //刷新頁面 CreatMissionList(); } }