源战役客户端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

212 wiersze
5.1 KiB

TaskBountyRewardView = TaskBountyRewardView or BaseClass(BaseView)
local TaskBountyRewardView = TaskBountyRewardView
function TaskBountyRewardView:__init()
self.base_file = "task"
self.layout_file = "TaskBountyRewardView"
self.layer_name = "Activity"
self.destroy_imm = true
self.use_background = true
self.hide_maincancas = false
self.model = TaskModel:getInstance()
self.time_diff = 10
self.is_set_zdepth = true
-- self.use_local_view = true
self.item_list = {}
self.load_callback = function ()
self:LoadSuccess()
self:InitEvent()
end
self.open_callback = function ()
self:InitView()
end
self.close_callback = function ()
end
self.destroy_callback = function ()
self:Clear()
end
end
function TaskBountyRewardView:Open(circle_num)
self.circle_num = circle_num
BaseView.Open(self)
end
function TaskBountyRewardView:Clear()
if self.update_reward_id then
GlobalEventSystem:UnBind(self.update_reward_id)
self.update_reward_id = nil
end
for i, v in ipairs(self.item_list) do
v:DeleteMe()
v = nil
end
self.item_list = {}
self:CancelTimer()
end
function TaskBountyRewardView:Close()
BaseView.Close(self)
end
function TaskBountyRewardView:InitView()
self:StartTimer()
local info = self.model.circle_cache_reward
if not info then
return
end
local reward_list = {}
for index, vo in ipairs(info.reward) do
table.insert(reward_list, vo)
end
for index, vo in ipairs(info.extra_reward) do
table.insert(reward_list, vo)
end
for i, v in ipairs(reward_list) do
local item = self.item_list[i]
if item == nil then
item = AwardItem.New(self.item_parent)
self.item_list[i] = item
end
item:SetVisible(true)
item:SetItemSize(78, 78)
local goods_id, lock = GoodsModel:getInstance():GetMappingTypeId(v[1], v[2])
item:SetData(goods_id, v[3], nil, nil, lock)
if v.is_vip then
item:SetVipAdditionTip(true)
end
end
for i=#reward_list + 1,#self.item_list do
self.item_list[i]:SetVisible(false)
end
if self.circle_num == 10 then
self.ok_btn_txt.text = "继续任务"
elseif self.circle_num == 20 then
self.ok_btn_txt.text = "确定"
end
end
function TaskBountyRewardView:LoadSuccess()
self.left_img,
self.right_img
= GetChildImages(self.transform, {
"left",
"right",
})
lua_resM:setOutsideImageSprite(self, self.left_img, GameResPath.GetCommonImage("jsui_bg"))
lua_resM:setOutsideImageSprite(self, self.right_img,GameResPath.GetCommonImage("jsui_bg"))
self.cancel_btn,
self.ok_btn = self:GetChildGameObjects({
"CancelBtn",
"OkBtn",
})
self.item_parent = self:GetChildTransforms({
"ItemParent"
})
self.tip_txt,
self.ok_btn_txt = self:GetChildTexts({
"Tip",
"OkBtn/Text",
})
end
function TaskBountyRewardView:InitEvent()
local function onBtnClickHandler(target)
if target == self.cancel_btn then
self:Close()
GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK,true)
elseif target == self.ok_btn then
if self.circle_num == 10 then
self:Close()
GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK,true)
elseif self.circle_num == 20 then
self:Close()
self:GoToHook()
end
end
end
AddClickEvent(self.cancel_btn,onBtnClickHandler)
AddClickEvent(self.ok_btn,onBtnClickHandler)
end
function TaskBountyRewardView:GoToHook()
local onHookData = DailyModel:getInstance():GetOnhookConfig()
if onHookData then
local pointList = ErlangParser:GetInstance():Parse(onHookData.xy)
local index = math.random(1, #pointList)
local randomPoint = pointList[index]
local x = tonumber(randomPoint[1])
local y = tonumber(randomPoint[2])
local call_back = function ()
GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
end
local findVo = FindVo.New()
findVo.type = FindVo.POINT
findVo.sceneId = tonumber(onHookData.scene_id)
findVo.x = x / SceneObj.LogicRealRatio.x
findVo.y = y / SceneObj.LogicRealRatio.y
findVo.call_back = call_back
findVo.force_change_scene = true
GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT)
GlobalEventSystem:Fire(EventName.FORCE_STOP_DO_TASK)
Scene.Instance:FindElement(findVo)
end
end
function TaskBountyRewardView:CancelTimer()
if self.timer_id then
TimerQuest.CancelQuest(GlobalTimerQuest, self.timer_id)
self.timer_id = nil
end
end
function TaskBountyRewardView:StartTimer()
self:CancelTimer()
local end_time = TimeUtil:getServerTime( ) + self.time_diff
local function onTimer()
local time = end_time - TimeUtil:getServerTime( )
if time > 0 then
if self.circle_num == 10 then
self.tip_txt.text = string.format("%d秒后自动任务",time)
elseif self.circle_num == 20 then
self.tip_txt.text = string.format("%d秒后自动野外挂机",time)
end
else
self:CancelTimer()
if self.circle_num == 10 then
self:Close()
GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK,true)
elseif self.circle_num == 20 then
self:Close()
self:GoToHook()
end
end
end
onTimer()
self.timer_id = TimerQuest.AddPeriodQuest(GlobalTimerQuest, onTimer,1,-1)
end