源战役客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

223 rader
6.4 KiB

EquipCollectSuitTipView = EquipCollectSuitTipView or BaseClass(BaseView)
local EquipCollectSuitTipView = EquipCollectSuitTipView
--[[
EquipCollectSuitTipView.TabData = {
[1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
}
--]]
local table_insert = table.insert
function EquipCollectSuitTipView:__init()
self.base_file = "equipCollect"
self.layout_file = "EquipCollectSuitTipView"
self.layer_name = "UI"
self.destroy_imm = true
self.use_background = true --全屏界面默认使用这个参数
self.close_fog = true
--self.hide_maincancas = true --全屏界面需要放开隐藏主UI
self.change_scene_close = true
self.append_to_ctl_queue = false --是否要添加进界面堆栈
self.need_show_money = false --是否要显示顶部的金钱栏
self.item_list = {}
self.tween_list = {}
self.timer_list = {}
self.close_time = 10
self.model = EquipCollectModel:getInstance()
self.item_posy = {
[1] = -415,
[2] = -194,
[3] = -391,
[4] = -194,
[5] = -299,
[6] = -391,
[7] = -299,
}
self.load_callback = function ()
self:LoadSuccess()
self:AddEvent()
end
self.open_callback = function ( )
self:OpenSuccess()
end
self.switch_callback = function(index)
self:SwitchTab(index)
end
self.destroy_callback = function ( )
self:DestroySuccess()
end
end
function EquipCollectSuitTipView:Open(data)
self.data = data
BaseView.Open(self)
end
function EquipCollectSuitTipView:LoadSuccess()
local nodes = {
"item2", "item1", "item5", "item6", "bg:raw", "btn/btn_text:tmp", "btn:obj", "item7", "item3", "role_con", "item4",
"time_text:tmp", "color_image:img",
}
self:GetChildren(nodes)
lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("equipcollect_suit_tip_bg"),false)
local function bg_back_func( ... )
if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
end
self:MoveUIToBack(self.bg_raw)
end
if self.background_wnd then
bg_back_func()
else
self.bg_back_func = bg_back_func
end
end
function EquipCollectSuitTipView:AddEvent()
local function on_click( )
self:Close()
self.model:Fire(EquipCollectConst.OPEN_EC_MAIN_VIEW, true, EquipCollectConst.TAB_ID.COLLECT, self.data.id, self.sub_id, self.sub_id)
end
AddClickEvent(self.btn_obj, on_click)
end
function EquipCollectSuitTipView:OpenSuccess()
self:UpdateView()
end
--图片上下移动
function EquipCollectSuitTipView:ArrowAnimation(index,time)
if index then
local call_fun = function ()
local function onCompleted()
self:ArrowAnimation(index, 0.01)
end
table.insert(self.tween_list, TweenLite.to(self, self["item"..index].transform,TweenLite.UiAnimationType.ANCHORED_POSY,self.item_posy[index] + 5,1.2,onCompleted))
end
local onDelay = function( )
table.insert(self.tween_list, TweenLite.to(self, self["item"..index].transform,TweenLite.UiAnimationType.ANCHORED_POSY,self.item_posy[index] - 25,1.2,call_fun))
end
table.insert(self.timer_list, setTimeout(onDelay, 0.01))
else
for i=1,7 do
time = 0.05 * i
local call_fun = function ()
local function onCompleted()
self:ArrowAnimation(i, time)
end
table.insert(self.tween_list, TweenLite.to(self, self["item"..i].transform,TweenLite.UiAnimationType.ANCHORED_POSY,self.item_posy[i] + 5,1.2,onCompleted))
end
local onDelay = function( )
table.insert(self.tween_list, TweenLite.to(self, self["item"..i].transform,TweenLite.UiAnimationType.ANCHORED_POSY,self.item_posy[i] - 25,1.2,call_fun))
end
table.insert(self.timer_list, setTimeout(onDelay, time))
end
end
end
--停止动画
function EquipCollectSuitTipView:StopAnim()
for i,v in ipairs(self.tween_list) do
TweenLite.Stop(v)
end
self.tween_list = {}
for i,v in ipairs(self.timer_list) do
GlobalTimerQuest:CancelQuest(v)
end
self.timer_list = {}
end
function EquipCollectSuitTipView:UpdateView()
local server_data = self.model:GetEquipCollectInfo(self.data.id)
local bool = false
--构造一个7个装备的数据
local data = {}
local temp_server_data = {}
for i=1,7 do
data[i] = {
type_id = 0,
pos_id = i,
}
end
for i,v in pairsByKeys(server_data) do
if TableSize(v) == 7 then--满足7件
bool = bool or not self.model:CheckIsAllEquipCollected(self.data.id, i)--并且没领奖励
temp_server_data = bool and v or temp_server_data
self.sub_id = bool and i or self.sub_id
end
end
for i,v in ipairs(temp_server_data) do
data[i].type_id = v
end
local str = string.format("equipcollect_tip%s%s", self.data.id, self.sub_id or self.data.sub_id)
lua_resM:setImageSprite(self, self.color_image_img, "equipCollectOut_asset", str, false)
for i,v in ipairs(data) do
local item = self.item_list[i]
if not item then
item = EquipCollectTipItem.New(self["item"..i])
self.item_list[i] = item
end
item:SetData(v, "suit_view")
item:SetPosition(-14, 0)
end
self:UpdateModel()
self.model:CleanEquipCollectNeedShowTipData()
self:ArrowAnimation()
self:StartCloseTimer()
end
function EquipCollectSuitTipView:SwitchTab( index )
end
function EquipCollectSuitTipView:StartCloseTimer( )
local end_time = self.close_time + TimeUtil:getServerTime()
local function hide_timer()
local left_time = end_time - TimeUtil:getServerTime()
if left_time <= 0 then
self:Close()
self.model:Fire(EquipCollectConst.OPEN_EC_MAIN_VIEW, true, EquipCollectConst.TAB_ID.COLLECT, self.data.id, self.sub_id, self.sub_id)
end
self.time_text_tmp.text = string.format("%s 秒后自动关闭页面", HtmlColorTxt(left_time, ColorUtil.GREEN_DARK))
end
hide_timer()
if not self.hide_timer_id then
self.hide_timer_id = GlobalTimerQuest:AddPeriodQuest(hide_timer, 0.1, -1)
end
end
function EquipCollectSuitTipView:ClearHideTimer( )
if self.hide_timer_id then
GlobalTimerQuest:CancelQuest(self.hide_timer_id)
self.hide_timer_id = nil
end
end
function EquipCollectSuitTipView:DestroySuccess( )
for i,v in ipairs(self.item_list) do
v:DeleteMe()
v = nil
end
self.item_list = {}
self:StopAnim()
self:ClearHideTimer()
end
function EquipCollectSuitTipView:UpdateModel( )
local res_data = {
father_node = self,
transform = self.role_con,
fashion_type = FuncOpenModel.TypeId.Clothes,
scale = 200,
ui_model_type = UIModelCommon.ModelType.BackModel,
layer_name = self.layer_name,
position = Vector2(0, 60+(ScreenHeight-720)/2),
}
FuncOpenModel:getInstance():SetModelRes(res_data)
end
function EquipCollectSuitTipView:ReOpen( data )
self.data = data
self:UpdateView()
end