GuildSceneWarView = GuildSceneWarView or BaseClass(BaseView)
|
|
local GuildSceneWarView = GuildSceneWarView
|
|
|
|
function GuildSceneWarView:__init()
|
|
self.base_file = "guildScene"
|
|
self.layout_file = "GuildSceneWarView"
|
|
self.layer_name = "Main"
|
|
self.destroy_imm = true
|
|
self.change_scene_close = false
|
|
self.append_to_ctl_queue = false --是否要添加进界面堆栈
|
|
self.need_show_money = false --是否要显示顶部的金钱栏
|
|
self.is_in_pick = false --当前的采集状态
|
|
self.item_list = {}
|
|
self.show_left_time_tip = false
|
|
self.show_exit_time_tip = false
|
|
self.wait_to_collect = false
|
|
self.init_exit_btn = false
|
|
|
|
self.project_cd_time = 0
|
|
|
|
self.model = GuildModel:getInstance()
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:UpdateView()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function GuildSceneWarView:Open( )
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function GuildSceneWarView:LoadSuccess()
|
|
local nodes = {
|
|
"left_info_con/data_con/exitBtn:obj",
|
|
"rightIconCon/rankBtn:obj",
|
|
"left_info_con/data_con/collect_info_con/my_score:tmp",
|
|
"left_info_con/data_con/collect_info_con/leftTime:tmp",
|
|
"left_info_con/data_con/collect_info_con/reward_scroll_collect",
|
|
"left_info_con/data_con/collect_info_con/reward_scroll_collect/Viewport/reward_con_collect",
|
|
"left_info_con/data_con/collect_info_con/boss_hp_percentage:tmp",
|
|
"left_info_con/data_con/collect_info_con/boss_hp_r:img",
|
|
"left_info_con/data_con/collect_info_con/boss_hp_r_bg:img",
|
|
"left_info_con/data_con/collect_info_con/big_time:tmp",
|
|
"left_info_con/data_con/collect_info_con/small_time:tmp",
|
|
"broadcast_root/broadcast_bg:obj",
|
|
"broadcast_root/broadcast_text:tmp",
|
|
"broadcast_root:obj",
|
|
"left_info_con/data_con/collect_info_con/escort_boss_1:obj",
|
|
"left_info_con/data_con/collect_info_con/escort_boss_2:obj",
|
|
"left_info_con/data_con/collect_info_con/escort_small_1:obj",
|
|
"left_info_con/data_con/collect_info_con/escort_small_2:obj",
|
|
"left_info_con/data_con/collect_info_con/escort_big_1:obj",
|
|
"left_info_con/data_con/collect_info_con/escort_big_2:obj",
|
|
"left_info_con/data_con/collect_info_con/boss_tips:tmp",
|
|
"left_info_con/data_con/collect_info_con/boss_name:tmp",
|
|
"rightIconCon:obj",
|
|
"left_info_con:obj",
|
|
"left_info_con/data_con/collect_info_con",
|
|
"left_info_con/data_con/collect_info_con/reward_scroll_collect/Viewport/reward_con_collect/finish:obj",
|
|
"left_info_con/data_con/collect_info_con/guide_tip_1/guide_tip_text_1:tmp",
|
|
"left_info_con/data_con/collect_info_con/guide_tip_1:obj",
|
|
|
|
"func_btn_con/find_boss_btn:obj",
|
|
"func_btn_con/find_escort_btn:obj:img",
|
|
"func_btn_con/escorting_text:tmp",
|
|
"func_btn_con:obj",
|
|
|
|
"func_btn_con/boss_state:img",
|
|
"func_btn_con/protect_btn:obj",
|
|
"func_btn_con/protect_btn/protect_cd_img:img",
|
|
"func_btn_con/protect_btn/protect_cd_time:tmp",
|
|
"func_btn_con/boss_tips_root:obj",
|
|
"func_btn_con/boss_tips_root/lb_boss_tips:tmp",
|
|
|
|
"left_info_con/data_con/collect_info_con/escort_small_2/escort_small_2_text:tmp",
|
|
"left_info_con/data_con/collect_info_con/escort_big_2/escort_big_2_text:tmp",
|
|
|
|
}
|
|
self:GetChildren(nodes)
|
|
--设置sceneView的自适应
|
|
self.transform.sizeDelta = Vector2(ScreenWidth, ScreenHeight)
|
|
SetAnchoredPosition(self.transform, 0, 0)
|
|
|
|
|
|
self.boss_hp_r_img.gameObject:SetActive(false)
|
|
self.boss_hp_r_bg_img.gameObject:SetActive(false)
|
|
self.boss_hp_percentage_tmp.gameObject:SetActive(false)
|
|
self.boss_name_tmp.gameObject:SetActive(false)
|
|
|
|
self:ChangeUiPosition()
|
|
|
|
--进场的时候,提示引导
|
|
self:StartGuideAction()
|
|
|
|
--护盾时间
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40513)
|
|
end
|
|
|
|
function GuildSceneWarView:AddEvent()
|
|
local function onBtnClickHandler(target)
|
|
if target == self.exitBtn_obj then
|
|
self.model:Fire(GuildModel.LEAVE_GUILD_WAR_SCENE)
|
|
elseif target == self.rankBtn_obj then
|
|
self.model:GuildWarSetRankList()
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40504)
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40505)
|
|
self.model:Fire(GuildModel.OPEN_GUILD_WAR_RANK_VIEW)
|
|
elseif target == self.escort_big_1_obj or target == self.escort_big_2_obj then
|
|
if not self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.BigRice) then
|
|
--如果没有精粮就不显示护送中了
|
|
self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.Boss)
|
|
return
|
|
end
|
|
self:StopActionGuideTipsAction(false)
|
|
self:UpdatePickInfo(true)
|
|
elseif target == self.find_escort_btn_obj then
|
|
self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.SmallRice)
|
|
self:StopActionGuideTipsAction(false)
|
|
self:UpdatePickInfo(true)
|
|
elseif target == self.escort_small_1_obj or target == self.escort_small_2_obj then
|
|
if not self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.MiddleRice) then
|
|
--如果没有中粮就不显示护送中了
|
|
self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.Boss)
|
|
return
|
|
end
|
|
self:StopActionGuideTipsAction(false)
|
|
self:UpdatePickInfo(true)
|
|
elseif target == self.escort_boss_1_obj or target == self.escort_boss_2_obj or target == self.find_boss_btn_obj then
|
|
Scene.Instance:CancelClickTarget(nil, true)
|
|
self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.Boss)
|
|
self:StopActionGuideTipsAction(false)
|
|
elseif target == self.protect_btn_obj then
|
|
self.model:Fire(GuildModel.REQUEST_CCMD_EVENT,40514)
|
|
end
|
|
end
|
|
AddClickEvent(self.exitBtn_obj,onBtnClickHandler)
|
|
AddClickEvent(self.rankBtn_obj,onBtnClickHandler)
|
|
AddClickEvent(self.escort_boss_1_obj,onBtnClickHandler)
|
|
AddClickEvent(self.escort_boss_2_obj,onBtnClickHandler)
|
|
AddClickEvent(self.escort_big_1_obj,onBtnClickHandler)
|
|
AddClickEvent(self.escort_big_2_obj,onBtnClickHandler)
|
|
AddClickEvent(self.escort_small_1_obj,onBtnClickHandler)
|
|
AddClickEvent(self.escort_small_2_obj,onBtnClickHandler)
|
|
AddClickEvent(self.find_boss_btn_obj,onBtnClickHandler)
|
|
AddClickEvent(self.find_escort_btn_obj,onBtnClickHandler)
|
|
AddClickEvent(self.protect_btn_obj,onBtnClickHandler)
|
|
|
|
self.exitBtn_obj:SetActive(false)
|
|
|
|
local function delay_init( ... )
|
|
if self._use_delete_method then return end
|
|
if not self.init_exit_btn then--初始退出exit_btn_pos这个是任务背景的长度
|
|
self.init_exit_btn = true
|
|
local function call_back( ... )
|
|
self.model:Fire(GuildModel.LEAVE_GUILD_WAR_SCENE)
|
|
end
|
|
local data = {call_back = call_back, pos = {x = 198,y = 280}}
|
|
GlobalEventSystem:Fire(EventName.SHOW_EXIT_BTN_STATE,data)
|
|
end
|
|
end
|
|
setTimeout(delay_init,0.5)
|
|
|
|
--百团对话监听
|
|
local function onUpdateScroe( )
|
|
self:UpdateScore()
|
|
end
|
|
self:BindEvent(self.model, GuildModel.GUILD_WAR_UPDATE_SCROE, onUpdateScroe)
|
|
|
|
--基本信息刷新
|
|
local function onUpdaeBaseInfo()
|
|
self:UpdateScore()
|
|
self:UpdateTime()
|
|
end
|
|
self:BindEvent(self.model, GuildModel.GUILD_WAR_BASE_INFO, onUpdaeBaseInfo)
|
|
|
|
--百团对话监听
|
|
local function onCheckGuildWarnpc(npc_type_id )
|
|
self.model:GuideWarGiveInPick(npc_type_id)
|
|
end
|
|
self:BindEvent(GlobalEventSystem, DialogueModel.CLICK_OK, onCheckGuildWarnpc)
|
|
|
|
--boss更新刷新
|
|
local function onUdateBossInfo(npc_type_id)
|
|
self:UpdateCountInfo()
|
|
end
|
|
self:BindEvent(self.model, GuildModel.GUILD_WAR_BOSS_BORN, onUdateBossInfo)
|
|
self:BindEvent(self.model, GuildModel.GUILD_WAR_BOSS_DIE, onUdateBossInfo)
|
|
|
|
--怪物添加
|
|
local function onMonsterUpdateAdd(monster_id, monster_vo)
|
|
if monster_vo.type_id == GuildModel.GuildWarTarget.Boss then
|
|
self:UpdateBossInfo(true, monster_vo)
|
|
self:ShowRefreshBossTipsAnimation()
|
|
end
|
|
self:UpdateCountInfo()
|
|
end
|
|
self:BindEvent(GlobalEventSystem, SceneEventType.MONSTER_VO_ADD, onMonsterUpdateAdd)
|
|
--进场boss已经刷新了,提示一下
|
|
local function boss_refresh_func()
|
|
if self._use_delete_method then return end
|
|
local boss_num = self.model:GuideWarGetTargetNum(GuildModel.GuildWarTarget.Boss)
|
|
if boss_num > 0 then
|
|
self:ShowRefreshBossTipsAnimation()
|
|
end
|
|
end
|
|
setTimeout(boss_refresh_func,1)
|
|
|
|
--怪物移除
|
|
local function onMonsterUpdateRemove(monster_id, monster_type_id, monster_vo)
|
|
if monster_vo.type_id == GuildModel.GuildWarTarget.Boss then
|
|
self:UpdateBossInfo(false, monster_vo)
|
|
end
|
|
self:UpdateCountInfo()
|
|
end
|
|
self:BindEvent(GlobalEventSystem, SceneEventType.MONSTER_VO_REMOVE, onMonsterUpdateRemove)
|
|
|
|
--百团对话监听
|
|
local function onBroadcast(module_id, id)
|
|
if module_id == 405 then
|
|
local config = Config.Languageextra
|
|
local key = module_id .. "@" .. id
|
|
if config[key] and config[key].content then
|
|
self:UpdateBroadCast(config[key].content)
|
|
end
|
|
end
|
|
end
|
|
self:BindEvent(SocialityModel:getInstance(), SocialityModel.BROADCAST_MIDDLE_MESSAGE, onBroadcast)
|
|
|
|
--更新右上角活动图标状态
|
|
local function changeFunc(is_hide)
|
|
self.rightIconCon_obj:SetActive(is_hide)
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.CHANGE_RIGHT_TIP_ICON, changeFunc)
|
|
|
|
--适配刘海屏
|
|
local function onOrientationChange()
|
|
self:ChangeUiPosition()
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.ORIENTATION_DID_CHANGE, onOrientationChange)
|
|
|
|
|
|
--采集状态变化
|
|
local function onUpdaePickInfo()
|
|
local find_way_state = AutoFightManager:getInstance():GetAutoFindWayState()
|
|
local fight_state = AutoFightManager:getInstance():GetAutoFightState()
|
|
if fight_state then
|
|
self:UpdatePickInfo(false)
|
|
elseif find_way_state then
|
|
--不处理
|
|
else
|
|
local function delay_fun( ... )
|
|
local main_role = Scene.Instance.main_role
|
|
if not main_role then
|
|
self:UpdatePickInfo(false)
|
|
return
|
|
end
|
|
if main_role:IsInState(PoseState.COLLECT) then
|
|
self:UpdatePickInfo(true)
|
|
else
|
|
local find_way_state = AutoFightManager:getInstance():GetAutoFindWayState()
|
|
if not find_way_state then
|
|
self:UpdatePickInfo(false)
|
|
end
|
|
end
|
|
end
|
|
TimeManager.GetInstance():StartDalayTime("GuildSceneWarViewonUpdaePickInfo",0.5,delay_fun)
|
|
end
|
|
end
|
|
self:BindEvent(GlobalEventSystem, AutoFightManager.CHANGE_AUTO_FIGHT_STATE, onUpdaePickInfo)
|
|
self:BindEvent(GlobalEventSystem, AutoFightManager.CHANGE_AUTO_FIND_WAY_STATE, onUpdaePickInfo)
|
|
|
|
local function onCancelCollect()
|
|
self:UpdatePickInfo(false)
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.CANCEL_TO_COLLECT, onCancelCollect)
|
|
|
|
local function onStartCollect()
|
|
self:UpdatePickInfo(true)
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.START_TO_COLLECT, onStartCollect)
|
|
self:BindEvent(self.model, GuildModel.GUILD_WAR_START_COLLECT, onStartCollect)
|
|
|
|
local function onReliveSuccess(i_type)
|
|
--出生地复活
|
|
if i_type == 3 then
|
|
EventSystem.Fire(GlobalEventSystem,EventName.STOPAUTOFIGHT, false, true)
|
|
self.wait_to_collect = true
|
|
else
|
|
EventSystem.Fire(GlobalEventSystem,EventName.STOPAUTOFIGHT, false, true)
|
|
self.wait_to_collect = false
|
|
end
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.RELIVE_SUCC, onReliveSuccess)
|
|
|
|
--复活动画播放完成
|
|
local function onReviveEndEvent()
|
|
if self.wait_to_collect then
|
|
self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.SmallRice)
|
|
self:UpdatePickInfo(true)
|
|
self.wait_to_collect = false
|
|
else
|
|
--起来只停自动战斗
|
|
end
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.REVIVE_END_EVENT, onReviveEndEvent)
|
|
|
|
--场景落地动画结束,开始采集
|
|
local function onDoFlyShoeEffectFinishDown()
|
|
self.model:FindGuideWarTarget(GuildModel.GuildWarTarget.SmallRice)
|
|
self:UpdatePickInfo(true)
|
|
end
|
|
self:BindEvent(GlobalEventSystem, SceneEventType.DO_FLYSHOE_EFFECT_FINISH_DOWN, onDoFlyShoeEffectFinishDown)
|
|
|
|
|
|
--更新护盾
|
|
local function onProject()
|
|
self:UpdateProjectGroup()
|
|
end
|
|
self:BindEvent(self.model, GuildModel.GUILD_WAR_PROJECT, onProject)
|
|
|
|
--对话提示框
|
|
local function hide_dance_eff_node()
|
|
self.left_info_con_obj:SetActive(false)
|
|
end
|
|
local function show_dance_eff_node()
|
|
self.left_info_con_obj:SetActive(true)
|
|
end
|
|
self:BindEvent(GlobalEventSystem, EventName.START_COM_DIALOGUE_SHOW_ANIM, hide_dance_eff_node)
|
|
self:BindEvent(GlobalEventSystem, EventName.FINISHED_COM_DIALOGUE_SHOW_ANIM, show_dance_eff_node)
|
|
|
|
self:BindLittleMove(self.left_info_con, BaseView.LittleMoveDir.Left, 222)
|
|
self:BindLittleMove(self.func_btn_con, BaseView.LittleMoveDir.Bottom, 192)
|
|
self:BindLittleMove(self.rightIconCon, BaseView.LittleMoveDir.Right, -60)
|
|
|
|
-- 主界面聊天展开事件
|
|
self:BindMainUIExpandEvent( self.func_btn_con )
|
|
|
|
self:UpdatePickInfo(false)
|
|
end
|
|
|
|
function GuildSceneWarView:UpdateView()
|
|
self:UpdateScore()
|
|
self:UpdateTime()
|
|
self:UpdateCountInfo()
|
|
self:UpdateBossInfo(true)
|
|
end
|
|
|
|
function GuildSceneWarView:DestroySuccess( )
|
|
if self.timer then
|
|
GlobalTimerQuest:CancelQuest(self.timer)
|
|
self.timer = nil
|
|
end
|
|
|
|
if self.boss_timer then
|
|
GlobalTimerQuest:CancelQuest(self.boss_timer)
|
|
self.boss_timer = nil
|
|
end
|
|
|
|
if self.boss_vo and self.boss_vo_id then
|
|
self.boss_vo:UnBind(self.boss_vo_id)
|
|
self.boss_vo_id = nil
|
|
end
|
|
|
|
if self.broadcast_timer then
|
|
GlobalTimerQuest:CancelQuest(self.broadcast_timer)
|
|
self.broadcast_timer = nil
|
|
end
|
|
|
|
if self.delay_timer then
|
|
GlobalTimerQuest:CancelQuest(self.delay_timer)
|
|
self.delay_timer = nil
|
|
end
|
|
for k,n in ipairs(self.item_list) do
|
|
n:SetIsFixSize(true)
|
|
UIObjPool:PushItem(UIObjPool.UIType.AwardItem, n)
|
|
end
|
|
self.item_list = {}
|
|
|
|
|
|
if self.delay_guide_tips_timer then
|
|
GlobalTimerQuest:CancelQuest(self.delay_guide_tips_timer)
|
|
self.delay_guide_tips_timer = nil
|
|
end
|
|
|
|
self:StopActionGuideTipsAction(false)
|
|
self:StopPrjectCdTimer()
|
|
self:StopRefreshBossTipsAnimation(true)
|
|
|
|
--关闭计时界面
|
|
CommonController.Instance:Fire(EventName.OPEN_SPECIALTIPVIEW, false)
|
|
GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP, nil, false)
|
|
|
|
GlobalEventSystem:Fire(EventName.HIDE_EXIT_BTN_STATE)
|
|
end
|
|
|
|
function GuildSceneWarView:UpdateScore( )
|
|
local score = self.model.guild_war_info.score or 0
|
|
local reward_list, is_finish,next_score = self.model:GuildWarGetRewardByScroe(score, true)
|
|
reward_list = reward_list or {}
|
|
self.my_score_tmp.text = score .. "/" .. next_score
|
|
|
|
for i, v in ipairs(self.item_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
for ii,vv in ipairs(reward_list) do
|
|
local show_item = self.item_list[ii]
|
|
if not show_item then
|
|
show_item = UIObjPool:PopItem(UIObjPool.UIType.AwardItem, self.reward_con_collect)
|
|
show_item:SetIsFixSize(false)
|
|
show_item:SetItemSize(50,50)
|
|
self.item_list[ii] = show_item
|
|
show_item:SetAnchoredPosition(60*(ii-1) + 3, -6)
|
|
self.finish:SetSiblingIndex(#self.item_list + 1)
|
|
end
|
|
local goods_Id, lock = GoodsModel:getInstance():GetMappingTypeId(vv[1], vv[2])
|
|
local goodVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_Id)
|
|
show_item:SetIsFixSize(false)
|
|
show_item:SetItemSize(50,50)
|
|
if goodVo then
|
|
show_item:SetData(goodVo.type_id, vv[3] , goodVo.color, nil, lock)
|
|
end
|
|
show_item:SetVisible(true)
|
|
if is_finish then
|
|
|
|
SetAnchoredPositionX(self.finish, #reward_list == 1 and 28 or (#reward_list > 2 and 88 or 58 ))
|
|
end
|
|
show_item:SetGray(is_finish)
|
|
end
|
|
SetSizeDeltaX(self.reward_con_collect, 63 * #reward_list)
|
|
self.finish_obj:SetActive(is_finish)
|
|
end
|
|
|
|
function GuildSceneWarView:UpdateTime()
|
|
if self.timer then
|
|
GlobalTimerQuest:CancelQuest(self.timer)
|
|
self.timer = nil
|
|
end
|
|
self.end_time = self.model.guild_war_info.end_time or TimeUtil:getServerTime()
|
|
local function timer_func()
|
|
local left_time = self.end_time - TimeUtil:getServerTime()
|
|
if left_time and left_time > 0 then
|
|
self:ShowExitTime(left_time)
|
|
self.leftTime_tmp.text = TimeUtil:timeConvert8(left_time)
|
|
if self.is_in_pick then
|
|
self.is_in_pick = self.is_in_pick + 1
|
|
if self.is_in_pick > 3 then
|
|
self.is_in_pick = 1
|
|
end
|
|
self.escorting_text_tmp.text = self.is_in_pick == 1 and (".") or (self.is_in_pick == 2 and ".." or "...")
|
|
else
|
|
self.escorting_text_tmp.text = ""
|
|
end
|
|
else
|
|
self.escorting_text_tmp.text = ""
|
|
self.leftTime_tmp.text = "00:00"
|
|
if self.timer then
|
|
GlobalTimerQuest:CancelQuest(self.timer)
|
|
self.timer = nil
|
|
end
|
|
end
|
|
end
|
|
if not self.timer then
|
|
self.timer = GlobalTimerQuest:AddPeriodQuest(timer_func, 1)
|
|
end
|
|
timer_func()
|
|
end
|
|
|
|
function GuildSceneWarView:UpdateCountInfo()
|
|
local big_time = self.model:GuideWarGetTargetNum(GuildModel.GuildWarTarget.BigRice)
|
|
local middle_time = self.model:GuideWarGetTargetNum(GuildModel.GuildWarTarget.MiddleRice)
|
|
|
|
self.escort_small_2_text_tmp.text = middle_time == 0 and "<color=#2cf86f><u>击杀BOSS刷新</u></color>" or "<color=#2cf86f><u>前往护送</u></color>"
|
|
self.escort_big_2_text_tmp.text = big_time == 0 and "<color=#2cf86f><u>击杀BOSS刷新</u></color>" or "<color=#2cf86f><u>前往护送</u></color>"
|
|
self.big_time_tmp.text = string.format("剩余: %s", HtmlColorTxt(tostring(big_time), "#2cf86f"))
|
|
self.small_time_tmp.text = string.format("剩余: %s", HtmlColorTxt(tostring(middle_time), "#2cf86f"))
|
|
end
|
|
|
|
function GuildSceneWarView:UpdateBossInfo(is_add, boss_vo)
|
|
self.boss_vo = self.model:GuideWarGetBossVo() or boss_vo
|
|
if self.boss_vo and self.boss_vo_id then
|
|
self.boss_vo:UnBind(self.boss_vo_id)
|
|
self.boss_vo_id = nil
|
|
end
|
|
|
|
if self.boss_timer then
|
|
GlobalTimerQuest:CancelQuest(self.boss_timer)
|
|
self.boss_timer = nil
|
|
end
|
|
|
|
|
|
|
|
if self.boss_vo and is_add then
|
|
if self.delay_timer then
|
|
GlobalTimerQuest:CancelQuest(self.delay_timer)
|
|
self.delay_timer = nil
|
|
end
|
|
--self.escort_boss_2_obj:SetActive(true)
|
|
self.boss_hp_r_img.gameObject:SetActive(true)
|
|
self.boss_hp_r_bg_img.gameObject:SetActive(true)
|
|
self.boss_hp_percentage_tmp.gameObject:SetActive(true)
|
|
self.boss_name_tmp.gameObject:SetActive(true)
|
|
self.boss_name_tmp.text = string.format("结晶守卫%s", HtmlColorTxt("(前往击杀)", ColorUtil.GREEN_DARK))
|
|
self.boss_hp_percentage_tmp.text = ""
|
|
self.boss_tips_tmp.gameObject:SetActive(false)
|
|
lua_resM:setImageSprite(self,self.boss_state_img,"guildScene_asset", "guild_war_boss_live", true)
|
|
|
|
local function func_update_hp()
|
|
local percent = self.boss_vo.hp / self.boss_vo.maxHp
|
|
self.boss_hp_r_img.fillAmount = percent
|
|
self.boss_hp_percentage_tmp.text = math.ceil(percent * 100) .. "%"
|
|
end
|
|
|
|
self.boss_vo_id = self.boss_vo:BindOne("hp", func_update_hp)
|
|
func_update_hp()
|
|
else
|
|
|
|
--当boss找不到的时候,延时1秒,在更新信息栏,因为有时候,安全区复活boss第一时间没生成,会闪一下
|
|
if self.delay_timer then
|
|
GlobalTimerQuest:CancelQuest(self.delay_timer)
|
|
self.delay_timer = nil
|
|
end
|
|
|
|
local function delay_func()
|
|
self.escort_boss_2_obj:SetActive(false)
|
|
self.boss_hp_r_img.gameObject:SetActive(false)
|
|
self.boss_hp_r_bg_img.gameObject:SetActive(false)
|
|
self.boss_name_tmp.gameObject:SetActive(false)
|
|
self.boss_hp_percentage_tmp.gameObject:SetActive(false)
|
|
self.boss_tips_tmp.gameObject:SetActive(true)
|
|
self.boss_tips_tmp.text = ""
|
|
|
|
local idx = 0
|
|
self.next_boss_born_time, idx = self.model:GuildWarGetNextBossBornTime()
|
|
if self.next_boss_born_time > 0 then
|
|
|
|
local function boss_timer_func()
|
|
local left_time = self.next_boss_born_time - TimeUtil:getServerTime()
|
|
--print(">>>>>>>> self.next_boss_born_time222 ", left_time)
|
|
if left_time and left_time > 0 then
|
|
self:ShowLiveTime(left_time)
|
|
lua_resM:setImageSprite(self,self.boss_state_img,"guildScene_asset", "guild_war_boss_death", true)
|
|
self.boss_tips_tmp.text = "刷新时间:" .. HtmlColorTxt(TimeUtil:timeConvert8(left_time) , "#2cf86f")
|
|
else
|
|
lua_resM:setImageSprite(self,self.boss_state_img,"guildScene_asset", "guild_war_boss_live", true)
|
|
if self.boss_timer then
|
|
GlobalTimerQuest:CancelQuest(self.boss_timer)
|
|
self.boss_timer = nil
|
|
end
|
|
self.show_left_time_tip = false
|
|
self.boss_tips_tmp.text = ""
|
|
end
|
|
end
|
|
if not self.boss_timer then
|
|
self.boss_timer = GlobalTimerQuest:AddPeriodQuest(boss_timer_func, 1)
|
|
end
|
|
boss_timer_func()
|
|
else
|
|
lua_resM:setImageSprite(self,self.boss_state_img,"guildScene_asset", "guild_war_boss_death", true)
|
|
self.boss_tips_tmp.text = string.format("结晶守卫\n%s", HtmlColorTxt("已击杀" , ColorUtil.RED_DARK))
|
|
end
|
|
end
|
|
|
|
if not self.delay_timer then
|
|
self.delay_timer = GlobalTimerQuest:AddPeriodQuest(delay_func, 1, 0)
|
|
end
|
|
end
|
|
end
|
|
|
|
function GuildSceneWarView:UpdateBroadCast(str)
|
|
if self.broadcast_timer then
|
|
GlobalTimerQuest:CancelQuest(self.broadcast_timer)
|
|
self.broadcast_timer = nil
|
|
end
|
|
local left_time = 6
|
|
self.broadcast_root_obj:SetActive(true)
|
|
self.broadcast_text_tmp.text = str
|
|
function broadcast_timer_func( )
|
|
left_time = left_time - 1
|
|
if left_time > 0 then
|
|
|
|
else
|
|
if self.broadcast_timer then
|
|
GlobalTimerQuest:CancelQuest(self.broadcast_timer)
|
|
self.broadcast_timer = nil
|
|
end
|
|
self.broadcast_root_obj:SetActive(false )
|
|
self.broadcast_text_tmp.text = ""
|
|
end
|
|
|
|
end
|
|
|
|
if not self.broadcast_timer then
|
|
self.broadcast_timer = GlobalTimerQuest:AddPeriodQuest(broadcast_timer_func, 1)
|
|
end
|
|
|
|
broadcast_timer_func()
|
|
end
|
|
|
|
function GuildSceneWarView:ChangeUiPosition( )
|
|
SetAnchoredPositionX(self.left_info_con, 222 + ClientConfig.iphone_x_offset_left)
|
|
end
|
|
|
|
|
|
function GuildSceneWarView:StartGuideAction( )
|
|
self.action_breath_light = ActionBreathLight.New()
|
|
self.action_breath_light:Init(self.guide_tip_1)
|
|
self.guide_tip_1_obj:SetActive(true)
|
|
self.guide_tip_text_1_tmp.text = string.format("运送结晶可获得%s,\n击败BOSS有%s!",HtmlColorTxt("积分" , "#fdffc2"), HtmlColorTxt("大量积分" , "#fdffc2"))
|
|
if self.delay_guide_tips_timer then
|
|
GlobalTimerQuest:CancelQuest(self.delay_guide_tips_timer)
|
|
self.delay_guide_tips_timer = nil
|
|
end
|
|
|
|
local delay_func = function()
|
|
self:StopActionGuideTipsAction(false)
|
|
end
|
|
self.delay_guide_tips_timer = GlobalTimerQuest:AddDelayQuest(delay_func, 10)
|
|
end
|
|
|
|
function GuildSceneWarView:StopActionGuideTipsAction(visible)
|
|
visible = visible or false
|
|
self.guide_tip_1_obj:SetActive(visible)
|
|
if self.action_breath_light then
|
|
self.action_breath_light:DeleteMe()
|
|
self.action_breath_light = false
|
|
end
|
|
|
|
if self.delay_guide_tips_timer then
|
|
GlobalTimerQuest:CancelQuest(self.delay_guide_tips_timer)
|
|
self.delay_guide_tips_timer = nil
|
|
end
|
|
end
|
|
|
|
function GuildSceneWarView:UpdatePickInfo(state)
|
|
local b = state
|
|
self.is_in_pick = b == true and 0 or false
|
|
self.escorting_text_tmp.text = ""
|
|
lua_resM:setImageSprite(self,self.find_escort_btn_img,"guildScene_asset", b and "guild_war_escorting_btn" or "guild_war_escort_btn", true)
|
|
end
|
|
|
|
function GuildSceneWarView:ShowLiveTime(time)
|
|
if time > 30 then
|
|
return
|
|
end
|
|
if self.show_left_time_tip then
|
|
return
|
|
end
|
|
self.show_left_time_tip = true
|
|
local special_tip_data = {
|
|
type = SpecialTipType.Timer2,
|
|
sepeical_str = "结晶守卫降临 %s",
|
|
show_time = time,
|
|
}
|
|
CommonController.Instance:Fire(EventName.OPEN_SPECIALTIPVIEW, special_tip_data)
|
|
end
|
|
|
|
function GuildSceneWarView:ShowExitTime(time)
|
|
if time > 15 then
|
|
return
|
|
end
|
|
if self.show_exit_time_tip then
|
|
return
|
|
end
|
|
self.show_exit_time_tip = true
|
|
local data = {
|
|
time = time,
|
|
time_str = "秒后",
|
|
exit_desc = "自动退出战场",
|
|
}
|
|
GlobalEventSystem:Fire(EventName.OPEN_EXIT_TIME_TIP, data, true)
|
|
end
|
|
|
|
function GuildSceneWarView:UpdateProjectGroup()
|
|
local cd_time = self.model.guild_war_info.cd_time or 0
|
|
local cur_time = TimeUtil:getServerTime()
|
|
self:StopPrjectCdTimer()
|
|
if cd_time == 0 or cur_time >= cd_time then
|
|
self.project_cd_time = 0
|
|
self.protect_cd_time_tmp.text = ""
|
|
self.protect_cd_img_img.fillAmount = 1
|
|
else
|
|
local time = cd_time - cur_time
|
|
if not self.skill_max_cd_time then
|
|
local cfg = Config.Guildwarkv
|
|
self.skill_max_cd_time = tonumber(cfg["skill_cd"].value_content)
|
|
end
|
|
self.protect_cd_img_img.fillAmount = 1 - (time / self.skill_max_cd_time)
|
|
self.project_cd_time = time
|
|
local delay_func = function ()
|
|
self.project_cd_time = self.project_cd_time - 1
|
|
if self.project_cd_time <= 0 then
|
|
self:UpdateProjectGroup()
|
|
return
|
|
end
|
|
self.protect_cd_time_tmp.text = self.project_cd_time
|
|
end
|
|
self.protect_cd_time_tmp.text = self.project_cd_time
|
|
if not self.project_timer then
|
|
self.project_timer = GlobalTimerQuest:AddPeriodQuest(delay_func, 1)
|
|
end
|
|
self.tween_project_cd = TweenLite.to(self, self.protect_cd_img_img,TweenLite.UiAnimationType.FILLAMOUNT, 1, time)
|
|
end
|
|
end
|
|
|
|
function GuildSceneWarView:StopPrjectCdTimer()
|
|
if self.project_timer then
|
|
GlobalTimerQuest:CancelQuest(self.project_timer)
|
|
self.project_timer = nil
|
|
end
|
|
if self.tween_project_cd then
|
|
TweenLite.Stop(self.tween_project_cd)
|
|
self.tween_project_cd = nil
|
|
end
|
|
end
|
|
|
|
|
|
function GuildSceneWarView:ShowRefreshBossTipsAnimation( )
|
|
self:StartRefreshBossTipsAnimation()
|
|
|
|
local left_time = 11
|
|
local function left_tips_timer_func()
|
|
left_time = left_time - 1
|
|
if left_time <= 0 then
|
|
self:StopRefreshBossTipsAnimation(true)
|
|
end
|
|
end
|
|
if not self.boss_tips_delay_timer then
|
|
self.boss_tips_delay_timer = GlobalTimerQuest:AddPeriodQuest(left_tips_timer_func, 1)
|
|
end
|
|
left_tips_timer_func()
|
|
end
|
|
|
|
function GuildSceneWarView:StartRefreshBossTipsAnimation( )
|
|
self:StopRefreshBossTipsAnimation()
|
|
self.boss_tips_root_obj:SetActive(true)
|
|
local call_fun = function ()
|
|
local function onCompleted()
|
|
self:StartRefreshBossTipsAnimation()
|
|
end
|
|
self.boss_tips_tween_id1 = TweenLite.to(self, self.boss_tips_root.transform,TweenLite.UiAnimationType.ANCHORED_POS,Vector2(0, 10 - 5), 0.5, onCompleted)
|
|
end
|
|
local onDelay = function( )
|
|
self.boss_tips_tween_id2 = TweenLite.to(self, self.boss_tips_root.transform,TweenLite.UiAnimationType.ANCHORED_POS,Vector2(0, 10 + 5), 0.5, call_fun)
|
|
end
|
|
self.arrow_boss_timer_delay_id = setTimeout(onDelay, 0.01)
|
|
end
|
|
|
|
function GuildSceneWarView:StopRefreshBossTipsAnimation(stop_delay_timer)
|
|
self.boss_tips_root_obj:SetActive(false)
|
|
if self.boss_tips_tween_id1 then
|
|
TweenLite.Stop(self.boss_tips_tween_id1)
|
|
self.boss_tips_tween_id1 = nil
|
|
end
|
|
if self.boss_tips_tween_id2 then
|
|
TweenLite.Stop(self.boss_tips_tween_id2)
|
|
self.boss_tips_tween_id2 = nil
|
|
end
|
|
if self.arrow_boss_timer_delay_id then
|
|
GlobalTimerQuest:CancelQuest(self.arrow_boss_timer_delay_id)
|
|
self.arrow_boss_timer_delay_id = nil
|
|
end
|
|
|
|
if stop_delay_timer then
|
|
if self.boss_tips_delay_timer then
|
|
GlobalTimerQuest:CancelQuest(self.boss_tips_delay_timer)
|
|
self.boss_tips_delay_timer = nil
|
|
end
|
|
end
|
|
end
|