源战役客户端
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
8.8 KiB

EquipCollectRightItem = EquipCollectRightItem or BaseClass(BaseItem)
local EquipCollectRightItem = EquipCollectRightItem
function EquipCollectRightItem:__init()
self.base_file = "equipCollect"
self.layout_file = "EquipCollectRightItem"
self.model = EquipCollectModel:GetInstance()
self.equip_item_list = {}
self.pos = false
self.pos_map_list = {
[1] = EquipModel.EquipType.Weapon,
[2] = EquipModel.EquipType.Head,
[3] = EquipModel.EquipType.Body,
[4] = EquipModel.EquipType.Shoulder,
[5] = EquipModel.EquipType.Hand,
[6] = EquipModel.EquipType.Leg,
[7] = EquipModel.EquipType.Shoes,
}
self:Load()
end
function EquipCollectRightItem:Load_callback()
self.nodes = {
"icon_image:img:obj", "btn/btn_text:tmp", "bg:img", "name_text:tmp", "finishi_image:obj", "item_con", "btn:obj:img", "btn/btn_red:obj",
}
self:GetChildren(self.nodes)
self:AddEvents()
if self.need_refreshData then
self:UpdateView()
end
self:AddToStageHandler()
end
function EquipCollectRightItem:AddEvents( )
local function on_click( )
if self.data and self.data[1] then
self.model:Fire(EquipCollectConst.CLICK_EQUIP_COLLECT_ITEM, self.data[1].id, self.data[1].sub_id)
end
-------------------------
if self.can_click then
self.model:Fire(EquipCollectConst.REQUEST_SCMD_EVENT,15220, self.data[1].id, self.data[1].sub_id)
else
if self.data[1].id == 1 and self.data[1].sub_id == 1 then--第一套装备领取的时候关界面 强制做主线
self.model:Fire(EquipCollectConst.OPEN_EC_MAIN_VIEW, false)
GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK) --启动自动任务
else
local key = self.click_jump.pos .. "@" .. self.click_jump.id .. "@" .. self.click_jump.pos
local cfg = Config.Equipmentempty[key]
if cfg then
BagModel:getInstance():Fire(BagModel.EQUIP_ITEM_GET_WAY_TIPS, cfg,0,0,"equipCollect")
else
print(">>>>>ec unfinfd config Equipmentempty ", self.pos_type, self.series )
end
end
-- local type_id = self.model:GetEquipCollectEquipId(self.click_jump.id, self.click_jump.sub_id,self.click_jump.pos)
-- UIToolTipMgr:getInstance():AppendEquipTips(type_id, x, y, nil, nil, nil, nil, nil, nil, true)
end
end
AddClickEvent(self.btn_obj, on_click)
local function onGuideTrigger()
self:AddToStageHandler()
end
self:BindEvent(GlobalEventSystem, EventName.TRIGGER_GUIDE_TYPE, onGuideTrigger)
local function CLICK_EQUIP_COLLECT_ITEM( id,sub_id )
self.model.mask_lead_effect[sub_id] = true--点击之后就去掉特效
if self.data and self.data[1] then
if self.data[1].id == id and self.data[1].sub_id == sub_id then
self:ClearUIEffect(self.bg.transform)
self.showing_effect = false
end
end
end
self:BindEvent(self.model, EquipCollectConst.CLICK_EQUIP_COLLECT_ITEM, CLICK_EQUIP_COLLECT_ITEM)
end
function EquipCollectRightItem:UpdateView( )
local server_data = self.model:GetEquipCollectInfo(self.data[1].id, self.data[1].sub_id)
local is_all_collect = self.model:CheckIsAllEquipCollected(self.data[1].id, self.data[1].sub_id)
self.btn_obj:SetActive(not is_all_collect)
self.finishi_image_obj:SetActive(is_all_collect)
lua_resM:setImageSprite(self, self.bg_img, "equipCollectOut_asset", "equipcollect_color_bg"..self.data[1].sub_id, true)
local str = "收集 %s 套装7件 (%s/7)"
local name = self.model:GetEquipCollectSubTypeName(self.data[1].id, self.data[1].sub_id)
local progress = self.model:GetEquipCollectProgress(self.data[1].id, self.data[1].sub_id)
local cur_active_num = 0
if TableSize(progress) > 0 then
cur_active_num = progress.can_active
end
if cur_active_num == 7 then-- 可以点按钮
lua_resM:setImageSprite(self, self.btn_img, "alphaCommon_asset", "tyui_btn_2")
SetTMPSharedMaterial(self.btn_text_tmp,ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkOrangeBtn)
self.can_click = true
self.click_jump = nil
self.btn_text_tmp.text = "领取"
else
lua_resM:setImageSprite(self, self.btn_img, "alphaCommon_asset", "tyui_btn_1")
SetTMPSharedMaterial(self.btn_text_tmp,ShaderTools.TMPSharedMaterialType.FZZZOutlineDarkBlueBtn)
self.can_click = false
self.btn_text_tmp.text = "获取装备"
self.click_jump = nil
end
self.name_text_tmp.text = string.format(str, HtmlColorTxt(name, ColorUtil.YELLOW_DARK), HtmlColorTxt(cur_active_num, cur_active_num == 7 and ColorUtil.GREEN_DARK or ColorUtil.RED_DARK ))
self.btn_red_obj:SetActive(self.model:IsEquipCollectNeedRedById(self.data[1].id, self.data[1].sub_id))
local award = stringtotable(self.model:GetEqipCollectAward(self.data[1].id, self.data[1].sub_id))
if TableSize(award) > 0 then
local designation_id = DesignationModel:GetInstance():GetDesignationIdByGoodsId(award[1][2])
local cfg = Config.Dsgt
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.icon_image)
if cfg[designation_id].type == 1 then--文字称号(文字称号也用图片了)
self.icon_image_obj:SetActive(true)
lua_resM:setOutsideImageSprite(self, self.icon_image_img, GameResPath.GetDesignImage(cfg[designation_id].id), true)
elseif cfg[designation_id].type == 2 then--图片称号
self.icon_image_obj:SetActive(true)
lua_resM:setOutsideImageSprite(self, self.icon_image_img, GameResPath.GetDesignImage(cfg[designation_id].id), true)
elseif cfg[designation_id].type == 3 then--特效称号
if not self.dynamic_image_obj then
self.dynamic_image_obj = UiFactory.createChild(self.icon_image, UIType.Image, "dynamic_image")
self.dynamic_image_img = self.dynamic_image_obj:GetComponent("Image")
self.dynamic_image = self.dynamic_image_obj.transform
SetAnchoredPosition(self.dynamic_image,0,0)
else
self.dynamic_image_obj:SetActive(true)
end
SetSizeDelta(self.icon_image, 210*0.5,90*0.5)
self.icon_image_obj:SetActive(true)
local data = DesignationModel:GetInstance():GetDynamicDesignationCFG(designation_id)
local res = Split(data[1].res,"_")--分割出来配置 然后取文字
local font_res = res[1] or ""
lua_resM:setImageSprite(self, self.dynamic_image_img, data[1].ab, font_res.."_font", true)
SetSizeDelta(self.dynamic_image, 210*0.5,90*0.5)
self.icon_image_obj:SetActive(true)
local action = cc.Animation.New(data,0.15)
cc.ActionManager:getInstance():addAction(cc.RepeatForever.New(action),self.icon_image.transform)
end
end
local x_offset = 78
for i=1,7 do
local item = self.equip_item_list[i]
if not item then
item = EquipCollectEquipItem.New(self.item_con)
item:SetPosition(x_offset*(i-1) - 16, 10)
self.equip_item_list[i] = item
end
if not self.can_click and not self.click_jump then
self.click_jump = server_data[self.pos_map_list[i]] and self.click_jump or self.data[self.pos_map_list[i]]
end
item:SetData(self.data[self.pos_map_list[i]], index, self.pos_map_list[i], server_data[self.pos_map_list[i]], "equip_collect_base_view")
end
if self.time_delay_effect then
GlobalTimerQuest:CancelQuest(self.time_delay_effect)
self.time_delay_effect = nil
end
if (self.show_first_effect == self.data[1].sub_id) and (not self.model.mask_lead_effect[self.data[1].sub_id]) then
if not self.showing_effect then
local function delay( )
self.showing_effect = true
self:AddUIEffect("ui_jujiaodianji", self.bg.transform, "Activity", Vector3(268,-23,0), 1, true)
end
self.time_delay_effect = setTimeout(delay,0.3)
end
else
self.showing_effect = false
self:ClearUIEffect(self.bg.transform)
end
end
function EquipCollectRightItem:SetData( data,_,_,pos,show_first_effect )
self.data = data
self.pos = pos
self.show_first_effect = show_first_effect
if self.is_loaded then
self.need_refreshData = false
self:UpdateView()
else
self.need_refreshData = true
end
end
function EquipCollectRightItem:__delete( )
for i,v in ipairs(self.equip_item_list) do
v:DeleteMe()
v = nil
end
self.equip_item_list = {}
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.icon_image)
if self.bg then
self:ClearUIEffect(self.bg.transform)
end
if self.time_delay_effect then
GlobalTimerQuest:CancelQuest(self.time_delay_effect)
self.time_delay_effect = nil
end
end
function EquipCollectRightItem:AddToStageHandler()
if self.pos ~= 1 then return end
local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_SUIT_COLLECT,3)
if not helpVo then return end
local help_type = helpVo.help_type
if (help_type == HelpType.TYPE_SUIT_COLLECT ) then
local step = helpVo.step
local button = false
if (help_type == HelpType.TYPE_SUIT_COLLECT and step == 3 ) then
button = self.btn_obj
end
if button then
local function call_back()
end
GlobalEventSystem:Fire(EventName.OPEN_GUIDE_PROMPT_VIEW, button.transform, button.transform.parent.transform, call_back, helpVo, self.layout_file)
end
else
GlobalEventSystem:Fire(EventName.CLOSE_GUIDE_PROMPT_VIEW)
end
end