源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

239 行
7.1 KiB

  1. ReChargePreView = ReChargePreView or BaseClass(BaseView)
  2. local ReChargePreView = ReChargePreView
  3. --首充预告
  4. function ReChargePreView:__init(parent)
  5. self.base_file = "guide"
  6. self.layout_file = "ReChargePreView"
  7. self.layer_name = "UI"
  8. self.mainVo = RoleManager.Instance.mainRoleInfo
  9. self.destroy_imm = true
  10. self.hide_maincancas = false
  11. self.diff_time = 15
  12. self.close_mode = CloseMode.CloseVisible
  13. self.change_scene_close = true
  14. self.is_set_order_sorting = false
  15. -- self.use_local_view = true
  16. --回调方法
  17. self.load_callback = function()
  18. self:LoadSuccess()
  19. self:InitEvent()
  20. end
  21. self.open_callback = function()
  22. if self.is_pre_load then
  23. return
  24. end
  25. self:UpdateView()
  26. self.diff_time = 15
  27. self:StopTimer()
  28. self:StartTimer()
  29. -- self:AddUIEffect("ui_meirishouchong", self.goEffect, self.layer_name, nil, {x=1,y=1}, true,false,nil,nil)
  30. end
  31. self.close_callback = function()
  32. end
  33. self.destroy_callback = function()
  34. self:Clear()
  35. end
  36. end
  37. function ReChargePreView:Open(bool)
  38. self.is_pre_load = bool
  39. BaseView.Open(self)
  40. end
  41. function ReChargePreView:LoadSuccess()
  42. self.closeBtn,
  43. self.combatLabel,
  44. self.useBtn = self:GetChildGameObjects({
  45. "CloseBtn",
  46. "combatLabel",
  47. "UseBtn"
  48. })
  49. self.itemCon,
  50. self.goEffect,
  51. self.otherCon = self:GetChildTransforms({
  52. "itemCon",
  53. "effect",
  54. "otherItemCon",
  55. })
  56. self.roleCombat,
  57. self.otherCombat
  58. = GetChildTexts(self.transform,
  59. {
  60. "combatLabel",
  61. "otherCombat",
  62. })
  63. self.bg = self:GetChildImages({
  64. "Border",
  65. })
  66. local pos = ActivityIconManager.Instance:GetIconPos(7)
  67. if pos then
  68. self.transform.anchoredPosition = Vector2(pos.x--[[-190--]]+75, pos.y--[[-215--]]+445)
  69. end
  70. local config = OutSidePictureMgr.PreLoad.ReChargePreView_BG
  71. if config then
  72. lua_resM:setOutsideImageSprite(self, self.bg,GameResPath.GetImage(config.modele,config.res))
  73. end
  74. end
  75. function ReChargePreView:InitEvent()
  76. local function onClickHandler(target)
  77. if target == self.closeBtn then
  78. self:Close()
  79. elseif target == self.useBtn then
  80. RechargeActivityModel:getInstance():Fire(RechargeActivityModel.OPEN_FIRST_RECHARGE_VIEW)
  81. self:Close()
  82. end
  83. end
  84. AddClickEvent(self.useBtn,onClickHandler)
  85. AddClickEvent(self.closeBtn,onClickHandler)
  86. end
  87. function ReChargePreView:UpdateView( )
  88. local pos = ActivityIconManager.Instance:GetIconPos(7)
  89. if pos then
  90. self.transform.anchoredPosition = Vector2(pos.x--[[-190--]]+75, pos.y--[[-215--]]+445)
  91. end
  92. self:SetRoleModel()
  93. end
  94. function ReChargePreView:Clear( )
  95. self:ClearUIEffect(self.goEffect)
  96. self:StopTimer()
  97. end
  98. function ReChargePreView:StartTimer()
  99. local function onTimer()
  100. if self.diff_time < 1 then
  101. self:Close()
  102. else
  103. self.diff_time = self.diff_time - 1
  104. end
  105. end
  106. self.timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer,1,-1)
  107. end
  108. function ReChargePreView:StopTimer()
  109. if self.timer_id then
  110. GlobalTimerQuest:CancelQuest(self.timer_id)
  111. self.timer_id = nil
  112. end
  113. end
  114. function ReChargePreView:SetRoleModel()
  115. -- local angel = 0
  116. -- local pos = Vector3(35,-110)
  117. -- local scale = 100
  118. -- local action = nil
  119. -- local res_id = 158001
  120. -- local data = {
  121. -- clothe_res_id = res_id,
  122. -- SceneBaseType.Horse,
  123. -- layer_name = self.layer_name,
  124. -- rotate = angel,
  125. -- can_rotate = true,
  126. -- scale = scale,
  127. -- position = pos,
  128. -- layout_file = self.layout_file
  129. -- }
  130. local cfg = Config.Rechargefirst["40@"..self.mainVo.career.."@1"] --直接拿第一个 因为只是显示模型而已 所以其他的也是相同的
  131. if cfg then
  132. local model_id, texture_id = self.mainVo:GetRoleClotheTextureId()
  133. local weapon_model_id, weapon_texture_id = self.mainVo:GetWeaponClotheId()
  134. local head_model_id, head_clothe_id = self.mainVo:GetRoleHeadId()
  135. local fashion_model_id, fashion_texture_id = self.mainVo:GetRoleClotheTextureId()
  136. local leftRes = ErlangParser:GetInstance():Parse(cfg.left_res)
  137. if TableSize(leftRes) > 0 then
  138. local pos_id, fashion_id, config
  139. for _, v in ipairs(leftRes) do
  140. pos_id = tonumber(v[1])
  141. fashion_id = tonumber(v[2])
  142. config = Config.Fashionmodel[pos_id .. "@" .. fashion_id .. "@" .. self.mainVo.career]
  143. if config then
  144. if pos_id == FashionPartPos.Clothe then
  145. fashion_model_id = config.model_id
  146. fashion_texture_id = config.color_id
  147. elseif pos_id == FashionPartPos.Weapon then
  148. weapon_model_id = config.model_id
  149. weapon_texture_id = config.color_id
  150. elseif pos_id == FashionPartPos.Head then
  151. head_model_id = config.model_id
  152. head_clothe_id = config.color_id
  153. end
  154. end
  155. end
  156. end
  157. local data = {
  158. career = self.mainVo.career,
  159. sex = self.mainVo.sex,
  160. clothe_res_id = self.mainVo:GetRoleClotheId(),
  161. weapon_res_id = weapon_model_id,
  162. weapon_clothe_id = weapon_texture_id,
  163. type = SceneBaseType.Role,
  164. layer_name = self.layer_name,
  165. scale = 150,
  166. position = Vector3(0,0,0),
  167. fashion_model_id = fashion_model_id,
  168. texture_id = fashion_texture_id,
  169. -- wing_id = data.wing_id,
  170. -- image_id = data.image_id,
  171. head_wear_id = head_model_id,
  172. head_clothe_id = head_clothe_id,
  173. layout_file = self.layout_file
  174. }
  175. -- lua_resM:SetRoleModel(self, self.itemCon, data)
  176. local rightRes = ErlangParser:GetInstance():Parse(cfg.right_res)
  177. if TableSize(rightRes) > 0 then
  178. -- local show_type = tonumber(rightRes[1] [1]) -- 1模型,2图片
  179. -- self.rightImgObj.gameObject:SetActive(show_type == 2)
  180. -- self.otherCon.gameObject:SetActive(show_type == 1)
  181. local godweapon_id = rightRes[1][2]
  182. local callBack = function()
  183. self.curr_Model = lua_resM:GetPartModel(self, self.otherCon)
  184. if self.curr_Model then
  185. local body_pvo = {} --Config.SceneObjectParticle.Body[tonumber(godweapon_id)]
  186. if body_pvo and body_pvo.always then
  187. for bone_name,particle_vo in pairs(body_pvo.always) do
  188. local bone = FindBone(self.curr_Model.transform, bone_name)
  189. if bone then
  190. local renders = bone:GetComponentsInChildren(typeof(UnityEngine.Renderer))
  191. if renders then
  192. for i = 0, renders.Length - 1 do
  193. local render = renders[i]
  194. render.sortingOrder = 600 + 1
  195. end
  196. end
  197. end
  198. end
  199. end
  200. end
  201. end
  202. local data = {
  203. clothe_res_id = tonumber(godweapon_id),
  204. type = SceneBaseType.Monster,
  205. layer_name = self.layer_name,
  206. scale = 150,
  207. position = Vector3(0,0,0),
  208. layout_file = self.layout_file,
  209. callBack = callBack,
  210. }
  211. lua_resM:SetRoleModel(self, self.otherCon, data)
  212. end
  213. end
  214. -- self.roleCombat.text = "战力+8888"
  215. -- self.otherCombat.text = "战力23000+"
  216. end