-- <*
|
|
-- @Author: Saber
|
|
-- @Description: 跨服社团排行玩法场景界面
|
|
-- *>
|
|
GuildCSGRSceneView = GuildCSGRSceneView or BaseClass(BaseView)
|
|
local GuildCSGRSceneView = GuildCSGRSceneView
|
|
|
|
function GuildCSGRSceneView:__init()
|
|
self.base_file = "guildCSGR"
|
|
self.layout_file = "GuildCSGRSceneView"
|
|
self.layer_name = "Main"
|
|
self.destroy_imm = true
|
|
self.use_background = false --全屏界面默认使用这个参数,非全屏界面自行设置
|
|
self.change_scene_close = false --是否切换场景时关闭(弹出界面使用)
|
|
self:AddPreLoadList("guildCSGR", {"GuildCSGRSceneRankItem"})
|
|
self.init_exit_btn = false
|
|
self.trigger_collect_guide = false -- 是否触发了采集引导
|
|
self.tab_index = 1 -- 选项卡index
|
|
self.auto_switch_tab = {} -- 记录强制切换过页签
|
|
self.collect_cfg_data = nil -- 战场采集物配置信息
|
|
self.boss_position = nil -- 战场boss坐标
|
|
self.info_list = {} -- 右侧信息节点
|
|
self.had_show_collect_dialogue = false -- 是否已经显示了左侧采集对话小窗
|
|
self.had_show_assult_dialogue = false -- 是否已经显示了左侧围攻对话小窗
|
|
self.had_show_boss_alert = false -- 是否弹出过boss预警
|
|
self.info_rank_item = {} -- 右侧信息节点中的排行节点
|
|
self.rank_data = {} -- 服务端推送的排行信息
|
|
self.extra_con_type = 1 -- 额外信息内容类型 1:采集物 2:排行榜
|
|
self.rightIcon_tween = {} -- 右上角动画列表
|
|
-- 采集阶段参数
|
|
self.auto_collect = false -- 第二阶段中是否自动采集
|
|
|
|
self.model = GuildModel:getInstance()
|
|
self.scene = Scene.Instance
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
-- 请求采集相关信息
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41003)
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41004)
|
|
-- 请求排行相关信息
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41006)
|
|
end
|
|
self.open_callback = function ( )
|
|
self:UpdateView()
|
|
self:ShowInfoCon(not MainUIModel:getInstance():GetDialogueActionFlag(), true)
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function GuildCSGRSceneView:Open( )
|
|
--self.data = data
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function GuildCSGRSceneView:LoadSuccess()
|
|
local nodes = {
|
|
"con:img:cg",
|
|
"rank_btn:obj",
|
|
-- 最右侧信息节点
|
|
-- 选项卡
|
|
"con/tab_con/tab_selected:obj:img",
|
|
"con/tab_con/tab_1_lb:obj:tmp",
|
|
"con/tab_con/tab_2_lb:obj:tmp",
|
|
-- 采集相关
|
|
-- "con/collect_scroll:obj",
|
|
-- "con/collect_scroll/Viewport/collect_con",
|
|
"con/collect_con:obj",
|
|
"con/collect_con/collect_tip:tmp",
|
|
"con/collect_con/collect_effect_con",
|
|
-- 排行相关
|
|
"con/rank_con:obj",
|
|
"con/rank_con/boss_click:obj",
|
|
"con/rank_con/boss_hp:img",
|
|
"con/rank_con/r_item_node",
|
|
"con/rank_con/r_my_rank:tmp",
|
|
"con/rank_con/boss_name:tmp",
|
|
"con/rank_con/boss_hp_pec:tmp",
|
|
"con/rank_con/other_data_click_tip:obj",
|
|
-- 额外信息节点
|
|
"con/other_con:obj",
|
|
"con/other_con/close_btn:obj", -- 额外信息节点关闭按钮
|
|
"con/other_con/buff_con",
|
|
"con/other_con/other_desc:tmp",
|
|
-- 活动结束时间
|
|
"con/event_time:tmp",
|
|
-- 功能按钮
|
|
"func_btn_con",
|
|
"func_btn_con/func_btn_collect:obj:img",
|
|
"func_btn_con/func_btn_call:obj",
|
|
"func_btn_con/func_btn_assult:obj",
|
|
"func_btn_con/func_btn_collect/func_btn_collect_lb:tmp",
|
|
"func_btn_con/func_btn_call/func_btn_call_lb:tmp",
|
|
"func_btn_con/func_btn_assult/func_btn_assult_lb:tmp",
|
|
}
|
|
self:GetChildren(nodes)
|
|
lua_resM:setOutsideImageSprite(self, self.con_img, GameResPath.GetViewBigBg("common_right_top_img2"))
|
|
-- 绑定到退出按钮应该有的位置上去
|
|
GlobalEventSystem:Fire(EventName.MOVE_NODE_EXIT_CON, self.rank_btn, self.transform, "rank_btn", 1)
|
|
-- 提前设置一次文本
|
|
self.func_btn_collect_lb_tmp.text = "采集物资"
|
|
self.func_btn_call_lb_tmp.text = "召唤社员"
|
|
self.func_btn_assult_lb_tmp.text = "进攻图腾"
|
|
-- 设置界面大小和位置
|
|
SetSizeDelta(self.transform, 0, 0)
|
|
-- 设置刘海屏offset
|
|
if ClientConfig.iphone_x_model then
|
|
-- self.transform.offsetMin = Vector2(ClientConfig.iphone_x_offset_left,0)
|
|
-- self.transform.offsetMax = Vector2(-ClientConfig.iphone_x_offset_right,0)
|
|
end
|
|
-- 隐藏额外信息界面
|
|
self.other_con_obj:SetActive(false)
|
|
if not self.init_exit_btn then
|
|
self.init_exit_btn = true
|
|
local function call_back( ... )
|
|
local function ok( ... )
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41002, 1)
|
|
end
|
|
local ask_str = "是否确定退出当前场景?"
|
|
Alert.show(ask_str,Alert.Type.Two,ok,nil,"确定","取消")
|
|
end
|
|
local data = {call_back = call_back, pos = {x = 202, y = 277}} -- pos 为左侧侧边栏的长度
|
|
GlobalEventSystem:Fire(EventName.SHOW_EXIT_BTN_STATE, data)
|
|
end
|
|
-- 添加采集引导
|
|
GuideController.Instance:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE, 410000000)
|
|
end
|
|
|
|
function GuildCSGRSceneView:AddEvent()
|
|
local function click_event(target)
|
|
if target == self.tab_1_lb_obj then -- 选项卡1
|
|
self:SwitchCSGRDataTab(1)
|
|
elseif target == self.tab_2_lb_obj then -- 选项卡2
|
|
self:SwitchCSGRDataTab(2)
|
|
elseif target == self.rank_btn_obj then -- 排行榜按钮
|
|
self.model:Fire(GuildModel.OPEN_CSGR_RANK_VIEW, true)
|
|
elseif target == self.close_btn_obj then -- 关闭额外信息界面
|
|
self.other_con_obj:SetActive(false)
|
|
elseif target == self.boss_click_obj or target == self.func_btn_assult_obj then -- 阶段2要前往boss
|
|
self:CSGRFindWayToBoss()
|
|
elseif target == self.func_btn_collect_obj then
|
|
self:OnCollectBtnClick(not self.auto_collect)
|
|
elseif target == self.func_btn_call_obj then -- 呼叫社团成员
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 40064, 410)
|
|
elseif target == self.other_data_click_tip_obj then -- 弹出额外信息小窗
|
|
self.other_con_obj:SetActive(true)
|
|
end
|
|
end
|
|
AddClickEvent(self.tab_1_lb_obj, click_event)
|
|
AddClickEvent(self.tab_2_lb_obj, click_event)
|
|
AddClickEvent(self.rank_btn_obj, click_event)
|
|
AddClickEvent(self.close_btn_obj, click_event)
|
|
AddClickEvent(self.boss_click_obj, click_event)
|
|
AddClickEvent(self.func_btn_assult_obj, click_event)
|
|
AddClickEvent(self.func_btn_collect_obj, click_event)
|
|
AddClickEvent(self.func_btn_call_obj, click_event)
|
|
AddClickEvent(self.other_data_click_tip_obj, click_event)
|
|
|
|
-- local function onOrientationChange()
|
|
-- if self.transform then
|
|
-- if ClientConfig.iphone_x_model then
|
|
-- -- self.transform.offsetMin = Vector2(ClientConfig.iphone_x_offset_left,0)
|
|
-- -- self.transform.offsetMax = Vector2(-ClientConfig.iphone_x_offset_right,0)
|
|
-- end
|
|
-- end
|
|
-- end
|
|
-- self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)--位置适配
|
|
|
|
local function hide_dialogue_cur_xy_node()--隐藏当前和对话框重叠位置的节点
|
|
self:ShowInfoCon(false)
|
|
end
|
|
local function show_dialogue_cur_xy_node()--显示当前和对话框重叠位置的节点
|
|
self:ShowInfoCon(true)
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.START_COM_DIALOGUE_SHOW_ANIM, hide_dialogue_cur_xy_node)
|
|
self:BindEvent(GlobalEventSystem, EventName.FINISHED_COM_DIALOGUE_SHOW_ANIM, show_dialogue_cur_xy_node)
|
|
|
|
-- 活动跨阶段更新
|
|
local function update_event_data(event_type)
|
|
if not event_type or event_type == GuildEventType.GuildCSGR then
|
|
self.event_data = self.model:GetGuildEventByType(GuildEventType.GuildCSGR)
|
|
self:UpdateInfoShowCon()
|
|
self:UpdateEventCountdown()
|
|
end
|
|
end
|
|
self:BindEvent(self.model, GuildModel.UPDATE_GUILD_EVENT_BY_TYPE, update_event_data)
|
|
|
|
-- 更新采集数据
|
|
local function update_collect_buff()
|
|
self:UpdateCSGRStatusTips()
|
|
end
|
|
self:BindEvent(self.model, GuildModel.UPDATE_CSGR_BF_RES, update_collect_buff)
|
|
|
|
-- 更新排行数据
|
|
local function update_rank_data(vo)
|
|
self.rank_data = vo
|
|
-- 先更新最右侧的展示内容
|
|
self:UpdateRankItem()
|
|
end
|
|
self:BindEvent(self.model, GuildModel.UPDATE_CSGR_SCENE_DMG_RANK, update_rank_data)
|
|
|
|
local function update_boss_hp(monsterHp, maxHp, percentage)
|
|
self:UpdateBossHp(monsterHp, maxHp, percentage)
|
|
end
|
|
self:BindEvent(self.model, GuildModel.UPDATE_CSGR_BOSS_HP, update_boss_hp)
|
|
|
|
-- 绑定界面移动动画
|
|
self:BindLittleMove(self.con, BaseView.LittleMoveDir.Left, 1.5)
|
|
self:BindLittleMove(self.func_btn_con, BaseView.LittleMoveDir.Bottom, 147.5)
|
|
|
|
-- 主界面聊天展开事件
|
|
self:BindMainUIExpandEvent( self.func_btn_con )
|
|
end
|
|
|
|
function GuildCSGRSceneView:UpdateView()
|
|
self.event_data = self.model:GetGuildEventByType(GuildEventType.GuildCSGR)
|
|
self:UpdateBasicData()
|
|
-- 默认切换到页签1
|
|
self:SwitchCSGRDataTab(1)
|
|
-- 更新排行信息
|
|
self:UpdateRankItem()
|
|
-- 修改展示的内容
|
|
self:UpdateInfoShowCon()
|
|
-- 加载活动倒计时
|
|
self:UpdateEventCountdown()
|
|
-- 更新采集物信息
|
|
self:UpdateCollectionItem()
|
|
end
|
|
|
|
-- 加载一些基础信息
|
|
function GuildCSGRSceneView:UpdateBasicData( )
|
|
self.collect_tip_tmp.text = "采集物资,提升社团整体增益"
|
|
self.other_desc_tmp.text = "进攻图腾,社团伤害排名越高,奖励越好"
|
|
local mon_id = Config.Campwarkv["boss_id"].val
|
|
self.boss_name_tmp.text = Trim(ConfigItemMgr.Instance:GetMonsterDataItem(mon_id).name)
|
|
end
|
|
|
|
-- 切换页签表现
|
|
function GuildCSGRSceneView:SwitchCSGRDataTab(tab_index)
|
|
self.tab_index = tab_index
|
|
self.tab_1_lb_tmp.color = ColorUtil:ConvertHexToRGBColor(self.tab_index == 1 and "FFFFFF" or "9EB3CF")
|
|
self.tab_2_lb_tmp.color = ColorUtil:ConvertHexToRGBColor(self.tab_index == 2 and "FFFFFF" or "9EB3CF")
|
|
SetAnchoredPosition(self.tab_selected, self.tab_index == 1 and -49 or 49, 0)
|
|
self.collect_con_obj:SetActive(self.tab_index == 1)
|
|
self.rank_con_obj:SetActive(self.tab_index == 2)
|
|
end
|
|
|
|
-- 更新顶部横幅
|
|
function GuildCSGRSceneView:UpdateCSGRStatusTips( )
|
|
if self.event_data then
|
|
-- 确定阶段
|
|
local is_waiting = self.event_data.status == 1
|
|
local is_collecting = self.event_data.status == 2
|
|
local is_assulting = self.event_data.status == 3
|
|
-- 更新横幅
|
|
if is_waiting then -- 候场阶段
|
|
local show_time = self.event_data.next_time - TimeUtil:getServerTime()
|
|
local str = "备战入场时间 %s"
|
|
local special_tip_data = {
|
|
type = SpecialTipType.Timer2,
|
|
sepeical_str = str,
|
|
need_flash = false,
|
|
show_time = show_time > 0 and show_time or 0,
|
|
belong_key = "guildCSGR",
|
|
}
|
|
CommonController.Instance:Fire(EventName.OPEN_SPECIALTIPVIEW, special_tip_data)
|
|
elseif is_collecting then -- 采集阶段
|
|
local next_time = self.model:GetCSGRBattlefieldResRefreshTime()
|
|
local str = next_time and next_time ~= 0
|
|
and "下一批物资刷新%s"
|
|
or "物资采集阶段剩余%s"
|
|
-- 如果存在next_time不等于0的情况则代表还有下一轮的刷新,否则横幅调整为采集阶段的剩余时间
|
|
local stage_end_time = next_time and next_time ~= 0 and next_time or self.event_data.next_time
|
|
local special_tip_show_time = next_time and next_time ~= 0 and 10 or 30
|
|
local function delay_special_tip_func()
|
|
local left_time = stage_end_time - TimeUtil:getServerTime()
|
|
if left_time <= special_tip_show_time then -- 倒计时剩下n秒才弹出采集刷新横幅 或 采集阶段刷新横幅
|
|
local special_tip_data = {
|
|
type = SpecialTipType.Timer2,
|
|
sepeical_str = str,
|
|
need_flash = false,
|
|
show_time = left_time,
|
|
belong_key = "guildCSGR",
|
|
}
|
|
CommonController.Instance:Fire(EventName.OPEN_SPECIALTIPVIEW, special_tip_data)
|
|
self:ClearDelaySpecialTipId()
|
|
end
|
|
end
|
|
self:ClearDelaySpecialTipId()
|
|
self.delay_special_tip_id = GlobalTimerQuest:AddPeriodQuest(delay_special_tip_func, 0.2, -1)
|
|
-- 采集引导
|
|
if not self.trigger_collect_guide then
|
|
self:AddGuideToCollectBtn()
|
|
self.trigger_collect_guide = true
|
|
end
|
|
-- 左侧对话tips
|
|
if not self.had_show_collect_dialogue then
|
|
local dialogue_data = {
|
|
head_type = 1000 + RoleManager.Instance.mainRoleInfo.career,
|
|
desc = "物资采集开始了!采集的越多,社团增益越强!",
|
|
head_name = "战场指挥官",
|
|
hide_time = 5,
|
|
dalay_time = 0.1,
|
|
is_task_type = false,
|
|
}
|
|
GlobalEventSystem:Fire(EventName.SHOW_COM_DIALOGUE_SHOW_VIEW, dialogue_data)
|
|
self.had_show_collect_dialogue = true
|
|
end
|
|
elseif is_assulting then
|
|
-- 左侧对话tips
|
|
if not self.had_show_assult_dialogue then
|
|
local dialogue_data = {
|
|
head_type = 1000 + RoleManager.Instance.mainRoleInfo.career,
|
|
desc = "图腾降临了!对图腾伤害越高奖励越丰富!",
|
|
head_name = "战场指挥官",
|
|
hide_time = 5,
|
|
dalay_time = 0.1,
|
|
is_task_type = false,
|
|
}
|
|
GlobalEventSystem:Fire(EventName.SHOW_COM_DIALOGUE_SHOW_VIEW, dialogue_data)
|
|
self.had_show_assult_dialogue = true
|
|
end
|
|
if not self.had_show_boss_alert then
|
|
CommonController.Instance:Fire(EventName.OPEN_BOSS_ALERT_VIEW, true, 41000)
|
|
self.had_show_boss_alert = true
|
|
end
|
|
if self.show_delay_id then
|
|
GlobalTimerQuest:CancelQuest(self.show_delay_id)
|
|
self.show_delay_id = nil
|
|
end
|
|
if self.auto_delete_delay_id then
|
|
self:DeleteGuideToCollectBtn()
|
|
end
|
|
local function delay_exit_tip_func()
|
|
local left_time = self.event_data.next_time - TimeUtil:getServerTime()
|
|
-- if left_time <= 15 then -- 倒计时剩下15秒弹出退出场景
|
|
if left_time <= 0 then -- 活动结束后,倒计时自动退出场景
|
|
local exit_tips_data = {
|
|
time = 15,
|
|
time_str = "秒后",
|
|
exit_desc = "自动退出战场",
|
|
call_back = function()
|
|
if SceneManager:getInstance():IsGuildCSGRScene() then
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT, 41002, 1)
|
|
end
|
|
end,
|
|
}
|
|
GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP, exit_tips_data)
|
|
self:ClearDelayExitTipId()
|
|
end
|
|
end
|
|
self:ClearDelayExitTipId()
|
|
self.delay_exit_tip_id = GlobalTimerQuest:AddPeriodQuest(delay_exit_tip_func, 0.2, -1)
|
|
delay_exit_tip_func()
|
|
else
|
|
CommonController.Instance:Fire(EventName.CLOSE_SPECIALTIPVIEW)
|
|
end
|
|
end
|
|
end
|
|
function GuildCSGRSceneView:ClearDelaySpecialTipId( )
|
|
if self.delay_special_tip_id then
|
|
GlobalTimerQuest:CancelQuest(self.delay_special_tip_id)
|
|
self.delay_special_tip_id = nil
|
|
end
|
|
end
|
|
function GuildCSGRSceneView:ClearDelayExitTipId( )
|
|
if self.delay_exit_tip_id then
|
|
GlobalTimerQuest:CancelQuest(self.delay_exit_tip_id)
|
|
self.delay_exit_tip_id = nil
|
|
end
|
|
end
|
|
-- 更新排行信息
|
|
function GuildCSGRSceneView:UpdateRankItem( )
|
|
local data, item
|
|
local empty_tb = {is_empty = true}
|
|
-- 加载前3的伤害排行
|
|
for i = 1, 3 do
|
|
-- 计算输出百分比需要跟第一名进行输出总量对比,所以每条列表数据都需要加上第一名的输出
|
|
item = self.info_rank_item[i]
|
|
if not item then
|
|
item = GuildCSGRSceneRankItem.New(self.r_item_node)
|
|
self.info_rank_item[i] = item
|
|
end
|
|
data = self.rank_data and self.rank_data.hurt_rank and self.rank_data.hurt_rank[i] or empty_tb,
|
|
item:SetAnchoredPosition(0, (1-i) * 28.5 - 2.5)
|
|
item:SetData(data, i)
|
|
end
|
|
-- 加载自己社团的排行
|
|
self.r_my_rank_tmp.text = self.rank_data.my_guild_rank and self.rank_data.my_guild_rank ~= 0
|
|
and string.format("我的社团:<color=%s>第%s名</color>", ColorUtil.GREEN_DARK, self.rank_data.my_guild_rank)
|
|
or string.format("我的社团:<color=%s>未上榜</color>", ColorUtil.RED_DARK)
|
|
end
|
|
|
|
-- 根据当前的活动阶段调整展示右侧信息节点
|
|
function GuildCSGRSceneView:UpdateInfoShowCon( )
|
|
if self.event_data then
|
|
-- 确定阶段
|
|
local is_waiting = self.event_data.status == 1
|
|
local is_collecting = self.event_data.status == 2
|
|
local is_assulting = self.event_data.status == 3
|
|
if not is_waiting and not is_collecting and not is_assulting then return end
|
|
-- 显示或隐藏功能按钮
|
|
self.func_btn_call_obj:SetActive(true) -- 召唤社员默认显示
|
|
self.func_btn_collect_obj:SetActive(not is_assulting)
|
|
self.func_btn_assult_obj:SetActive(is_assulting)
|
|
self:SortFuncBtnPosition()
|
|
if is_collecting then
|
|
if not self.auto_switch_tab[1] then
|
|
self:SwitchCSGRDataTab(1)
|
|
self.auto_switch_tab[1] = true
|
|
end
|
|
self:OnCollectBtnClick(true)
|
|
end
|
|
if is_assulting then
|
|
if not self.auto_switch_tab[2] then
|
|
self:SwitchCSGRDataTab(2)
|
|
self.auto_switch_tab[2] = true
|
|
end
|
|
GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT) -- 进入围攻阶段就打开自动战斗
|
|
self:UpdateBossHp(self.model:GetCSGRCurBossHp())
|
|
end
|
|
-- 围攻首领阶段才弹出排行按钮
|
|
self.rank_btn_obj:SetActive(is_assulting)
|
|
-- 更新界面顶部横幅内容
|
|
self:UpdateCSGRStatusTips()
|
|
end
|
|
end
|
|
|
|
-- 更新活动剩余倒计时
|
|
function GuildCSGRSceneView:UpdateEventCountdown( )
|
|
if self.event_data then
|
|
local left_time
|
|
local is_collecting = self.event_data.status == 2
|
|
local is_assulting = self.event_data.status == 3
|
|
-- 除了最终阶段,其他阶段都使用next_time作为阶段的倒计时
|
|
local end_time = is_assulting and self.event_data.end_time or self.event_data.next_time
|
|
local function countdown_func()
|
|
left_time = end_time - TimeUtil:getServerTime()
|
|
left_time = left_time > 0 and left_time or 0
|
|
self.event_time_tmp.text = string.format("%s剩余时间:<color=%s>%s</color>",
|
|
is_collecting and "采集" or "进攻",
|
|
ColorUtil.GREEN_DARK, TimeUtil:convertTimeWithoutHour(left_time))
|
|
if left_time <= 0 then
|
|
self:ClearCountdownFuncId()
|
|
end
|
|
end
|
|
self:ClearCountdownFuncId()
|
|
self.countdown_func_id = GlobalTimerQuest:AddPeriodQuest(countdown_func, 0.5, -1)
|
|
end
|
|
end
|
|
function GuildCSGRSceneView:ClearCountdownFuncId( )
|
|
if self.countdown_func_id then
|
|
GlobalTimerQuest:CancelQuest(self.countdown_func_id)
|
|
self.countdown_func_id = nil
|
|
end
|
|
end
|
|
|
|
-- 更新采集物信息
|
|
function GuildCSGRSceneView:UpdateCollectionItem( )
|
|
self.collect_cfg_data = self.model:GetCSGRCollectCfg()
|
|
-- 右侧信息采集节点的采集物item节点
|
|
self.collection_item_creator = self.collection_item_creator or self:AddUIComponent(UI.ItemListCreator)
|
|
local info = {
|
|
data_list = self.collect_cfg_data,
|
|
item_con = self.collect_effect_con,
|
|
scroll_view = self.collect_effect_con,
|
|
item_class = GuildCSGRSceneCollectionItem,
|
|
item_height = 31,
|
|
create_frequency = 0.01,
|
|
alignment = UnityEngine.TextAnchor.UpperLeft,
|
|
on_update_item = function(item, i, v)
|
|
item:SetData(v, true)
|
|
end,
|
|
}
|
|
self.collection_item_creator:UpdateItems(info)
|
|
-- 额外信息的buff展示item
|
|
self.buff_item_creator = self.buff_item_creator or self:AddUIComponent(UI.ItemListCreator)
|
|
local info = {
|
|
data_list = self.collect_cfg_data,
|
|
item_con = self.buff_con,
|
|
scroll_view = self.buff_con,
|
|
item_class = GuildCSGRSceneCollectionItem,
|
|
item_height = 31,
|
|
create_frequency = 0.01,
|
|
alignment = UnityEngine.TextAnchor.UpperLeft,
|
|
on_update_item = function(item, i, v)
|
|
item:SetData(v, false)
|
|
end,
|
|
}
|
|
self.buff_item_creator:UpdateItems(info)
|
|
end
|
|
|
|
-- 自动寻路前往boss坐标并自动挂机
|
|
function GuildCSGRSceneView:CSGRFindWayToBoss( )
|
|
if self.event_data and self.event_data.status == 3 then
|
|
self.boss_position = self.boss_position or stringtotable(Config.Campwarkv["boss_position"].val)[1]
|
|
if self.boss_position then
|
|
local function call_back()
|
|
GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
|
|
end
|
|
local findVo = FindVo.New()
|
|
findVo.type = FindVo.POINT
|
|
findVo.x = self.boss_position[1] / SceneObj.LogicRealRatio.x
|
|
findVo.y = self.boss_position[2] / SceneObj.LogicRealRatio.y
|
|
findVo.sceneId = SceneManager:getInstance():GetSceneId()
|
|
findVo.call_back = call_back
|
|
GlobalEventSystem:Fire(EventName.FIND, findVo)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 更新boss血量信息
|
|
function GuildCSGRSceneView:UpdateBossHp(monsterHp, maxHp, percentage)
|
|
self.boss_hp_img.fillAmount = percentage
|
|
self.boss_hp_pec_tmp.text = string.format("%.1f%%", percentage * 100)
|
|
end
|
|
|
|
function GuildCSGRSceneView:SortFuncBtnPosition( )
|
|
local btn_list = {}
|
|
if self.func_btn_assult_obj.activeSelf then
|
|
btn_list[#btn_list + 1] = self.func_btn_assult
|
|
end
|
|
if self.func_btn_collect_obj.activeSelf then
|
|
btn_list[#btn_list + 1] = self.func_btn_collect
|
|
end
|
|
if self.func_btn_call_obj.activeSelf then
|
|
btn_list[#btn_list + 1] = self.func_btn_call
|
|
end
|
|
for i, v in ipairs(btn_list) do
|
|
SetAnchoredPosition(v, (i-#btn_list/2)* 120 - 60, 5.5 + 4)
|
|
end
|
|
end
|
|
|
|
function GuildCSGRSceneView:AddGuideToCollectBtn()
|
|
local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.GUILD_CSGR_COLLECT, 1)
|
|
if not helpVo then return end
|
|
local help_type = helpVo.help_type
|
|
local step = helpVo.step
|
|
local button = self.func_btn_collect_obj
|
|
if not button then return end
|
|
local function call_back()
|
|
|
|
end
|
|
-- 延时打开,防止按钮在动画中没有定对位置
|
|
local function delay_show( )
|
|
GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, self.transform, call_back, helpVo, self.layout_file)
|
|
-- 自动销毁
|
|
if not self.auto_delete_delay_id then
|
|
local function delay_delete( )
|
|
self:DeleteGuideToCollectBtn()
|
|
end
|
|
self.auto_delete_delay_id = setTimeout(delay_delete, 5)
|
|
end
|
|
end
|
|
if not self.show_delay_id then
|
|
self.show_delay_id = setTimeout(delay_show, 1.5)
|
|
end
|
|
end
|
|
|
|
function GuildCSGRSceneView:DeleteGuideToCollectBtn( )
|
|
-- 销毁引导表现
|
|
local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.GUILD_CSGR_COLLECT, 1)
|
|
if helpVo then
|
|
if helpVo.step == 1 then
|
|
GlobalEventSystem:Fire(EventName.CLOSE_GUIDE_PROMPT_VIEW)
|
|
end
|
|
end
|
|
if self.auto_delete_delay_id then
|
|
GlobalTimerQuest:CancelQuest(self.auto_delete_delay_id)
|
|
self.auto_delete_delay_id = nil
|
|
end
|
|
end
|
|
|
|
function GuildCSGRSceneView:OnCollectBtnClick(auto_collect)
|
|
self:DeleteGuideToCollectBtn()
|
|
if self.event_data and self.event_data.status == 2 and self.collect_cfg_data then
|
|
self.auto_collect = auto_collect
|
|
self.func_btn_collect_lb_tmp.text = self.auto_collect and "采集物资中..." or "采集物资"
|
|
self.model:UpdateCSGRAutoCollectFlag(self.auto_collect)
|
|
end
|
|
end
|
|
|
|
function GuildCSGRSceneView:ShowInfoCon(show, force)
|
|
local target_alpha = show and 1 or 0
|
|
if force then
|
|
self.con_cg.alpha = target_alpha
|
|
else
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.con)
|
|
local function action_alpha_callback(percent)
|
|
self.con_cg.alpha = show and percent or (1 - percent)
|
|
end
|
|
local action_alpha = cc.CustomUpdate.New(0.3, action_alpha_callback)
|
|
cc.ActionManager:getInstance():addAction(action_alpha, self.con)
|
|
end
|
|
end
|
|
|
|
function GuildCSGRSceneView:DestroySuccess( )
|
|
GlobalEventSystem:Fire(EventName.HIDE_EXIT_BTN_STATE) -- 隐藏
|
|
-- GlobalEventSystem:Fire(EventName.MOVE_NODE_EXIT_CON, self.exit_btn, self.transform, "exit_btn", 2)
|
|
GlobalEventSystem:Fire(EventName.MOVE_NODE_EXIT_CON, self.rank_btn, self.transform, "rank_btn", 2)
|
|
for k, v in pairs(self.info_rank_item) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.info_rank_item = nil
|
|
|
|
self:ClearDelaySpecialTipId()
|
|
self:ClearDelayExitTipId()
|
|
self:ClearCountdownFuncId()
|
|
if self.auto_delete_delay_id then
|
|
GlobalTimerQuest:CancelQuest(self.auto_delete_delay_id)
|
|
self.auto_delete_delay_id = nil
|
|
end
|
|
if self.show_delay_id then
|
|
GlobalTimerQuest:CancelQuest(self.show_delay_id)
|
|
self.show_delay_id = nil
|
|
end
|
|
GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP, nil, false)
|
|
CommonController.Instance:Fire(EventName.CLOSE_SPECIALTIPVIEW)
|
|
end
|