源战役客户端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

153 righe
5.1 KiB

  1. BeenAttackTips = BeenAttackTips or BaseClass(BaseView)
  2. local BeenAttackTips = BeenAttackTips
  3. function BeenAttackTips:__init()
  4. self.base_file = "common"
  5. self.layout_file = "BeenAttackTips"
  6. self.layer_name = "Main"
  7. self.destroy_imm = true
  8. self.change_scene_close = true
  9. self.append_to_ctl_queue = false --是否要添加进界面堆栈
  10. self.need_show_money = false --是否要显示顶部的金钱栏
  11. self.is_set_zdepth = true
  12. self.click_bg_toClose = false
  13. ------------------------
  14. -- 一级全屏界面:
  15. self.hide_maincancas = false --隐藏主界面
  16. self.use_background = false --不一定显示遮罩
  17. ------------------------
  18. self.show_role_id = 0
  19. self.load_callback = function ()
  20. self:LoadSuccess()
  21. self:AddEvent()
  22. end
  23. self.open_callback = function ( )
  24. self:OpenSuccess()
  25. end
  26. self.close_win_callback = function ( )
  27. self:Close()
  28. end
  29. self.destroy_callback = function ( )
  30. self:DestroySuccess()
  31. end
  32. end
  33. function BeenAttackTips:Open( )
  34. BaseView.Open(self)
  35. end
  36. function BeenAttackTips:LoadSuccess()
  37. local nodes = {
  38. "click/con_head:raw","click/btn_close:obj","click/lb_status:tmp","click/lb_name:tmp","click:obj",
  39. "click/con_vip:obj", "click/lb_lv:tmp",
  40. }
  41. self:GetChildren(nodes)
  42. SetAnchoredPosition( self.transform, 6 - ClientConfig.iphone_x_offset_right, 351 )
  43. self:SetViewShow(false,false)
  44. -- self.head_item = self.head_item or self:CreateItem(HeadRoleItem, self.con_head, self.layer_name)
  45. -- self.head_item:SetItemSize(88,88)
  46. self.vip_item = self.vip_item or self:CreateItem(RoleVipItem, self.con_vip, self.layer_name)
  47. self.lb_status_tmp.text = "(点击反击)"
  48. end
  49. function BeenAttackTips:SetViewShow( role_id, bool )
  50. self.transform.gameObject:SetActive(bool)
  51. GlobalEventSystem:Fire(EventName.BOARDCAST_ATTACK_BACK, role_id, bool and "open" or "close")
  52. end
  53. function BeenAttackTips:AddEvent()
  54. local function call_back( target )
  55. if target == self.btn_close_obj then
  56. self:SetViewShow(false,false)
  57. elseif target == self.click_obj then
  58. local have_select = false
  59. if self.show_role_id and self.show_role_id > 0 then
  60. local temp = Scene:getInstance():GetRole(self.show_role_id)
  61. if temp then
  62. -------------------------
  63. if SceneManager:getInstance():IsCanAttackByMainRole(temp.vo) then
  64. --可攻击的话不需要切换
  65. else
  66. PKStatusModel:getInstance():Fire(PKStatusModel.CHANGE_PK_STATUS, PKStatusModel.Status.Force)
  67. end
  68. -------------------------
  69. Scene.Instance:SetClickTarget(temp)
  70. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
  71. have_select = true
  72. else
  73. Message.show("对方已不在该场景")
  74. end
  75. else
  76. Message.show("请选择一个目标")
  77. end
  78. if not have_select then
  79. self.show_role_id = 0
  80. self:SetViewShow(false,false)
  81. end
  82. end
  83. end
  84. AddClickEvent(self.btn_close_obj,call_back,false)
  85. AddClickEvent(self.click_obj,call_back,false)
  86. local function REFRESH_BEEN_ATTACK_TIPS( role_id )
  87. if not role_id then return end
  88. if role_id > 0 then
  89. self.show_role_id = role_id
  90. self:UpdateView()
  91. end
  92. end
  93. self:BindEvent(GlobalEventSystem, EventName.REFRESH_BEEN_ATTACK_TIPS, REFRESH_BEEN_ATTACK_TIPS)
  94. local function onOrientationChange()
  95. SetAnchoredPosition( self.transform, 6 - ClientConfig.iphone_x_offset_right, 351 )
  96. end
  97. self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
  98. end
  99. function BeenAttackTips:OpenSuccess()
  100. self:UpdateView()
  101. end
  102. function BeenAttackTips:UpdateView()
  103. local role_data = SceneManager.Instance:GetRoleVo( self.show_role_id )
  104. if self.show_role_id > 0 and role_data then
  105. self:SetViewShow(self.show_role_id,true)
  106. -- local head_data = {
  107. -- vo = {id=role_data.role_id,career=role_data.career,level=role_data.level,sex=role_data.sex,turn=role_data.turn,
  108. -- board = role_data.dress_id,picture_ver = role_data.picture_ver,picture = role_data.picture,
  109. -- profile_photo_id = role_data.profile_photo_id, do_not_click = true},
  110. -- }
  111. -- self.head_item:SetData(head_data)
  112. CustomRoleHead:getInstance():Create(self, self.con_head_raw, role_data.role_id, role_data.career, role_data.sex, role_data.turn, nil, role_data.picture_ver, role_data.picture, false, role_data.profile_photo_id)
  113. self.lb_name_tmp.text = role_data.name
  114. self.lb_lv_tmp.text = role_data.level
  115. -------------------------
  116. self.vip_item:SetData(role_data.vip_flag,role_data.sup_vip_type)
  117. local show_vip = role_data.vip_flag > 0
  118. self.vip_item:SetVisible( show_vip )
  119. SetAnchoredPositionX( self.lb_name.transform, show_vip and 38 or 8 )
  120. -------------------------
  121. self.hide_clock = 3
  122. local function hide_call()
  123. self.hide_clock = self.hide_clock - 1
  124. if self.hide_clock < 0 then
  125. self:SetViewShow(false,false)
  126. if self.close_time_id then
  127. GlobalTimerQuest:CancelQuest(self.close_time_id)
  128. self.close_time_id = nil
  129. end
  130. end
  131. end
  132. self.close_time_id = self.close_time_id or GlobalTimerQuest:AddPeriodQuest(hide_call, 1, -1)
  133. else
  134. self:SetViewShow(false,false)
  135. end
  136. end
  137. function BeenAttackTips:DestroySuccess( )
  138. if self.close_time_id then
  139. GlobalTimerQuest:CancelQuest(self.close_time_id)
  140. self.close_time_id = nil
  141. end
  142. GlobalEventSystem:Fire(EventName.BOARDCAST_ATTACK_BACK, false,false)
  143. end