源战役客户端
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.

175 rivejä
4.6 KiB

4 viikkoa sitten
  1. CheatPropertyView = CheatPropertyView or BaseClass(BaseView)
  2. local CheatPropertyView = CheatPropertyView
  3. CheatPropertyView.Properties = {
  4. {1001, "fighting"},
  5. {1, "att"},
  6. {4, "def"},
  7. {5, "hit"},
  8. {6, "dodge"},
  9. {7, "crit"},
  10. {8, "ten"},
  11. {9, "hurt_add_ratio"},
  12. {10, "hurt_del_ratio"},
  13. {11, "hit_ratio"},
  14. {12, "dodge_ratio"},
  15. {13, "crit_ratio"},
  16. {14, "uncrit_ratio"},
  17. {15, "abs_att"},
  18. {16, "abs_def"},
  19. {27, "skill_hurt_add_ratio"},
  20. {28, "skill_hurt_del_ratio"},
  21. {29, "final_hurt_add_ratio"},
  22. {30, "final_hurt_del_ratio"},
  23. {51, "pvp_hurt_add_ratio"},
  24. {52, "crit_hurt_add_ratio"},
  25. {53, "crit_hurt_del_ratio"},
  26. {203, "boss_hurt_add_ratio"},
  27. {19, "att_add_ratio"},
  28. {20, "hp_add_ratio"},
  29. {54, "heart_ratio"},
  30. {56, "heart_resist_ratio"},
  31. {58, "att_speed_add_ratio"},
  32. {59, "speed_add_ratio"},
  33. {201, "hp_resume"},
  34. {77, "ice_hurt"},
  35. {78, "ice_def"},
  36. {79, "thunder_hurt"},
  37. {80, "thunder_def"},
  38. {81, "fire_hurt"},
  39. {82, "fire_def"},
  40. {83, "wind_hurt"},
  41. {84, "wind_def"},
  42. {21, "exp_add_ratio"},
  43. {48, "parry_ratio"},
  44. {49, "stab_ratio"},
  45. {50, "pvp_hurt_del_ratio"},
  46. {55, "heart_add_hurt"},
  47. {57, "heart_del_hurt"},
  48. }
  49. function CheatPropertyView:__init()
  50. self.base_file = "cheat"
  51. self.layout_file = "CheatPropertyView"
  52. self.layer_name = "Top"
  53. self.destroy_imm = true
  54. self.use_background = false
  55. self.change_scene_close = true
  56. self.load_callback = function ()
  57. self:LoadSuccess()
  58. self:AddEvent()
  59. end
  60. self.open_callback = function ( )
  61. self:OpenSuccess()
  62. end
  63. self.destroy_callback = function ( )
  64. self:DestroySuccess()
  65. end
  66. end
  67. function CheatPropertyView:Open( )
  68. --self.data = data
  69. BaseView.Open(self)
  70. end
  71. function CheatPropertyView:LoadSuccess()
  72. self.nodes = {
  73. "bg/scroll_view","bg/close_btn:obj","bg/scroll_view/Viewport/Content",
  74. "bg/hp:txt",
  75. }
  76. self:GetChildren(self.nodes)
  77. SetAnchoredPosition(self.transform, 0, 0)
  78. end
  79. function CheatPropertyView:AddEvent()
  80. local function onBtnClickHandler( target )
  81. self:Close()
  82. end
  83. AddClickEvent(self.close_btn_obj, onBtnClickHandler)
  84. local function on_hp_change( )
  85. self:UpdateHp()
  86. end
  87. self.bind_hp_id = RoleManager.Instance.mainRoleInfo:BindOne("hp",on_hp_change)
  88. self.bind_maxHp_id = RoleManager.Instance.mainRoleInfo:BindOne("maxHp",on_hp_change)
  89. local function on_all_change( )
  90. self:UpdateProperties()
  91. self:UpdateHp()
  92. end
  93. self.bind_property_id = RoleManager.Instance.mainRoleInfo:Bind(EventName.UPDATE_MAIN_ROLE_INFO_VIEW, on_all_change)
  94. self.bind_fighting_id = RoleManager.Instance.mainRoleInfo:BindOne("fighting", on_all_change)
  95. self.bind_level_id = RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, on_all_change)
  96. end
  97. function CheatPropertyView:OpenSuccess()
  98. self:UpdateProperties()
  99. self:UpdateHp()
  100. end
  101. function CheatPropertyView:UpdateProperties()
  102. local attr_list = CheatPropertyView.Properties
  103. self.attr_list_con = self.attr_list_con or self:AddUIComponent(UI.ItemListCreator)
  104. local info = {
  105. data_list = attr_list,
  106. item_con = self.Content,
  107. scroll_view = self.scroll_view,
  108. prefab_ab_name = "cheat",
  109. prefab_res_name = "CheatPropertyItem",
  110. item_height = 30,
  111. space_y = 2,
  112. child_names = {"text:txt",},
  113. on_update_item = function(item, i, v)
  114. local index = tonumber(v[1])
  115. if index > 1000 then --自定义属性
  116. local str = ""
  117. if index == 1001 then
  118. str = string.format("等级:%d 战力:%d", RoleManager.Instance.mainRoleInfo.level, RoleManager.Instance.mainRoleInfo[v[2]] or 99999999)
  119. end
  120. item.text_txt.text = str
  121. else
  122. local name = WordManager:GetProperties(tonumber(v[1]))
  123. local role_value = RoleManager.Instance.mainRoleInfo[v[2]] or 99999999
  124. local value = WordManager:GetPropertyValue(tonumber(v[1]), role_value)
  125. item.text_txt.text = "(" .. tonumber(v[1]) .. ")" .. name .. ": " .. value
  126. end
  127. end,
  128. }
  129. self.attr_list_con:UpdateItems(info)
  130. end
  131. function CheatPropertyView:UpdateHp( )
  132. local hp_str = string.format("血量:%d/%d", RoleManager.Instance.mainRoleInfo.hp, RoleManager.Instance.mainRoleInfo.maxHp)
  133. self.hp_txt.text = hp_str
  134. end
  135. function CheatPropertyView:DestroySuccess( )
  136. if self.bind_hp_id then
  137. RoleManager.Instance.mainRoleInfo:UnBind(self.bind_hp_id)
  138. self.bind_hp_id = nil
  139. end
  140. if self.bind_maxHp_id then
  141. RoleManager.Instance.mainRoleInfo:UnBind(self.bind_maxHp_id)
  142. self.bind_maxHp_id = nil
  143. end
  144. if self.bind_property_id then
  145. RoleManager.Instance.mainRoleInfo:UnBind(self.bind_property_id)
  146. self.bind_property_id = nil
  147. end
  148. if self.bind_fighting_id then
  149. RoleManager.Instance.mainRoleInfo:UnBind(self.bind_fighting_id)
  150. self.bind_fighting_id = nil
  151. end
  152. if self.bind_level_id then
  153. RoleManager.Instance.mainRoleInfo:UnBind(self.bind_level_id)
  154. self.bind_level_id = nil
  155. end
  156. end