|
CommonHuntResultView2 = CommonHuntResultView2 or BaseClass(BaseView)
|
|
|
|
local CommonHuntResultView2 = CommonHuntResultView2
|
|
|
|
function CommonHuntResultView2:__init()
|
|
self.base_file = "common"
|
|
self.layout_file = "CommonHuntResultView2"
|
|
self.layer_name = "Activity"
|
|
self.is_set_zdepth = true
|
|
self.click_bg_toClose = false
|
|
self.use_background = true
|
|
self.change_scene_close = true
|
|
self.reward_item_list = {}
|
|
-- self.loop_mgr = LoopScrowViewMgr.New()
|
|
self.column_num = 5 --一行多少个图标
|
|
self.show_count = 10
|
|
|
|
self.init_event = {}
|
|
self.use_local_view = true
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:InitEvent()
|
|
end
|
|
self.open_callback = function ()
|
|
self:SetData()
|
|
end
|
|
self.close_callback = function ()
|
|
|
|
end
|
|
self.destroy_callback = function ()
|
|
self:Remove()
|
|
end
|
|
end
|
|
|
|
function CommonHuntResultView2:LoadSuccess()
|
|
self.mask_btn,
|
|
self.score_obj
|
|
= GetChildGameObjects(self.transform, {
|
|
"maskBtn",
|
|
"parentCon/get_score"
|
|
})
|
|
|
|
self.mask_btn.transform.sizeDelta = Vector2(ScreenWidth, ScreenHeight)
|
|
self.score_num = self:GetChild("parentCon/get_score/text"):GetComponent("Text")
|
|
self.rune_goods_panel_list = {}
|
|
self.huntBtn_list = {}
|
|
self.huntBtn_dot_list = {}
|
|
self.consumable_image_list = {}
|
|
self.consumable_text_list = {}
|
|
self.huntItem_list = {}
|
|
self.huntBtn_text_list = {}
|
|
self.huntBtn_image_list = {}
|
|
self.draw_btn_iamge_list = {}
|
|
for i = 1, 2 do
|
|
self.huntItem_list[i] = self:GetChild("parentCon/hunt/hunt_"..i)
|
|
self.huntBtn_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/btn").gameObject
|
|
self.huntBtn_dot_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/btn/red_dot").gameObject
|
|
self.consumable_image_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/consumable"):GetComponent("Image")
|
|
self.consumable_text_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/consumable/text"):GetComponent("Text")
|
|
self.huntBtn_text_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/btn/Text"):GetComponent("Text")
|
|
self.huntBtn_image_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/image"):GetComponent("Image")
|
|
self.draw_btn_iamge_list[i] = self:GetChild("parentCon/hunt/hunt_"..i.."/btn"):GetComponent("Image")
|
|
end
|
|
self.scroll,
|
|
self.panel,
|
|
self.parent,
|
|
self.get_rune,
|
|
self.effect,
|
|
self.parentCon,
|
|
self.effect1
|
|
= GetChildTransforms(self.transform,
|
|
{
|
|
"parentCon/ScrollView",
|
|
"parentCon/ScrollView/Viewport/panel",
|
|
"parentCon/con/parent",
|
|
"parentCon/get_rune",
|
|
"parentCon/effect",
|
|
"parentCon",
|
|
"effect1",
|
|
})
|
|
self.scroll.gameObject:SetActive(false)
|
|
self.get_rune.gameObject:SetActive(false)
|
|
self:AddUIEffect("ui_lwmb_boom",self.effect1, self.layer_name, nil, 1, false, nil, nil, nil)
|
|
self.bg,
|
|
self.bg1,
|
|
self.icon
|
|
= GetChildImages(self.transform,
|
|
{
|
|
"parentCon/bg1",
|
|
"parentCon/bg1/image",
|
|
"parentCon/get_score/icon",
|
|
})
|
|
lua_resM:setOutsideImageSprite(self, self.bg, GameResPath.GetCommonImage("jsui_bg"), false)
|
|
lua_resM:setOutsideImageSprite(self, self.bg1, GameResPath.GetCommonImage("jsui_bg"), false)
|
|
end
|
|
|
|
function CommonHuntResultView2:InitEvent()
|
|
local function OnItemClick(target)
|
|
for i, v in ipairs(self.huntBtn_list) do
|
|
if target == v then
|
|
local callfunc = self["btn"..i.."_call"]
|
|
if callfunc then
|
|
callfunc()
|
|
end
|
|
end
|
|
self:Close()
|
|
end
|
|
end
|
|
for i, v in ipairs(self.huntBtn_list) do
|
|
AddClickEvent(v, OnItemClick)
|
|
end
|
|
|
|
local function OnBtnClick(target)
|
|
if target == self.mask_btn then
|
|
self:Close()
|
|
if self.maskBtn_call then
|
|
self.maskBtn_call()
|
|
end
|
|
end
|
|
end
|
|
AddClickEvent(self.mask_btn, OnBtnClick)
|
|
end
|
|
|
|
--[[
|
|
close_call 点击界面关闭后的回调函数
|
|
btn1_call 和 btn2_call 点击界面的两个按钮对应的函数
|
|
maskBtn_call 点击背景的对应函数
|
|
animEnd_call 在播放动画或者特效的结束之后的回调函数
|
|
parm_list 是一个表 里面可以传自己想要的参数
|
|
--]]
|
|
function CommonHuntResultView2:Open(target_list, close_call, btn1_call, btn2_call, maskBtn_call, animEnd_call, parm_list)
|
|
-- self.type = type
|
|
self.target_list = target_list or {}
|
|
self.close_call = close_call
|
|
self.btn1_call = btn1_call
|
|
self.btn2_call = btn2_call
|
|
self.maskBtn_call = maskBtn_call
|
|
self.animEnd_call = animEnd_call
|
|
self.parm_list = parm_list
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function CommonHuntResultView2:Close()
|
|
if self.close_call then
|
|
self.close_call()
|
|
end
|
|
BaseView.Close(self)
|
|
end
|
|
|
|
function CommonHuntResultView2:SetData()
|
|
self:SetReward()
|
|
self:AnalysicParmlist()
|
|
local delay = function ()
|
|
self:AddUIEffect("ui_accounts_gongxihuode",self.effect, self.layer_name, nil, 1, false,nil,nil,nil)
|
|
self:ClearTweenAnim()
|
|
for i,v in ipairs(self.reward_item_list) do
|
|
v:SetVisible(true)
|
|
end
|
|
local function callback()
|
|
if self.animEnd_call then
|
|
self.animEnd_call()
|
|
end
|
|
end
|
|
self.tween_id_1 = TweenLite.to(self, self.parentCon, TweenLite.UiAnimationType.SCALE, Vector3(1,1,1), 0.2,callback)
|
|
end
|
|
local evet = GlobalTimerQuest:AddPeriodQuest(delay,0.2,1)
|
|
table.insert(self.init_event,evet)
|
|
end
|
|
|
|
function CommonHuntResultView2:SetBtnView(btn1_txt, btn2_txt)
|
|
self.huntBtn_text_list[1].text = btn1_txt and btn1_txt or ""
|
|
self.huntBtn_text_list[2].text = btn2_txt and btn2_txt or ""
|
|
end
|
|
|
|
function CommonHuntResultView2:SetGradeShow(get_score_title, get_score_icon_ab, get_score_icon_res, score)
|
|
self.score_obj.transform:GetComponent("Text").text = get_score_title and get_score_title or ""
|
|
self.score_num.text = score and score or ""
|
|
if get_score_icon_ab and get_score_icon_res then
|
|
lua_resM:setImageSprite(self, self.icon, get_score_icon_ab, get_score_icon_res)
|
|
end
|
|
end
|
|
|
|
function CommonHuntResultView2:SetCostShow(cost_icon_ab, cost_icon_res, btn1_cost_txt, btn2_cost_txt)
|
|
if cost_icon_ab and cost_icon_res then
|
|
self.huntBtn_image_list[1].gameObject:SetActive(true)
|
|
self.huntBtn_image_list[2].gameObject:SetActive(true)
|
|
for i = 1, 2 do
|
|
lua_resM:setImageSprite(self, self.consumable_image_list[i], cost_icon_ab, cost_icon_res)
|
|
end
|
|
end
|
|
self.consumable_text_list[1].text = btn1_cost_txt and btn1_cost_txt or ""
|
|
self.consumable_text_list[2].text = btn2_cost_txt and btn2_cost_txt or ""
|
|
end
|
|
|
|
--外部资源的
|
|
function CommonHuntResultView2:SetCostShowOutSide(res_path,icon_size, btn1_cost_txt, btn2_cost_txt)
|
|
self.huntBtn_image_list[1].gameObject:SetActive(true)
|
|
self.huntBtn_image_list[2].gameObject:SetActive(true)
|
|
icon_size = icon_size or co.TableXY(35,38)
|
|
for i = 1, 2 do
|
|
self.consumable_image_list[i].transform.sizeDelta = Vector2(icon_size.x,icon_size.y)
|
|
lua_resM:setOutsideImageSprite(self,self.consumable_image_list[i],res_path,false)
|
|
end
|
|
|
|
self.consumable_text_list[1].text = btn1_cost_txt and btn1_cost_txt or ""
|
|
self.consumable_text_list[2].text = btn2_cost_txt and btn2_cost_txt or ""
|
|
end
|
|
|
|
function CommonHuntResultView2:SetReward()
|
|
-- if #self.target_list > 5 then
|
|
-- self.parent:GetComponent("ContentSizeFitter").enabled = true
|
|
-- end
|
|
local create_count = math.min(self.show_count, #self.target_list)
|
|
for k = 1, create_count do
|
|
local item = self.reward_item_list[k]
|
|
if item == nil then
|
|
item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.parent, nil, self.layer_name)
|
|
local id = self.target_list[k].type_id or self.target_list[k].typeId
|
|
local count = self.target_list[k].goods_num or self.target_list[k].count
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(id)
|
|
local spe_color
|
|
if basic and basic.color == 3 then
|
|
spe_color = 3
|
|
end
|
|
item:SetData(id, count, nil, nil, nil, nil, nil, nil, nil, nil, spe_color)
|
|
-- item:SetPosition(94*((k - 1)%5),math.floor((k - 1)/5) * -91)
|
|
self.reward_item_list[k] = item
|
|
item.gameObject:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
function CommonHuntResultView2:Remove()
|
|
self:ClearRewardShow()
|
|
|
|
self:ClearUIEffect(self.effect)
|
|
self:ClearUIEffect(self.effect1)
|
|
|
|
for i,v in ipairs(self.init_event) do
|
|
GlobalTimerQuest:CancelQuest(v)
|
|
end
|
|
self.init_event = nil
|
|
|
|
self:ClearTweenAnim()
|
|
end
|
|
|
|
--删除奖励
|
|
function CommonHuntResultView2:ClearRewardShow()
|
|
for k,v in pairs(self.reward_item_list) do
|
|
v:ReleaseObj()
|
|
v = nil
|
|
end
|
|
self.reward_item_list = {}
|
|
end
|
|
|
|
function CommonHuntResultView2:ClearTweenAnim( )
|
|
if self.tween_id_1 then
|
|
TweenLite.Stop(self.tween_id_1)
|
|
self.tween_id_1 = nil
|
|
end
|
|
end
|
|
|
|
function CommonHuntResultView2:AnalysicParmlist( )
|
|
if self.parm_list then
|
|
if self.parm_list.tag == "JoyWish" then
|
|
local data = self.parm_list
|
|
if data.btn_text_list then
|
|
|
|
end
|
|
if data.cost_data_list then
|
|
local cost = data.cost_data_list
|
|
self:SetCostShowOutSide(cost.res_path,cost.icon_size,cost.one_str,cost.ten_str)
|
|
end
|
|
|
|
if data.btn_list then
|
|
for k,image in pairs(self.draw_btn_iamge_list) do
|
|
lua_resM:setImageSprite(self,image,data.btn_list.abName,data.btn_list["resName"..k],false)
|
|
image.transform.sizeDelta = Vector2(data.btn_list.size.x,data.btn_list.size.y)
|
|
end
|
|
self:SetBtnView(data.btn_list.text1,data.btn_list.text2)
|
|
end
|
|
|
|
for _,v in pairs(self.huntBtn_text_list) do
|
|
v.gameObject:GetComponent("Outline").enabled = false
|
|
end
|
|
elseif self.parm_list.tag == "godhoodtower" then
|
|
self.huntBtn_list[1]:SetActive(false)
|
|
self.huntBtn_list[2]:SetActive(false)
|
|
end
|
|
|
|
|
|
end
|
|
end
|