|
SwallowView = SwallowView or BaseClass(BaseItem)
|
|
local SwallowView = SwallowView
|
|
|
|
function SwallowView:__init()
|
|
self.base_file = "bag"
|
|
self.layout_file = "SwallowView"
|
|
|
|
self.column_num = 4 --一行几个图标
|
|
self.defult_slot = 24 --默认最少生成空格数
|
|
self.equips_list = {} --装备列表
|
|
self.equips_count = 0 --装备数量
|
|
|
|
self.progressing_fun_queue = {} --吞噬进度条的执行方法队列
|
|
self.progressing_time = 0.4 --吞噬进度条跑完一次需要的时间
|
|
|
|
self.full_screen = true
|
|
self.ani_right = 400
|
|
self.ani_left = -200
|
|
self.adjust_mid = {left = 160, right = 780}
|
|
|
|
self.bag_item_list = {} --背包物品列表
|
|
|
|
self.core_attr_item_list = {} --特殊属性条
|
|
|
|
self.timer_id_list = {}
|
|
|
|
self.model = BagModel:getInstance()
|
|
|
|
self.model.need_sort_bag = false --是否需要在关闭界面后重整背包(只在吞噬操作后才进行重整)
|
|
|
|
self.loop_mgr = LoopScrowViewMgr.New()
|
|
|
|
--吞噬红点当次登录只给一次,打开界面后就取消掉
|
|
if self.model:GetSwallowRedDot() then
|
|
self.model.is_check_swallow_red = false--一次性红点先取消了
|
|
self.model:CheckEquipSwallowRed()
|
|
GlobalEventSystem:Fire(EventName.UPDATE_BAG_RED)
|
|
-- self.model:Fire(BagModel.ANS_UPDATE_EQUIP_RED)
|
|
end
|
|
self.fly_shoes_id = BagModel.FlyGoodsID
|
|
self:Load()
|
|
end
|
|
|
|
function SwallowView:Open( )
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function SwallowView:Load_callback()
|
|
local nodes = {
|
|
"right/swallowBtn:obj", --吞噬按钮
|
|
"right/tipsBtn:obj", --帮助按钮
|
|
"progressBg/progressBar:img",--进度条
|
|
"right/equipScroll/Viewport/Content_equip", "right/equipScroll", --装备滚动列表
|
|
"right/equipScroll/Viewport/Content_equip/con_equip",
|
|
"attrCon",
|
|
"attrCon/attr2:tmp","attrCon/attr1:tmp",--属性
|
|
"progressExpNum:tmp",--经验进度
|
|
"coreAttrCon:obj",
|
|
"swallowLv:tmp",--等级
|
|
"right/swallowCheck:obj", "right/swallowCheck/checkmark:obj", --勾选普通装备
|
|
"right/swallowAuto:obj", "right/swallowAuto/automark:obj", --勾选自动吞噬
|
|
"coreBigIcon:raw",
|
|
"attrCon/attrArrow2:obj","attrCon/attrArrow1:obj",
|
|
"right/bag_bg:img",
|
|
"progressBg/progressHandle",
|
|
"effectCon:obj",
|
|
"flyCon",
|
|
"swallowEffect",
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
lua_resM:setImageSprite(self, self.bag_bg_img, "bagSwallow_asset","bag_swallow_bag_bg")
|
|
lua_resM:setOutsideRawImage(self,self.coreBigIcon_raw,GameResPath.GetViewBigBg("bag_swallow_bg"))
|
|
|
|
self.swallowCheck_toggle = self.swallowCheck:GetComponent("Toggle")
|
|
self.swallowAuto_toggle = self.swallowAuto:GetComponent("Toggle")
|
|
|
|
self.swallowAuto_toggle.isOn = self.model.is_auto_swallow
|
|
|
|
SetAnchoredPositionX(self.attrCon,-195)
|
|
|
|
self:AddEvent()
|
|
|
|
if self.need_refreshData then
|
|
self:UpdateView()
|
|
self:AddUIEffect("ui_heidong", self.effectCon, "Scene", nil, 4.5, true, nil, false)
|
|
end
|
|
end
|
|
|
|
function SwallowView:AddEvent()
|
|
local on_click = function ( click_obj )
|
|
if self.swallowBtn_obj == click_obj then -- 开始吞噬
|
|
self:BeginSwallow()
|
|
elseif self.tipsBtn_obj == click_obj then -- 帮助按钮
|
|
EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, 15001)
|
|
elseif self.swallowCheck_obj == click_obj then -- 勾选普通
|
|
self:SelectEquip()
|
|
elseif self.swallowAuto_obj == click_obj then -- 自动吞噬
|
|
self.model.set_auto_swallow = true
|
|
self.model:Fire(BagModel.REQUEST_PROTOCOL,15025,self.swallowAuto_toggle.isOn and 1 or 0)
|
|
end
|
|
end
|
|
AddClickEvent(self.swallowBtn_obj, on_click)
|
|
AddClickEvent(self.tipsBtn_obj, on_click)
|
|
AddClickEvent(self.swallowCheck_obj, on_click)
|
|
AddClickEvent(self.swallowAuto_obj, on_click)
|
|
|
|
|
|
local function clickBagIcon(type, type_id, index, bool)
|
|
if type == GoodsModel.TYPE.EQUIP or type_id == self.fly_shoes_id then
|
|
self.equips_list[index].isSelect = bool
|
|
self:ShowSwallowExp()
|
|
end
|
|
end
|
|
self:BindEvent(self.model,BagModel.CLICK_EQUIP_ITEM,clickBagIcon)
|
|
|
|
local function Refresh_Init()
|
|
-- self:UpdateView(true,true)
|
|
self:UpdateShow(true,true)
|
|
end
|
|
self:BindEvent(self.model,BagModel.REFRESH_SWALLOW_INIT,Refresh_Init)
|
|
|
|
-- --点击切换法核时候,需要高亮展示相应的特殊属性已经切换到法核模型
|
|
-- local function switch_core_show_handler(index)
|
|
-- for i,v in ipairs(self.core_attr_item_list) do
|
|
-- v:SetSelected(i == index)
|
|
-- end
|
|
-- self:UpdateCoreShow(index)
|
|
-- end
|
|
-- self:BindEvent(self.model,BagModel.CLICK_SWALLOW_CORE_ITEM,switch_core_show_handler)
|
|
|
|
local function update_suto_swallow_state(bool)
|
|
self.swallowAuto_toggle.isOn = bool
|
|
end
|
|
self:BindEvent(self.model,BagModel.UPDATE_AUTO_SWALLOW_STATE,update_suto_swallow_state)
|
|
end
|
|
|
|
function SwallowView:UpdateView(need_anim,bool)
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
self:AddUIEffect("ui_heidong", self.effectCon, "Scene", nil, 4.5, true, nil, false,nil,nil,nil)
|
|
|
|
self:UpdateShow(need_anim,bool)
|
|
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function SwallowView:UpdateShow(need_anim,bool)
|
|
--刷新法核解锁属性
|
|
if not need_anim then
|
|
self:UpdateCoreAttr()
|
|
end
|
|
--刷新吞噬进度
|
|
self:UpdateSwallowProgress(need_anim)
|
|
--刷新装备列表
|
|
self:UpdateEquipScroll()
|
|
end
|
|
|
|
-- --刷新法核滚动列表(这玩意不要了,但是不晓得后面会不会加回来)
|
|
-- function SwallowView:UpdateCoreScroll(bool )
|
|
-- local cfg = self.model:GetSwallowCoreCfg()
|
|
-- if not self.item_list_com then
|
|
-- self.item_list_com = self:AddUIComponent(UI.ItemListCreator)
|
|
-- end
|
|
-- local info = {
|
|
-- data_list = cfg,
|
|
-- item_con = self.Content_core,
|
|
-- item_class = SwallowCoreItem,
|
|
-- item_width = 100,
|
|
-- space_x = 2,
|
|
-- start_x = 5,
|
|
-- start_y = -14,
|
|
-- scroll_view = self.coreScroll,
|
|
-- create_frequency = 0.01,
|
|
-- reuse_item_num = 6,
|
|
-- on_update_item = function(item, i, v)
|
|
-- item:SetData(v,i,#cfg)
|
|
-- end,
|
|
-- final_callback = function()
|
|
-- local now_item_id = self.model:GetNowSwallowCoreItemId()
|
|
-- self.item_list_com:IterateItems(function( item, i )
|
|
-- self.model.now_select_core_item_id = now_item_id
|
|
-- self.model:Fire(BagModel.CLICK_SWALLOW_CORE_ITEM,now_item_id)
|
|
-- end)
|
|
-- if now_item_id >5 then
|
|
-- self.item_list_com:ScrollToItem(now_item_id)
|
|
-- end
|
|
-- end,
|
|
-- }
|
|
-- self.item_list_com:UpdateItems(info)
|
|
-- if bool then
|
|
-- local now_item_id = self.model:GetNowSwallowCoreItemId()
|
|
-- self.item_list_com:IterateItems(function( item, i )
|
|
-- self.model.now_select_core_item_id = now_item_id
|
|
-- self.model:Fire(BagModel.CLICK_SWALLOW_CORE_ITEM,now_item_id)
|
|
-- end)
|
|
-- if now_item_id >5 then
|
|
-- self.item_list_com:ScrollToItem(now_item_id)
|
|
-- end
|
|
-- end
|
|
-- end
|
|
|
|
-- --刷新法核展示
|
|
-- function SwallowView:UpdateCoreShow(index)
|
|
-- local core_cfg, cur
|
|
-- if index then
|
|
-- core_cfg = self.model:GetSwallCoreCfgByLv(index)
|
|
-- cur = index
|
|
-- else
|
|
-- core_cfg, cur = self.model:GetNowSwallowCoreCfg()
|
|
-- end
|
|
-- end
|
|
|
|
--刷新法核解锁属性
|
|
function SwallowView:UpdateCoreAttr( )
|
|
local cfg = self.model:GetSwallowCoreCfg()
|
|
if cfg then
|
|
for k,v in pairs(self.core_attr_item_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
for i,v in ipairs(cfg) do
|
|
local item = self.core_attr_item_list[i]
|
|
if not item then
|
|
item = SwallowCoreAttrItem.New(self.coreAttrCon)
|
|
self.core_attr_item_list[i] = item
|
|
end
|
|
item:SetVisible(true)
|
|
item:SetData(v,i)
|
|
end
|
|
end
|
|
end
|
|
|
|
--刷新吞噬进度
|
|
function SwallowView:UpdateSwallowProgress(need_anim)
|
|
local is_up = self.model.swallow_lv > self.model.pre_swallow_lv
|
|
local up_lv_num = self.model.swallow_lv - self.model.pre_swallow_lv
|
|
|
|
--经验进度条
|
|
local endValue = 0
|
|
local lv_cfg = Config.Goodsdevour[self.model.swallow_lv]
|
|
local next_lv_cfg = Config.Goodsdevour[self.model.swallow_lv+1]
|
|
if lv_cfg then
|
|
if not next_lv_cfg then
|
|
self.swallowLv_tmp.text = string.format("Lv.%s",self.model.swallow_lv)
|
|
-- self.progressExpNum_tmp.text = "满级了"
|
|
self.progressExpNum_tmp.text = string.format("(<color=%s>%s</color>/%s)",ColorUtil.WHITE,self.model.swallow_exp,lv_cfg.exp)
|
|
-- SetSizeDeltaX(self.progressBar,590)
|
|
-- SetAnchoredPositionX(self.progressHandle,590)
|
|
endValue = self.model.swallow_exp/lv_cfg.exp
|
|
SetSizeDeltaX(self.progressBar,590*endValue)
|
|
SetAnchoredPositionX(self.progressHandle,590*endValue)
|
|
else
|
|
endValue = self.model.swallow_exp/lv_cfg.exp
|
|
if endValue < 0 then
|
|
endValue = 0
|
|
elseif endValue > 1 then
|
|
endValue = 1
|
|
end
|
|
if need_anim then
|
|
if is_up then
|
|
local function fun()
|
|
self.in_progressing = true --进度条正在跑
|
|
self.progressing_fun_queue = {}
|
|
|
|
self.progressing_time = 0.5
|
|
if self.progressing_time * up_lv_num > 2 then
|
|
self.progressing_time = 2 / up_lv_num
|
|
end
|
|
|
|
for i=1,up_lv_num-1 do --前几次跑完整的0到1
|
|
local pre_fun = function()
|
|
self.swallowLv_tmp.text = string.format("Lv.%s",self.model.pre_swallow_lv+i)
|
|
SetSizeDeltaX(self.progressBar,0)
|
|
SetAnchoredPositionX(self.progressHandle,0)
|
|
table.remove(self.progressing_fun_queue,1)
|
|
TweenLite.to(self, self.progressBar, TweenLite.UiAnimationType.WIDTH, 590, self.progressing_time,self.progressing_fun_queue[1])
|
|
TweenLite.to(self, self.progressHandle, TweenLite.UiAnimationType.ANCHORED_POSX, 590, self.progressing_time)
|
|
self:SetExpAnimation(0,Config.Goodsdevour[self.model.pre_swallow_lv+i].exp,self.model.pre_swallow_lv+i,self.progressing_time)
|
|
end
|
|
table.insert(self.progressing_fun_queue,pre_fun)
|
|
end
|
|
--最后一段的进度条
|
|
local final_fun = function()
|
|
local end_flag_change = function()
|
|
self.in_progressing = false --跑完了
|
|
self.progressing_fun_queue = {}
|
|
end
|
|
self.swallowLv_tmp.text = string.format("Lv.%s",self.model.swallow_lv)
|
|
SetSizeDeltaX(self.progressBar,0)
|
|
SetAnchoredPositionX(self.progressHandle,0)
|
|
table.remove(self.progressing_fun_queue,1)
|
|
TweenLite.to(self, self.progressBar, TweenLite.UiAnimationType.WIDTH, 590*endValue, endValue*self.progressing_time,end_flag_change)
|
|
TweenLite.to(self, self.progressHandle, TweenLite.UiAnimationType.ANCHORED_POSX, 590*endValue, endValue*self.progressing_time)
|
|
self:SetExpAnimation(0,Config.Goodsdevour[self.model.swallow_lv].exp,self.model.swallow_lv,endValue*self.progressing_time)
|
|
end
|
|
table.insert(self.progressing_fun_queue,final_fun)
|
|
--开始执行队列中的方法来跑进度条
|
|
self.progressing_fun_queue[1]()
|
|
end
|
|
TweenLite.to(self, self.progressBar, TweenLite.UiAnimationType.WIDTH, 590, (1-self.progressBar_img.fillAmount)*self.progressing_time,fun)
|
|
TweenLite.to(self, self.progressHandle, TweenLite.UiAnimationType.ANCHORED_POSX, 590, (1-self.progressBar_img.fillAmount)*self.progressing_time)
|
|
self:SetExpAnimation(self.model.swallow_exp,Config.Goodsdevour[self.model.pre_swallow_lv].exp,self.model.pre_swallow_lv,(1-self.progressBar_img.fillAmount)*self.progressing_time)
|
|
else
|
|
self.swallowLv_tmp.text = string.format("Lv.%s",self.model.swallow_lv)
|
|
TweenLite.to(self, self.progressBar, TweenLite.UiAnimationType.WIDTH, 590*endValue, endValue*self.progressing_time)
|
|
TweenLite.to(self, self.progressHandle, TweenLite.UiAnimationType.ANCHORED_POSX, 590*endValue, endValue*self.progressing_time)
|
|
self:SetExpAnimation(self.model.pre_swallow_exp,self.model.swallow_exp,self.model.swallow_lv,endValue*self.progressing_time)
|
|
end
|
|
else
|
|
self.progressExpNum_tmp.text = string.format("(<color=%s>%s</color>/%s)",ColorUtil.WHITE,self.model.swallow_exp,lv_cfg.exp)
|
|
self.swallowLv_tmp.text = string.format("Lv.%s",self.model.swallow_lv)
|
|
SetSizeDeltaX(self.progressBar,590*endValue)
|
|
SetAnchoredPositionX(self.progressHandle,590*endValue)
|
|
end
|
|
end
|
|
else
|
|
self.swallowLv_tmp.text = string.format("Lv.%s",self.model.swallow_lv)
|
|
-- self.progressExpNum_tmp.text = "满级了"
|
|
self.progressExpNum_tmp.text = string.format("(<color=%s>%s</color>/%s)",ColorUtil.WHITE,self.model.swallow_exp,lv_cfg.exp)
|
|
-- SetSizeDeltaX(self.progressBar,590)
|
|
-- SetAnchoredPositionX(self.progressHandle,590)
|
|
endValue = self.model.swallow_exp/lv_cfg.exp
|
|
SetSizeDeltaX(self.progressBar,590*endValue)
|
|
SetAnchoredPositionX(self.progressHandle,590*endValue)
|
|
end
|
|
|
|
--属性
|
|
local next_lv_cfg = Config.Goodsdevour[self.model.swallow_lv+1]
|
|
local next_attr_data = next_lv_cfg and stringtotable(next_lv_cfg.attr) or nil
|
|
local attr_data = stringtotable(lv_cfg.attr)
|
|
local txt_1 = ""
|
|
local txt_2 = ""
|
|
local pre_txt_1 = ""
|
|
local pre_txt_2 = ""
|
|
if attr_data then
|
|
pre_txt_1 = string.format("%s <color=%s>+%s</color>",WordManager:GetProperties(attr_data[1][1]),ColorUtil.WHITE,WordManager:GetPropertyValue(attr_data[1][1],attr_data[1][2]))
|
|
pre_txt_2 = string.format("%s <color=%s>+%s</color>",WordManager:GetProperties(attr_data[2][1]),ColorUtil.WHITE,WordManager:GetPropertyValue(attr_data[2][1],attr_data[2][2]))
|
|
end
|
|
txt_1 = pre_txt_1 .. " "
|
|
txt_2 = pre_txt_2 .. " "
|
|
if next_lv_cfg and next_attr_data and attr_data then
|
|
txt_1 = txt_1..HtmlColorTxt(WordManager:GetPropertyValue(next_attr_data[1][1],next_attr_data[1][2]-attr_data[1][2]), ColorUtil.GREEN_DARK)
|
|
txt_2 = txt_2..HtmlColorTxt(WordManager:GetPropertyValue(next_attr_data[2][1],next_attr_data[2][2]-attr_data[2][2]), ColorUtil.GREEN_DARK)
|
|
self.attrArrow1_obj:SetActive(true)
|
|
self.attrArrow2_obj:SetActive(true)
|
|
else
|
|
self.attrArrow1_obj:SetActive(false)
|
|
self.attrArrow2_obj:SetActive(false)
|
|
end
|
|
|
|
self.attr1_tmp.text = pre_txt_1
|
|
self.attr2_tmp.text = pre_txt_2
|
|
SetLocalPositionX(self.attrArrow1, GetLocalPositionX(self.attr1) + self.attr1_tmp.preferredWidth+20)
|
|
SetLocalPositionX(self.attrArrow2, GetLocalPositionX(self.attr2) + self.attr2_tmp.preferredWidth+20)
|
|
self.attr1_tmp.text = txt_1
|
|
self.attr2_tmp.text = txt_2
|
|
end
|
|
|
|
--经验增长动画
|
|
function SwallowView:SetExpAnimation(start_exp,end_exp,lv,duration)
|
|
if #self.timer_id_list ~= 0 then
|
|
self:DeleteTimer()
|
|
end
|
|
|
|
local lv_max_exp = Config.Goodsdevour[lv].exp
|
|
|
|
for i=1,20 do
|
|
local function delay_func()
|
|
self.progressExpNum_tmp.text = string.format("(<color=%s>%s</color>/%s)",ColorUtil.WHITE,math.floor(start_exp+((end_exp - start_exp)/20)*i),lv_max_exp)
|
|
end
|
|
local id = GlobalTimerQuest:AddDelayQuest(delay_func,i*(duration/20))
|
|
table.insert(self.timer_id_list,id)
|
|
end
|
|
|
|
local function end_show()
|
|
self.progressExpNum_tmp.text = string.format("(<color=%s>%s</color>/%s)",ColorUtil.WHITE,self.model.swallow_exp,Config.Goodsdevour[self.model.swallow_lv].exp)
|
|
end
|
|
local end_id = GlobalTimerQuest:AddDelayQuest(end_show,20*(duration/20)+0.05)
|
|
table.insert(self.timer_id_list,end_id)
|
|
end
|
|
|
|
function SwallowView:DeleteTimer()
|
|
for i=1,#self.timer_id_list do
|
|
GlobalTimerQuest:CancelQuest(self.timer_id_list[i])
|
|
self.timer_id_list[i] = nil
|
|
end
|
|
self.timer_id_list = {}
|
|
end
|
|
|
|
--刷新装备列表
|
|
function SwallowView:UpdateEquipScroll( )
|
|
self.equips_list = {}
|
|
self.equips_count = 0
|
|
--先拿到背包中的装备数据
|
|
local goods_list = GoodsModel:getInstance().bag_goods_list -- 获取到背包列表
|
|
for k,v in pairs(goods_list) do
|
|
-- 项链8 戒指9 耳饰10 守护11 不可吞噬
|
|
if v.type == GoodsModel.TYPE.EQUIP and v.subtype ~= 8 and v.subtype ~= 9
|
|
and v.subtype ~= 10 and v.subtype ~= 11 and v.goods_num >0 then
|
|
table.insert(self.equips_list,v)
|
|
end
|
|
end
|
|
table.sort(self.equips_list,function(a,b)
|
|
if a.color~=b.color then
|
|
return a.color<b.color
|
|
else
|
|
return a.type_id<b.type_id
|
|
end
|
|
end)
|
|
-- 如果是永久Vip,则额外加入小飞鞋的吞噬
|
|
if VipModel:getInstance():IsForeverVip() then
|
|
local fly_shoes = GoodsModel:getInstance():GetTypeGoods(self.fly_shoes_id)
|
|
if not IsTableEmpty(fly_shoes) then
|
|
for k, v in ipairs(fly_shoes) do -- 防止有多种小飞鞋
|
|
table.insert(self.equips_list, 1, v)
|
|
end
|
|
end
|
|
end
|
|
self.equips_count = #self.equips_list
|
|
|
|
|
|
--默认勾选住普通装备
|
|
self.swallowCheck_toggle.isOn = true
|
|
self:SelectEquip()
|
|
|
|
--开始创建装备背包列表
|
|
local total_num = 0
|
|
if self.equips_count > self.defult_slot then
|
|
total_num = self.equips_count
|
|
else
|
|
total_num = self.defult_slot
|
|
end
|
|
for k = 1,self.defult_slot do
|
|
local item = self.bag_item_list[k]
|
|
if item == nil then
|
|
item = SwallowBagItem.New(self.con_equip,nil,self.layer_name)
|
|
item:SetVisible(false)
|
|
self.bag_item_list[k] = item
|
|
end
|
|
end
|
|
self.loop_mgr:Init(self.equipScroll,self.Content_equip,self.column_num,89.5,89.5,function(item,index,realIndex )
|
|
self:OnInitializeItem(item,index,realIndex )
|
|
end)
|
|
self.loop_mgr:InitChildren(self.bag_item_list, total_num)
|
|
self.loop_mgr:RestToBeginning()
|
|
self.loop_mgr:ForceUpdateCurrentItems()
|
|
self.loop_mgr:SetContentSizeData()
|
|
end
|
|
|
|
function SwallowView:OnInitializeItem(item,index,realIndex)
|
|
if item and realIndex > 0 and realIndex <= self.equips_count then
|
|
item:SetData(self.equips_list[realIndex],realIndex)
|
|
else
|
|
item:SetData(nil)
|
|
end
|
|
self:UpdateItemState()
|
|
end
|
|
|
|
function SwallowView:UpdateItemState()
|
|
for k,item in pairs(self.bag_item_list) do
|
|
item:UpdateSelect()
|
|
end
|
|
end
|
|
|
|
-- 批量选择装备
|
|
function SwallowView:SelectEquip()
|
|
local color = ColorType.BLUE_DARK
|
|
|
|
local main_level = RoleManager.Instance.mainRoleInfo.level
|
|
local main_career = RoleManager.Instance.mainRoleInfo.career
|
|
local my_max_turn = EquipModel.getInstance():GetCurrentOpenSuitSeries()--我当前的最大装备套数
|
|
local repetitive_flag_list = {}--未解锁的蓝装只筛选一个去吞噬
|
|
|
|
for k,v in pairs(self.equips_list) do
|
|
v.isSelect = false
|
|
end
|
|
|
|
if self.swallowCheck_toggle.isOn then
|
|
for k,v in pairs(self.equips_list) do
|
|
if v.type_id == self.fly_shoes_id then
|
|
v.isSelect = true
|
|
else
|
|
if v.color <= color then
|
|
if v.color == ColorType.BLUE_DARK then--蓝装需要判定筛选
|
|
local can_not_use = false--是否为不可操作的装备(不可穿戴)
|
|
local can_tip, flag = EquipModel:getInstance():EquipCanShowGoodsTip(v)
|
|
|
|
local equip_cfg = EquipModel:getInstance():GetEquipmentCfg(v.type_id)--拿到装备配置
|
|
local equip_series = equip_cfg and equip_cfg.series or 0--装备对应套数
|
|
local career_list = equip_cfg and equip_cfg.career or {}--装备对应职业
|
|
local is_my_career = false--是否为我能用的职业
|
|
for k,v in pairs(career_list) do
|
|
if v == main_career then
|
|
is_my_career = true
|
|
break
|
|
end
|
|
end
|
|
|
|
local not_my_career_equip = false
|
|
local high_series_can_join = false
|
|
if is_my_career then
|
|
--如果是我的职业,判定一下是否为未解锁的套数
|
|
if equip_series > my_max_turn then --还没解锁的套数蓝装只保留一个
|
|
if repetitive_flag_list[v.type_id] then--已经有了一个了,剩下的都拿去吞噬
|
|
high_series_can_join = true
|
|
else
|
|
repetitive_flag_list[v.type_id] = true
|
|
end
|
|
else--已经解锁的套数判断下是否不可操作穿戴的装备
|
|
if flag ~= 1 then
|
|
can_not_use = true
|
|
end
|
|
end
|
|
else--如果都不是自己的职业,那直接吞掉就完事了
|
|
not_my_career_equip = true
|
|
end
|
|
|
|
if can_not_use or not_my_career_equip or high_series_can_join then
|
|
v.isSelect = true
|
|
end
|
|
else
|
|
v.isSelect = true
|
|
end
|
|
else
|
|
v.isSelect = false
|
|
end
|
|
end
|
|
end
|
|
else
|
|
for k,v in pairs(self.equips_list) do
|
|
v.isSelect = false
|
|
end
|
|
end
|
|
|
|
self:UpdateItemState()
|
|
self:ShowSwallowExp()
|
|
end
|
|
|
|
--预览吞噬经验
|
|
function SwallowView:ShowSwallowExp()
|
|
-- local next_lv_cfg = Config.Goodsdevour[self.model.swallow_lv+1]
|
|
-- if not next_lv_cfg then
|
|
-- self.progressExpNum_tmp.text = "满级了"
|
|
-- return
|
|
-- end
|
|
|
|
-- 构建装备表
|
|
local equips_list = {}
|
|
for k,v in pairs(self.equips_list) do
|
|
if v.isSelect == true then
|
|
table.insert(equips_list,v)
|
|
end
|
|
end
|
|
local exp = 0
|
|
for i,v in ipairs(equips_list) do
|
|
if v.type_id == self.fly_shoes_id then -- 1件小飞鞋写死1点经验值
|
|
exp = exp + v.goods_num
|
|
else
|
|
local cfg = Config.Equipment[v.type_id]
|
|
if cfg then
|
|
exp = exp + tonumber(cfg.devour_exp)
|
|
end
|
|
end
|
|
end
|
|
--展示预览吞噬经验
|
|
if exp ~= 0 then
|
|
local lv_cfg = Config.Goodsdevour[self.model.swallow_lv]
|
|
if lv_cfg then
|
|
self.progressExpNum_tmp.text = string.format("(<color=%s>%s <color=%s>+%s</color></color>/%s)",ColorUtil.WHITE,self.model.swallow_exp,ColorUtil.GREEN_TIPS,exp,lv_cfg.exp)
|
|
end
|
|
else
|
|
local lv_cfg = Config.Goodsdevour[self.model.swallow_lv]
|
|
if lv_cfg then
|
|
self.progressExpNum_tmp.text = string.format("(<color=%s>%s</color>/%s)",ColorUtil.WHITE,self.model.swallow_exp,lv_cfg.exp)
|
|
end
|
|
end
|
|
end
|
|
|
|
--开始吞噬
|
|
function SwallowView:BeginSwallow()
|
|
if self.in_progressing then
|
|
Message.show("吞噬中,请稍后再试","fault")
|
|
return
|
|
end
|
|
--先记录一下吞噬前的吞噬等级
|
|
self.model.pre_swallow_lv = self.model.swallow_lv
|
|
self.model.pre_swallow_exp = self.model.swallow_exp
|
|
-- 构建要发的装备表
|
|
local equips_list = {}
|
|
local is_rare_color = 0
|
|
for k,v in pairs(self.equips_list) do
|
|
if v.isSelect == true then
|
|
local equip = {}
|
|
equip.id = v.goods_id
|
|
equip.type_id = v.type_id
|
|
-- equip.num = v.goods_num
|
|
table.insert(equips_list,equip)
|
|
if v.type_id ~= self.fly_shoes_id then
|
|
is_rare_color = is_rare_color > v.color and is_rare_color or v.color
|
|
end
|
|
end
|
|
end
|
|
|
|
if #equips_list == 0 then
|
|
Message.show("尚未选择吞噬物品","fault")
|
|
else
|
|
local function ok_callback()
|
|
self.model.need_sort_bag = true
|
|
self.model:Fire(BagModel.REQUEST_PROTOCOL,15024,equips_list)
|
|
|
|
for i,v in ipairs(equips_list) do
|
|
self:FlyAwardToBag(v.type_id,i)
|
|
end
|
|
|
|
lua_soundM:PlayEffect(self, "success",false,LuaSoundManager.SOUND_TYPE.UI)
|
|
end
|
|
if is_rare_color >= 3 then
|
|
Alert.show("您选中的装备中包含稀有装备,确定要吞噬吗?", Alert.Type.Two, ok_callback, nil, "确定", "取消")
|
|
else
|
|
ok_callback()
|
|
end
|
|
end
|
|
end
|
|
|
|
function SwallowView:FlyAwardToBag(goods_type_id,index)
|
|
local goods_type_id = goods_type_id
|
|
|
|
local start_pos = self.flyCon:InverseTransformPoint(self.flyCon.transform.position)
|
|
|
|
self.image_pool = self.image_pool or {}
|
|
local image_item
|
|
if #self.image_pool > 0 then
|
|
image_item = table.remove(self.image_pool, #self.image_pool)
|
|
else
|
|
image_item = {}
|
|
image_item.gameObject = UiFactory.createChild(self.flyCon, UIType.Image)
|
|
image_item.transform = image_item.gameObject.transform
|
|
image_item.img = image_item.gameObject:GetComponent("Image")
|
|
end
|
|
SetLocalScale(image_item.transform,0.6,0.6,0.6)
|
|
image_item.gameObject:SetActive(true)
|
|
local goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_type_id)
|
|
local goods_icon = goods_vo and goods_vo.goods_icon or 0
|
|
lua_resM:setOutsideImageSprite(self, image_item.img, GameResPath.GetGoodsIcon(goods_icon), true)
|
|
SetLocalPosition(image_item.transform, start_pos.x, start_pos.y, start_pos.z)
|
|
local optional = {
|
|
min_duration = 0.6,
|
|
rand_duration = 0.9,
|
|
stop_duration = 0,
|
|
}
|
|
local flyAction = cc.FlyToRandom.New(start_pos, Vector3.New(-444, -222, 0),optional)
|
|
local action = cc.Sequence.New(flyAction, cc.CallFunc.New(function()
|
|
image_item.gameObject:SetActive(false)
|
|
table.insert(self.image_pool, image_item)
|
|
end))
|
|
cc.ActionManager:getInstance():addAction(action, image_item.transform)
|
|
|
|
if self.delay_show_effect then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_show_effect)
|
|
self.delay_show_effect = nil
|
|
end
|
|
if self.delay_hide_effect_id then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_hide_effect_id)
|
|
self.delay_hide_effect_id = nil
|
|
end
|
|
if self.delay_show_effect_id then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_show_effect_id)
|
|
self.delay_show_effect_id = nil
|
|
end
|
|
|
|
local function delay_method( )
|
|
self:AddUIEffect("ui_heidongtunshi", self.swallowEffect, "Scene", nil, 4.5, false, nil, false,nil,nil,0.4)
|
|
end
|
|
self.delay_show_effect = setTimeout(delay_method, 0)
|
|
|
|
|
|
lua_soundM:StopEffect(self, LuaSoundManager.SOUND_TYPE.UI, self.sound_id)
|
|
if lua_soundM then
|
|
self.sound_id = lua_soundM:PlayEffect(self, "swallow",false,LuaSoundManager.SOUND_TYPE.UI)
|
|
end
|
|
|
|
local function delay_hide_effect( )
|
|
self.effectCon_obj:SetActive(false)
|
|
end
|
|
self.delay_hide_effect_id = setTimeout(delay_hide_effect, 0.2)
|
|
|
|
local function delay_show_effect_con( )
|
|
self.effectCon_obj:SetActive(true)
|
|
end
|
|
self.delay_show_effect_id = setTimeout(delay_show_effect_con, 1.5)
|
|
end
|
|
|
|
function SwallowView:__delete( )
|
|
if self.delay_show_effect then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_show_effect)
|
|
self.delay_show_effect = nil
|
|
end
|
|
if self.delay_hide_effect_id then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_hide_effect_id)
|
|
self.delay_hide_effect_id = nil
|
|
end
|
|
if self.delay_show_effect_id then
|
|
TimerQuest.CancelQuest(GlobalTimerQuest, self.delay_show_effect_id)
|
|
self.delay_show_effect_id = nil
|
|
end
|
|
|
|
for k,v in pairs(self.bag_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.bag_item_list = {}
|
|
|
|
for k,v in pairs(self.core_attr_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.core_attr_item_list = {}
|
|
|
|
self.equips_list = {}
|
|
|
|
if self.loop_mgr then
|
|
self.loop_mgr:DeleteMe()
|
|
self.loop_mgr = nil
|
|
end
|
|
|
|
self:DeleteTimer()
|
|
|
|
self:ClearUIEffect(self.effectCon)
|
|
self:ClearUIEffect(self.flyCon)
|
|
end
|