源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
6.2 KiB

  1. AutoSettingView = AutoSettingView or BaseClass(BaseItem)
  2. -- 挂机设置界面
  3. function AutoSettingView:__init(parent)
  4. self.base_file = "setting"
  5. self.layout_file = "AutoSettingView"
  6. self.fight_model = AutoFightManager:getInstance()
  7. self.skil_list = {}
  8. self:Load()
  9. end
  10. function AutoSettingView:Load_callback()
  11. self:LoadSuccess()
  12. self:InitEvent()
  13. end
  14. function AutoSettingView:LoadSuccess()
  15. self.skill_con = self:GetChild("autoSkill")
  16. self.autoClick = {
  17. autoReborn = self:GetChild("autoSet/autoReborn"),
  18. autoFlyShoe = self:GetChild("autoSet/autoFlyShoe"),
  19. autoPowerSave = self:GetChild("autoSet/autoPowerSave"),
  20. autoReborn_tmp = self:GetChild("autoSet/autoReborn/Label"):GetComponent("TextMeshProUGUI"),
  21. autoFlyShoe_tmp = self:GetChild("autoSet/autoFlyShoe/Label"):GetComponent("TextMeshProUGUI"),
  22. autoPowerSave_tmp = self:GetChild("autoSet/autoPowerSave/Label"):GetComponent("TextMeshProUGUI"),
  23. }
  24. self.doubtBtn = self:GetChild("doubtBtn").gameObject
  25. if self.need_refreshData then
  26. self:SetData()
  27. end
  28. end
  29. function AutoSettingView:InitEvent()
  30. --普通toggle
  31. local function onToggleClickHandler(target)
  32. local state = target:GetComponent("Toggle").isOn
  33. if target == self.autoClick.autoReborn.gameObject then
  34. lua_settingM:SetAutoRebornSet(state)
  35. self.autoClick.autoReborn_tmp.color = ColorUtil:ConvertHexToRGBColor(state and "#f3fcff" or "#a9c1e1")
  36. elseif target == self.autoClick.autoFlyShoe.gameObject then
  37. lua_settingM:SetAutoFlyShoeSet(state)
  38. self.autoClick.autoFlyShoe_tmp.color = ColorUtil:ConvertHexToRGBColor(state and "#f3fcff" or "#a9c1e1")
  39. elseif target == self.autoClick.autoPowerSave.gameObject then
  40. lua_settingM:SetAutoPowerSaveSet(state)
  41. self.autoClick.autoPowerSave_tmp.color = ColorUtil:ConvertHexToRGBColor(state and "#f3fcff" or "#a9c1e1")
  42. end
  43. end
  44. AddClickEvent(self.autoClick.autoReborn.gameObject,onToggleClickHandler)
  45. AddClickEvent(self.autoClick.autoFlyShoe.gameObject,onToggleClickHandler)
  46. AddClickEvent(self.autoClick.autoPowerSave.gameObject,onToggleClickHandler)
  47. local on_click = function ( click_obj )
  48. if self.doubtBtn == click_obj then
  49. EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, "102@1")
  50. end
  51. end
  52. AddClickEvent(self.doubtBtn, on_click,LuaSoundManager.SOUND_UI.NONE)
  53. local function return_default(cur_index)
  54. if not self.is_loaded then return end
  55. if cur_index == GameSettingModel.TabData.AUTO then
  56. self:ReturnDefault()
  57. end
  58. end
  59. self:BindEvent(GameSettingModel:GetInstance(), GameSettingModel.RETURN_ALL_DEFAULT, return_default)
  60. end
  61. function AutoSettingView:SetData()
  62. if not self.is_loaded then
  63. self.need_refreshData = true
  64. return
  65. end
  66. self.need_refreshData = false
  67. local reborn_bool = lua_settingM:GetAutoRebornSet() and true or false
  68. self.autoClick.autoReborn:GetComponent("Toggle").isOn = reborn_bool
  69. self.autoClick.autoReborn_tmp.color = ColorUtil:ConvertHexToRGBColor(reborn_bool and "#f3fcff" or "#a9c1e1")
  70. local fly_bool = lua_settingM:GetAutoFlyShoeSet() and true or false
  71. self.autoClick.autoFlyShoe:GetComponent("Toggle").isOn = fly_bool
  72. self.autoClick.autoFlyShoe_tmp.color = ColorUtil:ConvertHexToRGBColor(fly_bool and "#f3fcff" or "#a9c1e1")
  73. local power_bool = lua_settingM:GetAutoFlyShoeSet() and true or false
  74. self.autoClick.autoPowerSave:GetComponent("Toggle").isOn = power_bool
  75. self.autoClick.autoPowerSave_tmp.color = ColorUtil:ConvertHexToRGBColor(power_bool and "#f3fcff" or "#a9c1e1")
  76. self:SetAutoSKill()
  77. end
  78. function AutoSettingView:SetAutoSKill()
  79. local shortcut_list = {}
  80. local shortcut_data = DeepCopy(SkillManager.Instance:GetCurShortcutList())
  81. for i,v in ipairs(shortcut_data) do
  82. if shortcut_data[i].id ~= 0 then
  83. local vo = {skill_id = shortcut_data[i].id,
  84. type = shortcut_data[i].type,
  85. name = SkillManager:getInstance():GetSkillNameById(shortcut_data[i].id),
  86. pos = shortcut_data[i].pos
  87. }
  88. table.insert(shortcut_list,vo)
  89. end
  90. end
  91. if not shortcut_list[1] then
  92. return
  93. end
  94. if #shortcut_list > 1 then
  95. table.sort( shortcut_list, function (a,b)
  96. return a.pos < b.pos
  97. end )
  98. end
  99. local task_cfg = Config.ConfigTaskEffect.SkillPosToTaskId
  100. local len = #shortcut_list
  101. --插入锁定状态的item
  102. for i=len+1,8 do
  103. local vo = {}
  104. vo.empty_data = true
  105. table.insert(shortcut_list,vo)
  106. end
  107. local item
  108. for i,v in ipairs(shortcut_list) do
  109. item = self.skil_list[i]
  110. if item == nil then
  111. item = SelectSkillItem.New(self.skill_con)
  112. table.insert(self.skil_list,item)
  113. end
  114. item:SetData(i,v)
  115. end
  116. end
  117. --旧的技能创建逻辑,先不要干掉
  118. -- function AutoSettingView:OldSetAutoSKill()
  119. -- local skil_table = {}
  120. -- local cfg = Config.ConfigSkillUI.InitiativeSkill
  121. -- if not cfg then return end
  122. -- local role_info = RoleManager.Instance:GetMainRoleVo()
  123. -- local career = role_info.career
  124. -- local sex = role_info.sex
  125. -- local data = cfg[career.."@"..sex]
  126. -- local hit_skill = SkillManager:getInstance():GetHitSkillVo()
  127. -- -- local god_skill = role_info.level >= Config.ConfigOpenLv.FunctionIconOpenLv.God and SkillManager.GodSkillId or nil
  128. -- for i=2,#data do
  129. -- local vo = { skill_id = data[i],type = 0,name = SkillManager:getInstance():GetSkillNameById(data[i]) }
  130. -- table.insert(skil_table,vo)
  131. -- end
  132. -- if hit_skill then
  133. -- local vo = { skill_id = hit_skill.id,type = 1 ,name = SkillManager:getInstance():GetSkillNameById(hit_skill.id)}
  134. -- table.insert(skil_table,vo)
  135. -- end
  136. -- -- if god_skill then
  137. -- -- local vo = { skill_id = god_skill,type = 0 ,name = "降神变身"}
  138. -- -- table.insert(skil_table,vo)
  139. -- -- end
  140. -- local list = skil_table
  141. -- local len = #list
  142. -- local item
  143. -- for i,v in ipairs(list) do
  144. -- item = self.skil_list[i]
  145. -- if item == nil then
  146. -- item = SelectSkillItem.New(self.skill_con)
  147. -- table.insert(self.skil_list,item)
  148. -- end
  149. -- item:SetData(i,v)
  150. -- item:SetPosition((897/len)*(i-1), 0)
  151. -- end
  152. -- end
  153. function AutoSettingView:__delete( )
  154. for i,item in ipairs(self.skil_list) do
  155. item:DeleteMe()
  156. end
  157. end
  158. function AutoSettingView:ReturnDefault( )
  159. lua_settingM:SetAutoRebornSet(false)
  160. lua_settingM:SetAutoFlyShoeSet(false)
  161. lua_settingM:SetAutoPowerSaveSet(true)
  162. for i,item in ipairs(self.skil_list) do
  163. item:SetStateCacheDefault()
  164. end
  165. self:SetData()
  166. end