|
|
- -- <*
- -- @Author: Saber
- -- @Description: 藏宝图 玩法介绍界面
- -- *>
- TreasureMapDescView = TreasureMapDescView or BaseClass(BaseView)
- local TreasureMapDescView = TreasureMapDescView
- local SetAnchoredPositionX = SetAnchoredPositionX
-
- function TreasureMapDescView:__init()
- self.base_file = "treasureMap"
- self.layout_file = "TreasureMapDescView"
- self.layer_name = "UI"
- self.destroy_imm = true
- self.use_background = true --全屏界面默认使用这个参数,非全屏界面自行设置
- self.hide_maincancas = false --全屏界面需要隐藏主UI
- self.change_scene_close = true --是否切换场景时关闭(弹出界面使用)
- self:AddPreLoadList("treasureMap", {"TreasureMapDescScrollItem"})
- self.model = TreasureMapModel: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 TreasureMapDescView:Open( )
- BaseView.Open(self)
- end
-
- function TreasureMapDescView:LoadSuccess()
- local nodes = {
- "bg_mask",
- -- 类型1相关
- "bg_mask/bg_type1:raw",
- "bg_mask/bg_type1/desc_scroll_1",
- "bg_mask/bg_type1/desc_scroll_1/Viewport/desc_con_1",
- "bg_mask/bg_type1/item_scroll_1",
- "bg_mask/bg_type1/item_scroll_1/Viewport/item_con_1",
- "bg_mask/bg_type1/reward_btn1:obj", "bg_mask/bg_type1/tm_mys_desc_btn:obj",
- -- 类型2相关
- "bg_mask/bg_type2:raw",
- "bg_mask/bg_type2/desc_scroll_2",
- "bg_mask/bg_type2/desc_scroll_2/Viewport/desc_con_2",
- "bg_mask/bg_type2/item_scroll_2",
- "bg_mask/bg_type2/item_scroll_2/Viewport/item_con_2",
- "bg_mask/bg_type2/reward_btn2:obj", "bg_mask/bg_type2/feed_back_btn:obj", "bg_mask/bg_type2/feedback_red:obj",
- "bg_mask/bg_type2/feed_back_tip_bg:obj",
- "bg_mask/bg_type2/feed_back_tip_bg/feed_back_tip_lb:tmp",
- -- 其他
- "bg_roll:raw",
- "close_btn:obj",
- }
- self:GetChildren(nodes)
- -- 暂时屏蔽
- self.feed_back_tip_bg_obj:SetActive(false)
- lua_resM:setOutsideRawImage(self, self.bg_roll_raw, GameResPath.GetViewBigBg("tm_desc_bg0"))
- lua_resM:setOutsideRawImage(self, self.bg_type1_raw, GameResPath.GetViewBigBg("tm_desc_bg1"))
- lua_resM:setOutsideRawImage(self, self.bg_type2_raw, GameResPath.GetViewBigBg("tm_desc_bg2"))
- end
-
- function TreasureMapDescView:AddEvent()
- local function click_event(target)
- if target == self.close_btn_obj then
- self:Close()
- elseif target == self.reward_btn1_obj then -- 奖励预览(普通)
- self.model:Fire(TreasureMapConst.OPEN_REWARD_PERVIEW_VIEW, true, 1)
- elseif target == self.reward_btn2_obj then -- 奖励预览(高级)
- self.model:Fire(TreasureMapConst.OPEN_REWARD_PERVIEW_VIEW, true, 2)
- elseif target == self.tm_mys_desc_btn_obj then -- 秘闻说明
- GlobalEventSystem:Fire(EventName.OPEN_INSTRUCTION_VIEW, 42400)
- elseif target == self.feed_back_btn_obj then -- 遗宝回馈界面
- self.model:Fire(TreasureMapConst.OPEN_FEEDBACK_VIEW, true)
- end
- end
- AddClickEvent(self.close_btn_obj, click_event)
- AddClickEvent(self.reward_btn1_obj, click_event)
- AddClickEvent(self.reward_btn2_obj, click_event)
- AddClickEvent(self.tm_mys_desc_btn_obj, click_event)
- AddClickEvent(self.feed_back_btn_obj, click_event)
-
- local function updateFeedbackRed(red_type)
- if red_type and red_type == TreasureMapConst.RedType.MonthReward then
- self:UpdateFeedbackRed()
- end
- end
- self:BindEvent(self.model, TreasureMapConst.UPDATE_TREASUREMAP_RED, updateFeedbackRed)
- end
-
- function TreasureMapDescView:UpdateView()
- self:ShowOpenAnim()
- self:UpdateTypeOneDesc()
- self:UpdateTypeTwoDesc()
- self:UpdateFeedbackRed()
- end
-
- -- 播放打开动画
- function TreasureMapDescView:ShowOpenAnim( )
- SetAnchoredPositionX(self.bg_roll, 0)
- SetAnchoredPositionX(self.bg_mask, 522)
- SetAnchoredPositionX(self.bg_type1, -906)
- SetAnchoredPositionX(self.bg_type2, -906)
- -- 通用等待
- local show_delay = cc.DelayTime.New(0.3)
- -- 主卷轴动画
- local roll_action_func = function(percent)
- SetAnchoredPositionX(self.bg_roll, -415 * percent)
- end
- local roll_action = cc.Sequence.New(show_delay, cc.CustomUpdate.New(0.3, roll_action_func))
- cc.ActionManager:getInstance():addAction(roll_action, self.bg_roll)
- -- 蒙版动画
- local mask_action_func = function(percent)
- SetAnchoredPositionX(self.bg_mask, 71 + 451 * (1 - percent))
- end
- local mask_action = cc.Sequence.New(show_delay, cc.CustomUpdate.New(0.3, mask_action_func))
- cc.ActionManager:getInstance():addAction(mask_action, self.bg_mask)
- -- 两个卷轴
- local type_action_func = function(percent)
- SetAnchoredPositionX(self.bg_type1, -906 * (1 - percent))
- SetAnchoredPositionX(self.bg_type2, -906 * (1 - percent))
- end
- local type_action = cc.Sequence.New(show_delay, cc.CustomUpdate.New(0.3, type_action_func))
- cc.ActionManager:getInstance():addAction(type_action, self.bg_type1)
- end
-
- -- 更新类型1描述说明
- function TreasureMapDescView:UpdateTypeOneDesc( )
- -- 加载描述内容
- self.type1_item_list = self.type1_item_list or {}
- local desc_data = {}
- desc_data[#desc_data+1] = {title = "来源:"}
- desc_data[#desc_data+1] = {
- desc1 = "1.常用商店购买", click_callback_desc = "<u>去购买</u>", click_callback = function()
- OpenFun.Open(153, 5)
- end,
- }
- desc_data[#desc_data+1] = {
- desc1 = "2.每日活跃产出", click_callback_desc = "<u>提升活跃</u>", click_callback = function()
- OpenFun.Open(157, 0)
- end,
- }
- desc_data[#desc_data+1] = {desc1 = "3.运营活动产出", height_offset = 10,}
- desc_data[#desc_data+1] = {title = "使用说明:"}
- local max_num = self.model:GetTreasureMapKvCfg("map_times_max").value
- desc_data[#desc_data+1] = {desc2 = string.format("在背包点击后会自动寻路至宝藏地点,寻宝过程中可能会出现<color=#fdffc2>神秘老人</color>、<color=#fdffc2>珍品之门</color>和<color=#fdffc2>宝藏看守者</color>等<color=#fdffc2>藏宝秘闻</color>事件\n每日使用上限%s张",
- max_num)}
- self:UpdateDescContent(self.type1_item_list, desc_data, self.desc_con_1)
- -- 加载奖励
- local reward_data = stringtotable(self.model:GetTreasureMapKvCfg("common_map_show").value)
- self:UpdateRewardItems("type1_reward_list", reward_data, self.item_scroll_1, self.item_con_1)
- end
-
- -- 更新类型2描述说明
- function TreasureMapDescView:UpdateTypeTwoDesc( )
- -- 加载描述内容
- self.type2_item_list = self.type2_item_list or {}
- local desc_data = {}
- desc_data[#desc_data+1] = {title = "来源:"}
- desc_data[#desc_data+1] = {
- desc1 = "1.常用商店购买", click_callback_desc = "<u>去购买</u>", click_callback = function()
- OpenFun.Open(153, 5)
- end,
- }
- desc_data[#desc_data+1] = {desc1 = "2.运营活动产出", height_offset = 10,}
- desc_data[#desc_data+1] = {title = "使用说明:"}
- local max_num = self.model:GetTreasureMapKvCfg("map_times_max").value
- desc_data[#desc_data+1] = {desc2 = string.format("在背包点击后会自动寻路至含有<color=#fdffc2>高级珍品</color>的宝藏地点,寻宝一定次数可获得<color=#fdffc2>遗迹的馈赠</color>,每日寻宝一定次数可触发大奖概率UP\n每日使用上限%s张",
- max_num)}
- self:UpdateDescContent(self.type2_item_list, desc_data, self.desc_con_2)
- -- 加载奖励
- local reward_data = stringtotable(self.model:GetTreasureMapKvCfg("advanced_map_show").value)
- self:UpdateRewardItems("type2_reward_list", reward_data, self.item_scroll_2, self.item_con_2)
- end
-
- -- 加载描述内容
- function TreasureMapDescView:UpdateDescContent(item_list, data, con)
- for k, v in ipairs(item_list) do
- v:SetVisible(false)
- end
- local height = 2
- local item
- for k, v in ipairs(data) do
- item = item_list[k] or TreasureMapDescScrollItem.New(con)
- item:SetAnchoredPosition(0, -height)
- height = height + item:SetData(v)
- end
- SetSizeDeltaY(con, height)
- end
-
- -- 加载奖励内容
- function TreasureMapDescView:UpdateRewardItems(ilc_name, data, scroll, con)
- self[ilc_name] = self[ilc_name] or self:AddUIComponent(UI.ItemListCreator)
- local info = {
- data_list = data,
- scroll_view = scroll,
- item_con = con,
- obj_pool_type = UIObjPool.UIType.AwardItem,
- item_width = 48,
- item_height = 48,
- start_x = 8,
- start_y = -5,
- space_x = 12,
- space_y = 9,
- create_frequency = 0.01,
- alignment = UnityEngine.TextAnchor.UpperLeft,
- on_update_item = function(item, i, v)
- item:SetData(v)
- item:SetIsFixSize(false)
- item:SetItemSize(48, 48)
- end,
- }
- self[ilc_name]:UpdateItems(info)
- end
-
- function TreasureMapDescView:UpdateFeedbackRed( )
- self.feedback_red_obj:SetActive(self.model:GetTreasureMapRed(TreasureMapConst.RedType.MonthReward))
- end
-
- function TreasureMapDescView:DestroySuccess( )
- cc.ActionManager:getInstance():removeAllActionsFromTarget(self.bg_roll)
- cc.ActionManager:getInstance():removeAllActionsFromTarget(self.bg_mask)
- cc.ActionManager:getInstance():removeAllActionsFromTarget(self.bg_type1)
-
- for k, v in pairs(self.type1_item_list) do
- v:DeleteMe()
- v = nil
- end
- self.type1_item_list = nil
-
- for k, v in pairs(self.type2_item_list) do
- v:DeleteMe()
- v = nil
- end
- self.type2_item_list = nil
- end
|