|
|
- BeenAttackTips = BeenAttackTips or BaseClass(BaseView)
- local BeenAttackTips = BeenAttackTips
-
- function BeenAttackTips:__init()
- self.base_file = "common"
- self.layout_file = "BeenAttackTips"
- self.layer_name = "Main"
- self.destroy_imm = true
- self.change_scene_close = true
- self.append_to_ctl_queue = false --是否要添加进界面堆栈
- self.need_show_money = false --是否要显示顶部的金钱栏
- self.is_set_zdepth = true
- self.click_bg_toClose = false
- ------------------------
- -- 一级全屏界面:
- self.hide_maincancas = false --隐藏主界面
- self.use_background = false --不一定显示遮罩
- ------------------------
- self.show_role_id = 0
-
- self.load_callback = function ()
- self:LoadSuccess()
- self:AddEvent()
- end
- self.open_callback = function ( )
- self:OpenSuccess()
- end
- self.close_win_callback = function ( )
- self:Close()
- end
- self.destroy_callback = function ( )
- self:DestroySuccess()
- end
- end
-
- function BeenAttackTips:Open( )
- BaseView.Open(self)
- end
-
- function BeenAttackTips:LoadSuccess()
- local nodes = {
- "click/con_head:raw","click/btn_close:obj","click/lb_status:tmp","click/lb_name:tmp","click:obj",
- "click/con_vip:obj", "click/lb_lv:tmp",
- }
- self:GetChildren(nodes)
- SetAnchoredPosition( self.transform, 6 - ClientConfig.iphone_x_offset_right, 351 )
- self:SetViewShow(false,false)
- -- self.head_item = self.head_item or self:CreateItem(HeadRoleItem, self.con_head, self.layer_name)
- -- self.head_item:SetItemSize(88,88)
- self.vip_item = self.vip_item or self:CreateItem(RoleVipItem, self.con_vip, self.layer_name)
- self.lb_status_tmp.text = "(点击反击)"
- end
-
- function BeenAttackTips:SetViewShow( role_id, bool )
- self.transform.gameObject:SetActive(bool)
- GlobalEventSystem:Fire(EventName.BOARDCAST_ATTACK_BACK, role_id, bool and "open" or "close")
- end
-
- function BeenAttackTips:AddEvent()
- local function call_back( target )
- if target == self.btn_close_obj then
- self:SetViewShow(false,false)
- elseif target == self.click_obj then
- local have_select = false
- if self.show_role_id and self.show_role_id > 0 then
- local temp = Scene:getInstance():GetRole(self.show_role_id)
- if temp then
- -------------------------
- if SceneManager:getInstance():IsCanAttackByMainRole(temp.vo) then
- --可攻击的话不需要切换
- else
- PKStatusModel:getInstance():Fire(PKStatusModel.CHANGE_PK_STATUS, PKStatusModel.Status.Force)
- end
- -------------------------
- Scene.Instance:SetClickTarget(temp)
- GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
- have_select = true
- else
- Message.show("对方已不在该场景")
- end
- else
- Message.show("请选择一个目标")
- end
- if not have_select then
- self.show_role_id = 0
- self:SetViewShow(false,false)
- end
- end
- end
- AddClickEvent(self.btn_close_obj,call_back,false)
- AddClickEvent(self.click_obj,call_back,false)
-
- local function REFRESH_BEEN_ATTACK_TIPS( role_id )
- if not role_id then return end
- if role_id > 0 then
- self.show_role_id = role_id
- self:UpdateView()
- end
- end
- self:BindEvent(GlobalEventSystem, EventName.REFRESH_BEEN_ATTACK_TIPS, REFRESH_BEEN_ATTACK_TIPS)
-
- local function onOrientationChange()
- SetAnchoredPosition( self.transform, 6 - ClientConfig.iphone_x_offset_right, 351 )
- end
- self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
- end
-
- function BeenAttackTips:OpenSuccess()
- self:UpdateView()
- end
-
- function BeenAttackTips:UpdateView()
- local role_data = SceneManager.Instance:GetRoleVo( self.show_role_id )
- if self.show_role_id > 0 and role_data then
- self:SetViewShow(self.show_role_id,true)
- -- local head_data = {
- -- vo = {id=role_data.role_id,career=role_data.career,level=role_data.level,sex=role_data.sex,turn=role_data.turn,
- -- board = role_data.dress_id,picture_ver = role_data.picture_ver,picture = role_data.picture,
- -- profile_photo_id = role_data.profile_photo_id, do_not_click = true},
- -- }
- -- self.head_item:SetData(head_data)
- 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)
- self.lb_name_tmp.text = role_data.name
- self.lb_lv_tmp.text = role_data.level
- -------------------------
- self.vip_item:SetData(role_data.vip_flag,role_data.sup_vip_type)
- local show_vip = role_data.vip_flag > 0
- self.vip_item:SetVisible( show_vip )
- SetAnchoredPositionX( self.lb_name.transform, show_vip and 38 or 8 )
- -------------------------
- self.hide_clock = 3
- local function hide_call()
- self.hide_clock = self.hide_clock - 1
- if self.hide_clock < 0 then
- self:SetViewShow(false,false)
- if self.close_time_id then
- GlobalTimerQuest:CancelQuest(self.close_time_id)
- self.close_time_id = nil
- end
- end
- end
- self.close_time_id = self.close_time_id or GlobalTimerQuest:AddPeriodQuest(hide_call, 1, -1)
- else
- self:SetViewShow(false,false)
- end
- end
-
- function BeenAttackTips:DestroySuccess( )
- if self.close_time_id then
- GlobalTimerQuest:CancelQuest(self.close_time_id)
- self.close_time_id = nil
- end
- GlobalEventSystem:Fire(EventName.BOARDCAST_ATTACK_BACK, false,false)
- end
|