源战役客户端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

454 wiersze
19 KiB

NiceGoodsTips = NiceGoodsTips or BaseClass(BaseView)
local NiceGoodsTips = NiceGoodsTips
--[[
NiceGoodsTips.TabData = {
[1] = {name = "人物", level = MainRoleModel.TabOpenLevel[1]},
}
--]]
function NiceGoodsTips:__init()
self.base_file = "common"
self.layout_file = "NiceGoodsTips"
self.layer_name = "Top"
self.destroy_imm = true
self.is_set_zdepth = true
self.use_background = true --全屏界面默认使用这个参数
self.click_bg_toClose = true
self.hide_maincancas = false
self.change_scene_close = true
self.append_to_ctl_queue = false --是否要添加进界面堆栈
self.need_show_money = false --是否要显示顶部的金钱栏
self.model = GoodsModel:getInstance()
self.shop_model = ShopModel:getInstance()
self.pos_x = 0
self.pos_y = 0
self.goods_vo = nil
self.is_show_btn = nil
self.mainVo = RoleManager.Instance.mainRoleInfo
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 NiceGoodsTips:Open(type_id, x, y, goods_vo, show_btn_list, parm_list)
self.type_id = type_id
self.is_show_btn = goods_vo ~= nil
self.show_btn_list = show_btn_list
self.parm_list = parm_list
self.shop_data = parm_list and parm_list.shop_data or nil
self.goods_vo = goods_vo or self.model:GetGoodsBasicByTypeId(type_id)
self.pos_x = x
self.pos_y = y
BaseView.Open(self)
end
function NiceGoodsTips:LoadSuccess()
local nodes = {
"layout/base_con/attr_scroll","layout/base_con/line1:obj","layout/base_con/attr_scroll/Viewport/attr_con",
"layout/base_con/designation_con:obj","layout/base_con/power_text:txt","layout/base_con/bg:raw",
"layout/base_con/get_text:txt","layout/base_con/desc_text:txt","layout/base_con/name_text:txt","layout/base_con/limit_image:obj",
----------------------------
"layout:obj","layout/base_con/designation_con/designation_image:obj:img",
"layout/base_con/designation_con/designation_text:txt","layout/base_con/designation_con/designation_effect:obj",
"layout/base_con/roleCon:obj","layout/btns_con:obj",
--商城购买界面
"layout/shop_con:obj",
}
self:GetChildren(nodes)
self.shiyongBtn = self:GetChild("layout/btns_con/shiyongBtn").gameObject
self.hechengBtn = self:GetChild("layout/btns_con/hechengBtn").gameObject
self.chushouBtn = self:GetChild("layout/btns_con/chushouBtn").gameObject
self.yulanBtn = self:GetChild("layout/btns_con/yulanBtn").gameObject
self.storeBtn = self:GetChild("layout/btns_con/storeBtn").gameObject
self.takeBtn = self:GetChild("layout/btns_con/takeBtn").gameObject
self.splitBtn = self:GetChild("layout/btns_con/splitBtn").gameObject
self.shelvesUpBtn = self:GetChild("layout/btns_con/shelvesUpBtn").gameObject
self.shelvesDownBtn = self:GetChild("layout/btns_con/shelvesDownBtn").gameObject
self.decomposeBtn = self:GetChild("layout/btns_con/decomposeBtn").gameObject
self.oneKeyBuyBtn = self:GetChild("layout/btns_con/oneKeyBuyBtn").gameObject
self.replaceBtn = self:GetChild("layout/btns_con/replaceBtn").gameObject
self.dropBtn = self:GetChild("layout/btns_con/dropBtn").gameObject
self.capsuleEggTakeBtn = self:GetChild("layout/btns_con/capsuleEggTakeBtn").gameObject
self.btns_list = {
self.shiyongBtn, self.hechengBtn, self.chushouBtn,
self.yulanBtn, self.storeBtn, self.takeBtn, self.splitBtn,
self.shelvesUpBtn, self.shelvesDownBtn,
self.oneKeyBuyBtn, self.decomposeBtn, self.replaceBtn, self.dropBtn,self.capsuleEggTakeBtn
}
end
function NiceGoodsTips:AddEvent()
local function onClickBtnHandler(target)
if (self.goods_vo and (self.is_show_btn or CapsuleEggModel:getInstance():IsShowCapsuleEggTakeOutBtn() or self:ForeceTriggerEvt())) then
if target == self.shiyongBtn then
if self.mainVo.level < self.goods_vo.level then
Message.show("等级不足,无法使用")
return
end
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.goods_vo.type_id)
if basic.use_way and basic.use_way ~= "" then
local use_table = stringtotable(basic.use_way)
if use_table and use_table[1] and use_table[2] then
--特殊参数处理
local arg1, arg2
if self.goods_vo.type_id == 102601 then --扩容钥匙
local num = self.goods_vo.goods_num
local open_count = math.max(math.floor(num / 2), 1)
arg1 = self.goods_pos_type
arg2 = open_count
end
OpenFun.Open(tonumber(use_table[1]), tonumber(use_table[2]), arg1, arg2)
self:Close()
return
end
end
self:CheckSecondView()
elseif target == self.hechengBtn then
self:JumpComposeFunc()
elseif target == self.chushouBtn then
GlobalEventSystem:Fire(EventName.OPEN_SEll_VIEW, self.goods_vo)
elseif target == self.storeBtn then
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT, 15003, self.goods_vo.goods_id, GoodsModel.GOODS_POS_TYPE.bag, GoodsModel.GOODS_POS_TYPE.warehouse)
elseif target == self.takeBtn then
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT, 15003, self.goods_vo.goods_id, GoodsModel.GOODS_POS_TYPE.warehouse, GoodsModel.GOODS_POS_TYPE.bag)
elseif target == self.splitBtn then
BagModel:getInstance():Fire(BagModel.OPEN_BATHANDLE_VIEW, self.goods_vo, SplitView.TYPE.SPLIT)
elseif target == self.yulanBtn then
elseif target == self.shelvesUpBtn then
elseif target == self.shelvesDownBtn then
elseif target == self.oneKeyBuyBtn then
elseif target == self.decomposeBtn then
BagModel:getInstance():Fire(BagModel.OPEN_EQUIP_DECOMPOSE_VIEW, self.goods_vo)
elseif target == self.dropBtn then
BagModel:getInstance():Fire(BagModel.OPEN_BATHANDLE_VIEW, self.goods_vo, SplitView.TYPE.BAT_DROP)
elseif target == self.replaceBtn then
if self.goods_vo then
local has_vo, main, sub = HorseModel:getInstance():CheckVoIsOnMaterialTab(self.goods_vo)
if has_vo then
local typ = (self.parm_list and self.parm_list.material_type and self.parm_list.material_type ~= 0) and self.parm_list.material_type or main
local pos = (self.parm_list and self.parm_list.material_pos and self.parm_list.material_pos ~= 0) and self.parm_list.material_pos or sub
HorseModel:getInstance():Fire(HorsePetEvent.SELECT_MATERIAL_VIEW, typ, true, pos)
self:Close()
return
end
end
elseif target == self.capsuleEggTakeBtn then --龙神宝库临时仓库取出按钮
local now_warehouse_selected_goods_id = CapsuleEggModel:getInstance():GetWarehouseNowSelectedGoodsId()
CapsuleEggModel:getInstance():Fire(CapsuleEggConst.REQUEST_CCMD_EVENT,17008,now_warehouse_selected_goods_id)
CapsuleEggModel:getInstance():ResetWarehouseNowSelectedGoodsId()
end
end
self:Close()
end
AddClickEvent(self.shiyongBtn, onClickBtnHandler)
AddClickEvent(self.hechengBtn, onClickBtnHandler)
AddClickEvent(self.chushouBtn, onClickBtnHandler)
AddClickEvent(self.storeBtn, onClickBtnHandler)
AddClickEvent(self.takeBtn, onClickBtnHandler)
AddClickEvent(self.splitBtn, onClickBtnHandler)
AddClickEvent(self.yulanBtn, onClickBtnHandler)
AddClickEvent(self.shelvesUpBtn, onClickBtnHandler)
AddClickEvent(self.shelvesDownBtn, onClickBtnHandler)
AddClickEvent(self.oneKeyBuyBtn, onClickBtnHandler)
AddClickEvent(self.decomposeBtn, onClickBtnHandler)
AddClickEvent(self.replaceBtn, onClickBtnHandler)
AddClickEvent(self.dropBtn, onClickBtnHandler)
AddClickEvent(self.capsuleEggTakeBtn,onClickBtnHandler)
function on_close( )
self:Close()
end
self:BindEvent(self.shop_model,ShopModel.CLOSE_SHOP_BUY_VIEW, on_close)
end
function NiceGoodsTips:OpenSuccess()
self:UpdateView()
end
function NiceGoodsTips:UpdateView()
if self.goods_vo == nil then return end
local basic = self.model:GetGoodsBasicByTypeId(self.type_id)
self.attr_list = {}
self.designation_con_obj:SetActive(false)
self.roleCon_obj:SetActive(false)
if basic.type == GoodsModel.TYPE.DESIGNATION then
lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("designation_tip_bg"),true)
local cfg = Config.Dsgt
local designation_id = DesignationModel:GetInstance():GetDesignationIdByGoodsId(self.type_id)
self.attr_list = stringtotable(cfg[designation_id].attr_list)
local is_limit = DesignationModel:GetInstance():IsDesignationLimitTime(designation_id)
self.limit_image_obj:SetActive(is_limit)
self.designation_image_obj:SetActive(false)
self.designation_effect_obj:SetActive(false)
self.name_text_txt.text = ""
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.designation_image)
if cfg[designation_id].type == 1 then--文字称号(文字称号也用图片了)
self.designation_image_obj:SetActive(true)
lua_resM:setOutsideImageSprite(self, self.designation_image_img, GameResPath.GetDesignImage(cfg[designation_id].id), true)
self.designation_text_txt.text = ""
elseif cfg[designation_id].type == 2 then--图片称号
self.designation_image_obj:SetActive(true)
lua_resM:setOutsideImageSprite(self, self.designation_image_img, GameResPath.GetDesignImage(cfg[designation_id].id), true)
self.designation_text_txt.text = ""
elseif cfg[designation_id].type == 3 then--特效称号
self.designation_image_obj:SetActive(true)
local data = DesignationConst.DesignationData[cfg[designation_id].id] or DesignationConst.DesignationData[0]
local action = cc.Animation.New(data,0.15)
cc.ActionManager:getInstance():addAction(cc.RepeatForever.New(action),self.designation_image.transform)
self.designation_text_txt.text = ""
end
self.designation_con_obj:SetActive(true)
elseif basic.type == GoodsModel.TYPE.FASHION then
local fashion_id,color_id = FashionModel:getInstance():GetFashionIdByGoodsId(self.type_id)
local cur_cfg = Config.Fashionstarup[fashion_id.."@"..color_id.."@0"]
if cur_cfg then
self.attr_list = stringtotable(cur_cfg.attr_list)
end
lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("fashion_tip_bg"),true)
local is_limit = FashionModel:GetInstance():IsFashionLimitTime(fashion_id,color_id)
self.limit_image_obj:SetActive(is_limit)
self.roleCon_obj:SetActive(true)
elseif basic.type == GoodsModel.TYPE.CHILDTOY then
lua_resM:setOutsideRawImage(self,self.bg_raw,GameResPath.GetViewBigBg("designation_tip_bg"),true)
self.designation_con_obj:SetActive(true)
self.designation_image_obj:SetActive(true)
lua_resM:setOutsideImageSprite(self, self.designation_image_img, GameResPath.GetChildHandbookIcon(basic.type_id), true)
if DeepCopy(Config.Childtoynew)[basic.type_id] then
self.attr_list = stringtotable(DeepCopy(Config.Childtoynew)[basic.type_id].attr_list)
end
end
self.name_text_txt.text = basic.goods_name
self.get_text_txt.text = basic.getway
self.desc_text_txt.text = basic.intro
self:SetBtnCon()
self:UpdateAttrCon()
if self.shop_data then
self.shop_con_obj:SetActive(true)
self:UpdateShopView()
else
self.shop_con_obj:SetActive(false)
end
end
function NiceGoodsTips:UpdateAttrCon( )
local attr_list = self.attr_list
if not self.attr_list_com then
self.attr_list_com = self:AddUIComponent(UI.ItemListCreator)
end
local child_names = {
"num_text:txt","name_text:txt",
}
self.power_text_txt.text = GetFighting(attr_list)
local function on_update( item,i,v )
local _, name, _, val = WordManager:GetPropertyInfo(v[1], v[2])
item.name_text_txt.text = name..""
item.num_text_txt.text = val
end
local info = {
data_list = attr_list,
item_con = self.attr_con,
prefab_ab_name = "common",
prefab_res_name = "NiceGoodsAttrItem",
item_width = 160,
item_height = 34,
space_x = 2,
space_y = 2,
start_x = 2,
start_y = -2,
scroll_view = self.attr_scroll,
create_frequency = 0.05,
is_scroll_back_on_update = false,
child_names = child_names,
on_update_item = function(item, i, v)
on_update(item,i,v)
end,
}
self.attr_list_com:UpdateItems(info)
end
function NiceGoodsTips:SetBtnCon( )
local basic = self.model:GetGoodsBasicByTypeId(self.type_id)
for i, v in pairs(self.btns_list) do
v:SetActive(false)
end
local btns_list = {}
if self.model:IsShowPreviewBtn(self.type_id) then
table.insert(btns_list, self.yulanBtn)
self.yulanBtn:SetActive(true)
else
self.yulanBtn:SetActive(false)
end
if self.is_show_btn then
if (self.goods_vo.use > 0 or self.goods_vo.use_way ~= "") and self.mainVo.level >= self.goods_vo.level then
table.insert(btns_list, self.shiyongBtn)
end
if basic.jump > 0 then--and self.mainVo.level >= self.goods_vo.level then
table.insert(btns_list, self.jumpBtn)
end
if self.goods_vo.compose > 0 then
table.insert(btns_list, self.hechengBtn)
end
if self.goods_vo.goods_num > 1 then
table.insert(btns_list, self.splitBtn)
end
if self.goods_vo.sell > 0 then
table.insert(btns_list, self.chushouBtn)
end
if MarketModel:getInstance():IsGoodsCanUpShelves(self.goods_vo) then
table.insert(btns_list, self.shelvesUpBtn)
end
if basic and basic.drop == 1 then
table.insert(btns_list, self.dropBtn)
end
end
local hide_yulan_btn = false
if GoodsModel:getInstance().show_warehouse == true and self.goods_vo.pos == GoodsModel.GOODS_POS_TYPE.bag then
hide_yulan_btn = true
btns_list = {self.storeBtn}
elseif self.goods_vo.pos == GoodsModel.GOODS_POS_TYPE.warehouse then
hide_yulan_btn = true
btns_list = {self.takeBtn}
elseif self.goods_vo.pos == GoodsModel.GOODS_POS_TYPE.hunt_store then
hide_yulan_btn = true
btns_list = {self.takeBtn}
end
if hide_yulan_btn then
self.yulanBtn:SetActive(false)
end
if CapsuleEggModel:getInstance():IsShowCapsuleEggTakeOutBtn() then--龙神宝库扭蛋临时仓库显示取出按钮
btns_list = {self.capsuleEggTakeBtn}
end
--自定义显示的按钮
if self.show_btn_list then
btns_list = self:ShowCustomBtns()
end
local btns_len = #btns_list
self.btns_con_obj:SetActive(btns_len > 0)
local local_index = 0
local local_offset_h = 55
for k, v in ipairs(btns_list) do
local b = self.is_show_btn
or CapsuleEggModel:getInstance():IsShowCapsuleEggTakeOutBtn()--龙神宝库仓库需要显示按钮
v:SetActive(b)
if b then
print(v)
SetAnchoredPosition(v.transform, 8, local_index * local_offset_h - 504)
local_index = local_index + 1
end
end
if not hide_yulan_btn then
if self.goods_vo.type == 32 or self.goods_vo.type == 34 then
self.yulanBtn:SetActive(true)
end
end
end
function NiceGoodsTips:CheckSecondView()
if self.goods_vo.type == GoodsModel.TYPE.DESIGNATION then--称号类型物品直接发激活协议
local designation_id = DesignationModel:GetInstance():GetDesignationIdByGoodsId(self.goods_vo.type_id)
if designation_id ~= 0 then
DesignationModel:GetInstance():Fire(DesignationModel.REQUEST_DESIGNATION, 41106, self.goods_vo.type_id, designation_id, 1)
else
Message.show("称号物品有点问题哦~请联系GM")
end
return
elseif self.goods_vo.type == GoodsModel.TYPE.FASHION and self.goods_vo.subtype ~= GoodsModel.FASHION_LIMIT_SUB_TYPE then--时装体验卡物品不走这里的激活协议
local fashion_id,color_id = FashionModel:getInstance():GetFashionIdByGoodsId(self.type_id)
local cur_cfg = Config.Fashionstarup[fashion_id.."@"..color_id.."@0"]
if cur_cfg then
local pos = cur_cfg.pos_id
FashionModel:GetInstance():Fire(FashionEvent.REQUEST_FASHION_PROTOCOL, 41306, pos, fashion_id, color_id)
else
Message.show("时装物品有点问题哦~请联系GM")
end
return
end
if self.goods_vo.use == 1 then
if self.goods_vo.goods_num > 1 then
BagModel:getInstance():Fire(BagModel.OPEN_BATHANDLE_VIEW, self.goods_vo, SplitView.TYPE.BAT_USE)
else
self.model:Fire(GoodsModel.REQUEST_CCMD_EVENT, 15050, self.goods_vo.goods_id, self.goods_vo.type_id, 1)
end
else
self.model:Fire(GoodsModel.REQUEST_CCMD_EVENT, 15050, self.goods_vo.goods_id, self.goods_vo.type_id, 1)
end
end
function NiceGoodsTips:ShowCustomBtns()
local temp_list = {}
for _, v in pairs(self.btns_list) do
v:SetActive(false)
end
for _, v in pairs(self.show_btn_list) do
if self[v] then
table.insert(temp_list, self[v])
end
end
return temp_list
end
function NiceGoodsTips:DestroySuccess( )
cc.ActionManager:getInstance():removeAllActionsFromTarget(self.designation_image)
if self.change_count_id then
self.addNumComponent:UnBind(self.change_count_id)
self.change_count_id = nil
self.addNumComponent:DeleteMe()
self.addNumComponent = nil
end
if self.change_jin_id then
self.mainVo:UnBind(self.change_jin_id)
self.change_jin_id = nil
end
if self.change_lockJin_id then
self.mainVo:UnBind(self.change_lockJin_id)
self.change_lockJin_id = nil
end
if self.change_silver_id then
self.mainVo:UnBind(self.change_silver_id)
self.change_silver_id = nil
end
if self.score_change_event_id then
GoodsModel:getInstance():UnBind(self.score_change_event_id)
self.score_change_event_id = nil
end
if self.shop_view then
self.shop_view:DeleteMe()
self.shop_view = nil
end
end
function NiceGoodsTips:UpdateShopView( )
if not self.shop_view then
self.shop_view = ShopBuySubView.New(self.shop_con)
end
self.shop_view:SetData(self.shop_data)
self.shop_view:SetPosition(9,-141)
end