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

158 lines
5.2 KiB

  1. --社团协助前往确认界面
  2. GuildSupportGoView = GuildSupportGoView or BaseClass(BaseView)
  3. local GuildSupportGoView = GuildSupportGoView
  4. function GuildSupportGoView:__init()
  5. self.base_file = "guild"
  6. self.layout_file = "GuildSupportGoView"
  7. self.layer_name = "Top"
  8. self.destroy_imm = true
  9. self.use_background = true
  10. self.hide_maincancas = false --全屏界面需要放开隐藏主UI
  11. self.change_scene_close = true
  12. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  13. self.need_show_money = false --是否要显示顶部的金钱栏
  14. self.blur_activity_bg = true
  15. self.model = GuildModel:getInstance()
  16. self.item_list = {}
  17. self.load_callback = function ()
  18. self:LoadSuccess()
  19. self:AddEvent()
  20. end
  21. self.open_callback = function ( )
  22. self:OpenSuccess()
  23. end
  24. self.destroy_callback = function ( )
  25. self:DestroySuccess()
  26. end
  27. end
  28. function GuildSupportGoView:DestroySuccess()
  29. for k, v in pairs(self.item_list) do
  30. v:DeleteMe()
  31. v = nil
  32. end
  33. self.item_list = {}
  34. end
  35. function GuildSupportGoView:LoadSuccess()
  36. local nodes = {
  37. "btnOK:obj","Window/windowCloseBtn:obj","award_con","btnCancel:obj",
  38. "bg:img","pass_name:tmp","name:tmp","Window:raw","Window/windowTitleCon/windowTitleText:tmp",
  39. }
  40. self:GetChildren(nodes)
  41. lua_resM:setOutsideRawImage(self, self.Window_raw, GameResPath.GetViewBigBg("tips_comm_bg6"), false)
  42. lua_resM:setOutsideImageSprite(self, self.bg_img, GameResPath.GetGuildImage("guild_support_go_bg"), false)
  43. self.windowTitleText_tmp.text = "协助提示"
  44. if self.need_refreshData then
  45. self:UpdateView( )
  46. end
  47. end
  48. function GuildSupportGoView:AddEvent()
  49. local function onBtnClickHandler(target,x,y)
  50. if target == self.windowCloseBtn_obj then--关闭
  51. self:Close()
  52. elseif target == self.btnCancel_obj then--关闭
  53. self:Close()
  54. elseif target == self.btnOK_obj then--立即前往
  55. if self.data and self.data.role_id ~= RoleManager.Instance.mainRoleInfo.role_id and self.cfg then
  56. if self.cfg.is_conflict ~= 1 then--可以接着协助其他人
  57. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40052,self.data.support_sid)
  58. else
  59. if self.model:GetGuildSupportStatus() == 1 then--请求他人协助
  60. Message.show("您已经请求协助,不可协助其他玩家")
  61. return
  62. elseif self.model:GetGuildSupportStatus() == 2 then--正在协助他人
  63. Message.show("您正在协助中")
  64. return
  65. elseif self.model:GetGuildSupportStatus() == 0 then
  66. self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40052,self.data.support_sid)
  67. end
  68. end
  69. end
  70. self:Close()
  71. end
  72. end
  73. AddClickEvent(self.windowCloseBtn_obj,onBtnClickHandler, LuaSoundManager.SOUND_UI.NONE)
  74. AddClickEvent(self.btnOK_obj,onBtnClickHandler, LuaSoundManager.SOUND_UI.NONE)
  75. AddClickEvent(self.btnCancel_obj,onBtnClickHandler, LuaSoundManager.SOUND_UI.NONE)
  76. end
  77. function GuildSupportGoView:Open( data )
  78. self.data = data
  79. BaseView.Open(self)
  80. end
  81. function GuildSupportGoView:OpenSuccess( )
  82. self:UpdateView()
  83. end
  84. function GuildSupportGoView:UpdateView( )
  85. if self.is_loaded then
  86. self.need_refreshData = false
  87. else
  88. self.need_refreshData = true
  89. return
  90. end
  91. if not self.data then return end
  92. --Boss形象
  93. local boss_type = BossModel:GetInstance():GetBossTypeByBossId( self.data.boss_id )
  94. local monster = ConfigItemMgr.Instance:GetMonsterDataItem(self.data.boss_id)
  95. local boss_type_name = self.model:GetSupportTypeName(boss_type) or ""
  96. local support_text = GuildModel.SupportTypeStr[self.data.support_cfg_id] or "协助击杀"
  97. self.name_tmp.text = "前往协助社团成员:"..HtmlColorTxt(self.data.name, "#d322ff")
  98. if self.data.support_cfg_id == GuildSupportInfoItem.CFG_TYPE.ANSWER or
  99. self.data.support_cfg_id == GuildSupportInfoItem.CFG_TYPE.GUILD_BOSS then
  100. local cfg = self.model:GetGuildSupportCfg(self.data.support_cfg_id)
  101. if cfg then
  102. self.pass_name_tmp.text = string.format("协助完成%s协助任务可获得协助奖励", HtmlColorTxt(Trim(cfg.mod_name), "#d322ff"))
  103. end
  104. else
  105. self.pass_name_tmp.text = string.format("%s%s可获得协助奖励", support_text, HtmlColorTxt(boss_type_name, "#d322ff"))
  106. end
  107. self:UpdateItemList()
  108. end
  109. function GuildSupportGoView:BtnCloseEvt()--关闭按钮回调
  110. self:Close()
  111. end
  112. function GuildSupportGoView:UpdateItemList( )
  113. local cfg = self.model:GetGuildSupportCfg(self.data.support_cfg_id)
  114. if not cfg then return end
  115. self.cfg = cfg
  116. for k,v in pairs(self.item_list) do
  117. v:SetVisible(false)
  118. end
  119. local item_list = {{0,100003,cfg.reward_reputation}}
  120. if not item_list or TableSize(item_list) == 0 then return end
  121. local offer_x = 0
  122. local offer_y = 0
  123. local x = 0
  124. local y = 0
  125. for i, v in ipairs(item_list) do
  126. local item = self.item_list[i]
  127. if item == nil then
  128. item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem,self.award_con)
  129. item:SetItemSize(62,62)
  130. self.item_list[i] = item
  131. end
  132. -- y = offer_y
  133. -- x = (78+offer_x) * (i-1)
  134. -- item:SetPosition(x,y)
  135. local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(v[1], v[2])
  136. local goodVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_Id)
  137. if goodVo then
  138. item:SetData(goods_Id, v[3] , goodVo.color, 0, lock,true,nil)
  139. else
  140. -- error("没有找到物品信息 "..v.typeId)
  141. end
  142. item:SetVisible(true)
  143. end
  144. end