--[[@------------------------------------------------------------------
|
|
@description:首充小弹窗
|
|
@author:huangcong
|
|
----------------------------------------------------------------------]]
|
|
FirstRechargeTipView = FirstRechargeTipView or BaseClass(BaseView)
|
|
local FirstRechargeTipView = FirstRechargeTipView
|
|
|
|
function FirstRechargeTipView:__init()
|
|
self.base_file = "rechargeActivity"
|
|
self.layout_file = "FirstRechargeTipView"
|
|
self.layer_name = "Activity"
|
|
self.destroy_imm = true
|
|
self.use_background = false
|
|
self.change_scene_close = false
|
|
self.append_to_ctl_queue = false --是否要添加进界面堆栈
|
|
self.need_show_money = false --是否要显示顶部的金钱栏
|
|
self.force_no_ctl_queue = true
|
|
self.item_list = {}
|
|
self.model = RechargeActivityModel:getInstance()
|
|
self.mainVo = RoleManager.Instance.mainRoleInfo
|
|
self.show_type = 0
|
|
self.cur_visible = true
|
|
self.delay_time = 20---20s自动关闭
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:OpenSuccess()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function FirstRechargeTipView:Open(data)
|
|
self.data = data
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function FirstRechargeTipView:OpenSuccess( )
|
|
self:UpdateView()
|
|
end
|
|
|
|
function FirstRechargeTipView:LoadSuccess()
|
|
local nodes = {
|
|
"layout/Panel/closeBtn:obj", "layout/Panel/bg:raw", "layout/Panel/rechargeBtn:obj"
|
|
,"layout/Panel/roleCon", "layout","layout/Panel","layout/Panel/effect",
|
|
"layout/Panel/effect1",
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetRechargeActivityImage("recharge_sub_bg"))
|
|
|
|
if self.need_load_again then
|
|
self:UpdateView()
|
|
end
|
|
local pos = ActivityIconManager.Instance:GetActivityIconPos(15901)
|
|
if pos and pos.x then
|
|
self.layout.anchoredPosition = Vector3(pos.x-360+45,pos.y-225,0)
|
|
self.layout.gameObject:SetActive(true)
|
|
end
|
|
self:ClearUIEffect(self.effect)
|
|
self:ClearUIEffect(self.effect1)
|
|
self:AddUIEffect("ui_shouchongtanchuang_2", self.effect, "Top", nil, 1, false,nil,nil,nil,nil,nil)
|
|
-- local function load_finish_func( go )
|
|
-- self:SetUIDepthEx(go,true,610)
|
|
-- end
|
|
-- self:AddUIEffect("ui_shouchongtanchuang_1", self.effect1, "Activity", nil, 1, true,nil,nil,nil,load_finish_func)
|
|
self:UpdateTime()
|
|
end
|
|
|
|
function FirstRechargeTipView:AddEvent()
|
|
local on_click = function ( click_obj )
|
|
if self.closeBtn_obj == click_obj then
|
|
self:StartAction()
|
|
elseif self.rechargeBtn_obj == click_obj then
|
|
self:StartAction()
|
|
OpenFun.Open(159,1)
|
|
end
|
|
end
|
|
AddClickEvent(self.closeBtn_obj, on_click)
|
|
AddClickEvent(self.rechargeBtn_obj, on_click)
|
|
|
|
local function onUpdateMainCanvasVisible(view, visible)
|
|
if visible then
|
|
self:Close()
|
|
end
|
|
end
|
|
self:BindEvent(LuaViewManager:getInstance(), LuaViewManager.CHANGE_MAIN_CANVAS_VISIBLE, onUpdateMainCanvasVisible)--更新红点顺便更新界面
|
|
end
|
|
|
|
function FirstRechargeTipView:UpdateView()
|
|
if not self.is_loaded then
|
|
self.need_load_again = true
|
|
return
|
|
end
|
|
local show_str = RechargeActivityModel.FIRST_RECHARGE_PRODUCKT_ID .. "@" .. RoleManager.Instance.mainRoleInfo.career .. "@" ..1
|
|
local show_cfg = DeepCopy(Config.Rechargefirst[show_str])
|
|
print("huangcong:FirstRechargeTipView [start:101] 111:", 111)
|
|
if show_cfg then
|
|
self:UpdateModelCon(show_cfg.right_res)
|
|
end
|
|
end
|
|
|
|
function FirstRechargeTipView:DestroySuccess( )
|
|
self:ClearUIEffect(self.effect1)
|
|
self:ClearUIEffect(self.effect)
|
|
self:StopAction()
|
|
if self.timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.timer_id)
|
|
self.timer_id = nil
|
|
end
|
|
end
|
|
|
|
--更新模型
|
|
function FirstRechargeTipView:UpdateModelCon( model_data )
|
|
local model_data = stringtotable(model_data)
|
|
local figure_data = nil
|
|
if model_data then
|
|
figure_data = model_data[1]
|
|
end
|
|
if figure_data then
|
|
local model_cfg = CustomActivityModel:getInstance():GetActModelConShowCfg(self.base_type,tonumber(figure_data[3]),tonumber(figure_data[4]))
|
|
local scale = 150
|
|
local position = model_cfg and model_cfg.position or Vector3(0,20,-300)
|
|
local fashion_type = tonumber(figure_data[3])
|
|
local career = RoleManager.Instance.mainRoleInfo.career
|
|
if fashion_type == FuncOpenModel.TypeId.FWeapon then--武器位置调高一点
|
|
scale = 220
|
|
position = Vector3(-15,45,-300)
|
|
if career == 3 or career == 4 then
|
|
scale = 330
|
|
position = Vector3(20,-55,-300)
|
|
end
|
|
end
|
|
if figure_data[1] == "show" then
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self.roleCon,
|
|
fashion_type = tonumber(figure_data[3]),
|
|
raycast_size = Vector2(200,200),
|
|
scale = scale,
|
|
figure_id = figure_data[4],
|
|
position = position,
|
|
layer_name = self.layer_name,
|
|
ui_model_type = UIModelCommon.ModelType.Model,
|
|
show_shadow = false,
|
|
use_bloom = false,
|
|
can_rotate = true,
|
|
}
|
|
print("huangcong:FirstRechargeTipView [start:361] :", model_data)
|
|
PrintTable(model_data)
|
|
print("huangcong:FirstRechargeTipView [end]")
|
|
if TableSize(model_data) > 1 then
|
|
local career = self.mainVo.career
|
|
for i,v in ipairs(model_data) do
|
|
local fashion_type = tonumber(v[3])
|
|
local figure_id = tonumber(v[4])
|
|
if figure_id then
|
|
if type_pos ~= FashionPartPos.wing and type_pos ~= FashionPartPos.Hat and type_pos ~= FashionPartPos.light then
|
|
if career then
|
|
if figure_id < 1000 then
|
|
figure_id = figure_id + career * 1000
|
|
end
|
|
end
|
|
else
|
|
figure_id = figure_id
|
|
end
|
|
end
|
|
if fashion_type == FuncOpenModel.TypeId.Clothes then --衣服
|
|
res_data.fashion_model_id = figure_id
|
|
elseif fashion_type == FuncOpenModel.TypeId.Weapon then --武器
|
|
res_data.weapon_res_id = figure_id
|
|
elseif fashion_type == FuncOpenModel.TypeId.Head then --头饰
|
|
res_data.head_wear_id = figure_id
|
|
elseif fashion_type == FuncOpenModel.TypeId.Footprint then --足迹
|
|
type_pos = FashionPartPos.Footmark
|
|
elseif fashion_type == FuncOpenModel.TypeId.wing then --背部
|
|
res_data.wing_id = figure_id
|
|
elseif fashion_type == FuncOpenModel.TypeId.Hat then--头套
|
|
res_data.hat_wear_id = figure_id
|
|
elseif fashion_type == FuncOpenModel.TypeId.RoleLight then--人物幻光
|
|
res_data.light_id = figure_id
|
|
end
|
|
end
|
|
end
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
else
|
|
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
function FirstRechargeTipView:UpdateTime( )
|
|
local time = self.delay_time
|
|
local function countDown()
|
|
if self._use_delete_method then return end
|
|
time = time - 1
|
|
if time > 0 then
|
|
else
|
|
-- self:Close()
|
|
self:StartAction()
|
|
end
|
|
end
|
|
countDown()
|
|
if not self.timer_id then
|
|
self.timer_id = GlobalTimerQuest:AddPeriodQuest(countDown,1)
|
|
end
|
|
end
|
|
|
|
function FirstRechargeTipView:StartAction( )
|
|
-- self.layout.transform.pivot = Vector2(1, 1)
|
|
-- self.layout.transform.anchorMin = Vector2(1, 1)
|
|
-- self.layout.transform.anchorMax = Vector2(1, 1)
|
|
local function end_func()
|
|
self:Close()
|
|
end
|
|
local action1 = cc.ScaleTo.New(0.2,0.1,0.1,0.1)
|
|
local action = cc.Sequence.New(action1,cc.CallFunc.New(end_func))
|
|
cc.ActionManager:getInstance():addAction(action, self.Panel.transform)
|
|
end
|
|
|
|
function FirstRechargeTipView:StopAction( )
|
|
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.Panel.transform)
|
|
end
|