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

206 lines
6.6 KiB

преди 4 седмици
  1. CSGWarOverlordView = CSGWarOverlordView or BaseClass(BaseView)
  2. local CSGWarOverlordView = CSGWarOverlordView
  3. function CSGWarOverlordView:__init()
  4. self.base_file = "CSGWar"
  5. self.layout_file = "CSGWarOverlordView"
  6. self.layer_name = "UI"
  7. self.destroy_imm = true
  8. self.use_background = true --全屏界面默认使用这个参数
  9. self.hide_maincancas = true --全屏界面需要放开隐藏主UI
  10. self.change_scene_close = true
  11. self.append_to_ctl_queue = true --是否要添加进界面堆栈
  12. self.need_show_money = true --是否要显示顶部的金钱栏
  13. self.blur_activity_bg = true
  14. self.close_fog = true
  15. self.model = CSGWarModel:getInstance()
  16. self.load_callback = function ()
  17. self:LoadSuccess()
  18. end
  19. self.open_callback = function ( )
  20. self:OpenSuccess()
  21. end
  22. self.switch_callback = function(index)
  23. self:SwitchTab(index)
  24. end
  25. self.destroy_callback = function ( )
  26. self:DestroySuccess()
  27. end
  28. end
  29. function CSGWarOverlordView:Open( )
  30. --self.data = data
  31. BaseView.Open(self)
  32. end
  33. function CSGWarOverlordView:LoadSuccess()
  34. local nodes = {
  35. "role_con2", "bg:raw", "role_con1", "role_con3", "buy_btn/price_text:tmp", "buy_btn:obj:imgex", "close_btn:obj",
  36. "name_text1:tmp","tip_text:obj",
  37. "name_text2:tmp",
  38. "name_text3:tmp","con_money","image:obj",
  39. }
  40. self:GetChildren(nodes)
  41. self:AddEvent()
  42. self:CreateMoneyView()
  43. lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("csgwar_overlord_bg"),false)
  44. local function bg_back_func( ... )
  45. if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
  46. self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
  47. self:MoveUIToBack(self.bg_raw)
  48. end
  49. end
  50. if self.background_wnd then
  51. bg_back_func()
  52. else
  53. self.bg_back_func = bg_back_func
  54. end
  55. end
  56. function CSGWarOverlordView:AddEvent()
  57. local function on_close( )
  58. self:Close()
  59. end
  60. AddClickEvent(self.close_btn_obj,on_close)
  61. local function on_buy( )
  62. local is_overlord = RoleManager.Instance.mainRoleInfo.is_overlord
  63. if is_overlord == 1 then
  64. self:DoBuy()
  65. else
  66. Message.show("仅限霸主购买哦~")
  67. end
  68. end
  69. AddClickEvent(self.buy_btn_obj, on_buy)
  70. end
  71. function CSGWarOverlordView:OpenSuccess()
  72. self:UpdateView()
  73. end
  74. function CSGWarOverlordView:UpdateView()
  75. local data = self.model:GetCSGWarOverlordInfo()
  76. self.can_buy = data.is_buy == 1
  77. for i,v in ipairs(data.reward) do
  78. self:SetModel(v,i)
  79. end
  80. self.type1_cost = data.price[1].num
  81. local str = string.format("%s%s",WordManager:GetMoneyFaceStr( data.price[1].type ),data.price[1].num)
  82. self.price_text_tmp.text = str
  83. self.buy_btn_imgex.gray = RoleManager.Instance.mainRoleInfo.is_overlord ~= 1 or not self.can_buy
  84. self.tip_text_obj:SetActive(RoleManager.Instance.mainRoleInfo.is_overlord ~= 1 or not self.can_buy)
  85. self.image_obj:SetActive(RoleManager.Instance.mainRoleInfo.is_overlord == 1 and self.can_buy)
  86. end
  87. function CSGWarOverlordView:SetModel( data,index )
  88. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(data.type_id)
  89. if not basic then
  90. print("not goods db data: ",data.type_id)
  91. return
  92. end
  93. self["name_text"..index.."_tmp"].text = Trim(basic.goods_name)
  94. if basic.type == GoodsModel.TYPE.FASHION then
  95. local fashion_id,color_id = FashionModel:getInstance():GetFashionIdByGoodsId(data.type_id)
  96. local cur_cfg = Config.Fashionstarup[fashion_id.."@"..color_id.."@0"]
  97. local career = RoleManager.Instance.mainRoleInfo.career
  98. local fashion_type = FuncOpenModel.TypeId.Clothes
  99. local figure_id = nil
  100. if fashion_id then
  101. if cur_cfg.pos_id == FashionModel.FashionType.HAT then--头饰
  102. career = 0 --目前头饰 是通用的
  103. figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
  104. fashion_type = FuncOpenModel.TypeId.Hat
  105. elseif cur_cfg.pos_id == FashionModel.FashionType.CLOTHES then--服饰
  106. figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
  107. if figure_id < 1000 then
  108. figure_id = figure_id + career * 1000
  109. end
  110. if color_id > 1 then
  111. figure_id = figure_id .. color_id
  112. end
  113. elseif cur_cfg.pos_id == FashionModel.FashionType.WING then--背饰
  114. figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
  115. fashion_type = FuncOpenModel.TypeId.wing
  116. elseif cur_cfg.pos_id == FashionModel.FashionType.WEAPON then--武器
  117. fashion_type = FuncOpenModel.TypeId.Weapon
  118. figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
  119. if figure_id < 1000 then
  120. figure_id = figure_id + career * 1000
  121. end
  122. elseif cur_cfg.pos_id == FashionModel.FashionType.HEAD then--头发
  123. fashion_type = FuncOpenModel.TypeId.Head
  124. figure_id = FashionModel:GetInstance():GetFashionModelId(fashion_id, career, color_id)
  125. if figure_id < 1000 then
  126. figure_id = figure_id + career * 1000
  127. end
  128. if color_id > 1 then
  129. figure_id = figure_id .. color_id
  130. end
  131. end
  132. end
  133. local res_data = {
  134. father_node = self,
  135. transform = self["role_con"..index],
  136. fashion_type = fashion_type,
  137. layer_name = self.layer_name,
  138. size = Vector2(720,720),
  139. scale = 150,
  140. figure_id = figure_id,
  141. ui_model_type = UIModelCommon.ModelType.Model,
  142. position = Vector3(0,-100,0)
  143. }
  144. FuncOpenModel:getInstance():SetModelRes(res_data)
  145. elseif basic.type == GoodsModel.TYPE.FosterSkin then
  146. --珍宝
  147. local show_conf = ShapeModel:GetInstance():GetConfByGoodsId( data.type_id )
  148. local res_data = {
  149. father_node = self,
  150. transform = self["role_con"..index],
  151. fashion_type = show_conf.type + 1000,
  152. layer_name = self.layer_name,
  153. size = Vector2(720,720),
  154. scale = 150,
  155. figure_id = show_conf.model,
  156. ui_model_type = UIModelCommon.ModelType.Model,
  157. position = Vector3(0,-50,0)
  158. }
  159. FuncOpenModel:getInstance():SetModelRes(res_data)
  160. end
  161. end
  162. function CSGWarOverlordView:CreateMoneyView( )
  163. if not self.money_view then
  164. self.money_view = UIMoneyView.New(self.con_money)
  165. end
  166. self.money_view:SetPosition(0,0)
  167. self.money_view:SetData()
  168. end
  169. function CSGWarOverlordView:DoBuy( )
  170. local function ok_callback()
  171. self.model:Fire(CSGWarConst.REQ_CSGWAR_SCMD, 60123)
  172. end
  173. local priceText = string.format("<color=%s>%s</color> 彩钻购买", ColorUtil.YELLOW_DARK, self.type1_cost)
  174. local data = {
  175. insufficientText = "",
  176. price = self.type1_cost,
  177. priceText = priceText,
  178. titleText = "提示",
  179. ok_callback = ok_callback,
  180. no_need_toggle = false,
  181. }
  182. if not self.can_buy then
  183. ok_callback()
  184. else
  185. GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, data)
  186. end
  187. end
  188. function CSGWarOverlordView:DestroySuccess( )
  189. if self.money_view then
  190. self.money_view:DeleteMe()
  191. self.money_view = nil
  192. end
  193. end