diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index 968fabcc..a4a5d2eb 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -5,6 +5,7 @@ local DataManager = { function DataManager:init() self.cdCallBack = {} self._cacheManager = {} + self:initManager("GameSettingData", "app/userdata/game_setting/game_setting_data") self:initManager("PlayerData", "app/userdata/player/player_data") self:initManager("ChapterData", "app/userdata/chapter/chapter_data") self:initManager("HeroData", "app/userdata/hero/hero_data") diff --git a/lua/app/userdata/game_setting/game_setting_data.lua b/lua/app/userdata/game_setting/game_setting_data.lua new file mode 100644 index 00000000..a3573509 --- /dev/null +++ b/lua/app/userdata/game_setting/game_setting_data.lua @@ -0,0 +1,48 @@ +local GameSettingData = class("GameSettingData", BaseData) + +local QUALITY_LEVEL_LOW = 1 +local QUALITY_LEVEL_MID = 5 +local QUALITY_LEVEL_HIGH = 10 + +function GameSettingData:ctor() + local qualityLevel = LocalData:getGameQualityLevel() -- 默认是0,按hight处理 + if qualityLevel == 0 then + qualityLevel = QUALITY_LEVEL_HIGH + end + if qualityLevel <= QUALITY_LEVEL_LOW then + self.data.qualityLevel = QUALITY_LEVEL_LOW + if not EDITOR_MODE then + CS.UnityEngine.Application.targetFrameRate = 60 + end + else + self.data.qualityLevel = QUALITY_LEVEL_HIGH + if not EDITOR_MODE then + CS.UnityEngine.Application.targetFrameRate = 60 + end + end +end + +function GameSettingData:switchQualityLevel() + if self:isHighQualityLevel() then + self.data.qualityLevel = QUALITY_LEVEL_LOW + if not EDITOR_MODE then + CS.UnityEngine.Application.targetFrameRate = 60 + end + else + self.data.qualityLevel = QUALITY_LEVEL_HIGH + if not EDITOR_MODE then + CS.UnityEngine.Application.targetFrameRate = 60 + end + end + LocalData:setGameQualityLevel(self.data.qualityLevel) +end + +function GameSettingData:isHighQualityLevel() + return self.data.qualityLevel >= QUALITY_LEVEL_HIGH +end + +function GameSettingData:isLowQualityLevel() + return self.data.qualityLevel <= QUALITY_LEVEL_LOW +end + +return GameSettingData \ No newline at end of file diff --git a/lua/app/userdata/game_setting/game_setting_data.lua.meta b/lua/app/userdata/game_setting/game_setting_data.lua.meta new file mode 100644 index 00000000..325a766d --- /dev/null +++ b/lua/app/userdata/game_setting/game_setting_data.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d3d203112916fef4da96460958d056e2 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}