源战役客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

311 rindas
11 KiB

GodActivityCommonView = GodActivityCommonView or BaseClass(BaseItem)
local GodActivityCommonView = GodActivityCommonView
-- GodActivityCommonView.Width = 200
-- GodActivityCommonView.Height = 90
function GodActivityCommonView:__init(parent_wnd,prefab_asset,layer_name)
self.base_file = "godActivity"
self.layout_file = "GodActivityCommonView"
self.layer_name = layer_name
self.model = GodModel:getInstance()
self.full_screen = true
-- self.ani_right = 400
-- self.adjust_mid = {left = 300, right = 800}
self.list_item = {}
self:Load()
self.model:Fire(GodConst.REQ_ACTIVITY_COMMON_INFO)
CustomActivityModel:getInstance():SetGoodsCanFly(false)
end
function GodActivityCommonView:Load_callback()
self.nodes = {
"scroll_1", "scroll_1/Viewport/Content_1",
"icon_money_one:img:obj", "lb_money_one:tmp", "lb_money_ten:tmp", "icon_money_ten:img",
"btn_one/lb_btn_one:tmp", "btn_one:obj", "btn_ten:obj", "btn_ten/lb_btn_ten:tmp",
"btn_tip:obj", "lb_all_time:tmp", "btn_one/free_red:obj",
"bg_1:raw","bg_2:raw","bg_3:raw","bg_4:raw","click_mask:obj",
"goods_show_4:img", "goods_show_6:img", "goods_show_3:img", "goods_show_5:img", "goods_show_1:img", "goods_show_2:img",
-------------------------
"con_item_5", "con_item_2", "con_item_4", "con_item_3", "con_item_1", "free_label:tmp",
}
self:GetChildren(self.nodes)
self:AddEvents()
self.lb_btn_one_tmp.text = "单次召唤"
self.lb_btn_ten_tmp.text = "十回召唤"
self:UpdateView()
self:SetPoolReward()
self:SetLeftReward()
lua_resM:setOutsideRawImage(self,self.bg_1_raw,"/client/assets/icon/god/bg/god_draw_bg_1.png")
lua_resM:setOutsideRawImage(self,self.bg_2_raw,"/client/assets/icon/god/bg/god_draw_bg_2.png")
lua_resM:setOutsideRawImage(self,self.bg_3_raw,"/client/assets/icon/god/bg/god_draw_bg_3.png")
lua_resM:setOutsideRawImage(self,self.bg_4_raw,"/client/assets/icon/god/bg/god_draw_bg_4.png")
end
function GodActivityCommonView:RefreshRed( )
if self.is_loaded then
--宠物生活技能 每日免费抽奖一次
local left_free_draw_times = self.model:GetGodLeftFreeDrawTimes()
local free_red = left_free_draw_times > 0
local num = GoodsModel:getInstance():GetTypeGoodsNum(self.model.acitvity_cost_id)
self.free_red_obj:SetActive(num > 0 or free_red)
end
end
function GodActivityCommonView:AddEvents( )
local function call_back( target )
if target == self.btn_tip_obj then
EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, 173 .. "@" .. 90)
elseif target == self.btn_one_obj then
self:StartGo(1)
elseif target == self.btn_ten_obj then
self:StartGo(10)
end
end
AddClickEvent(self.btn_tip_obj,call_back,false)
AddClickEvent(self.btn_one_obj,call_back,false)
AddClickEvent(self.btn_ten_obj,call_back,false)
local function ANS_ACTIVITY_COMMON_INFO( )
self:UpdateView()
end
self:BindEvent(self.model, GodConst.ANS_ACTIVITY_COMMON_INFO, ANS_ACTIVITY_COMMON_INFO)
local function on_update_red_dot( )
self:RefreshRed()
end
self:BindEvent(self.model, GodConst.UpdateRedDot, on_update_red_dot)
local function ANS_ACTIVITY_PLAY( pool_type, draw_type, result_data )
--抽奖完成,显示抽奖特效
if pool_type == GodConst.ActivityType.Common then
self:ShowDrawEffect(pool_type, draw_type, result_data)
self.click_mask_obj:SetActive(true)
end
end
self:BindEvent(self.model, GodConst.ANS_ACTIVITY_PLAY, ANS_ACTIVITY_PLAY)
end
function GodActivityCommonView:StartGo( use_type )
local conf_tag = use_type == 1 and "lottery_single" or "lottery_ten"
local have_num = GoodsModel:getInstance():GetTypeGoodsNum(self.model.acitvity_cost_id)
local one_cost_conf = Config.Godkv[conf_tag].value_content
local need_num = stringtotable(one_cost_conf)[1][3]
--宠物生活技能
local left_free_draw_times = self.model:GetGodLeftFreeDrawTimes()
if left_free_draw_times > 0 and use_type == 1 then
self.model:Fire(GodConst.REQ_ACTIVITY_PLAY,GodConst.ActivityType.Common, use_type == 1 and 1 or 2,0)
return
end
if have_num >= need_num then
self.model:Fire(GodConst.REQ_ACTIVITY_PLAY,GodConst.ActivityType.Common, use_type == 1 and 1 or 2,0)
else
local function yes_call( )
self.model:Fire(GodConst.REQ_ACTIVITY_PLAY,GodConst.ActivityType.Common, use_type == 1 and 1 or 2,1)
end
local price = GoodsModel:getInstance():GetGoodsPrice(self.model.acitvity_cost_id)
local need_cost = price * (need_num - have_num)
local have_money = RoleManager.Instance.mainRoleInfo:GetRealJin()
local good_name = GoodsModel:getInstance():getGoodsName(self.model.acitvity_cost_id,true)
local content = string.format( "<color=#fdffc2>%s</color> 购买 %sx%d 召唤 %s 次神座", need_cost,good_name,need_num - have_num,use_type )
if self.model.isAutoBuyActivityCommon then
yes_call()
else
function toggle_function( flag )
self.model.isAutoBuyActivityCommon = flag
end
--需要显示购买提示界面
local data = {
titleText = "温馨提示",
nameText = "",
price = need_cost,
okText = "确定",
gold_res = "ui_momey_icon_1",--货币类型
priceText = content,
ok_callback = yes_call,
toggle_function = toggle_function,
nameText = "是否花费",
insufficientText = "",
}
GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, data)
end
end
end
function GodActivityCommonView:UpdateView( )
local function call_backack( )
if self._use_delete_method then return end
self:UpdateBlessAwardList()
self:RefreshMoney()
self:RefreshRed()
end
TimeManager.GetInstance():StartTime("GodActivityCommonView_CheckRedDot", 0.2, call_backack)
end
function GodActivityCommonView:RefreshMoney( )
local one_cost_conf = Config.Godkv["lottery_single"].value_content
local ten_cost_conf = Config.Godkv["lottery_ten"].value_content
one_cost_conf = stringtotable(one_cost_conf)[1]
ten_cost_conf = stringtotable(ten_cost_conf)[1]
local goods_id = one_cost_conf[2]
local goods_num = GoodsModel:getInstance():GetTypeGoodsNum( goods_id )
-- if goods_num > 0 then
local goods_icon = GoodsModel:getInstance():GetGoodsBasicByTypeId( goods_id ).goods_icon
lua_resM:setOutsideImageSprite(self,self.icon_money_ten_img,GameResPath.GetGoodsIcon(goods_icon),true)
lua_resM:setOutsideImageSprite(self,self.icon_money_one_img,GameResPath.GetGoodsIcon(goods_icon),true)
self.lb_money_one_tmp.text = "x" .. one_cost_conf[3]
self.lb_money_ten_tmp.text = "x" .. ten_cost_conf[3]
-- else
-- local price = GoodsModel:getInstance():GetGoodsPrice(goods_id)
-- local goods_icon = GoodsModel:getInstance():GetGoodsBasicByTypeId( 100000 ).goods_icon
-- lua_resM:setOutsideImageSprite(self,self.icon_money_rest_img,GameResPath.GetGoodsIcon(goods_icon),true)
-- lua_resM:setOutsideImageSprite(self,self.icon_money_ten_img,GameResPath.GetGoodsIcon(goods_icon),true)
-- lua_resM:setOutsideImageSprite(self,self.icon_money_one_img,GameResPath.GetGoodsIcon(goods_icon),true)
-- self.lb_money_ten_tmp.text = price * one_cost_conf[3]
-- self.lb_money_one_tmp.text = price * ten_cost_conf[3]
-- self.lb_money_rest_tmp.text = WordManager:ConvertNum(RoleManager.Instance.mainRoleInfo.jin)
-- end
--宠物生活技能 每日免费抽奖一次
local left_free_draw_times = self.model:GetGodLeftFreeDrawTimes()
if left_free_draw_times > 0 then
self.icon_money_one_obj:SetActive(false)
self.lb_money_one_tmp.text = ""
self.free_label_tmp.text = "本次免费"
else
self.icon_money_one_obj:SetActive(true)
self.free_label_tmp.text = ""
end
end
--累计奖励
function GodActivityCommonView:UpdateBlessAwardList( )
if not self.is_loaded then return end
local base_data = self.model:GetActivityCommonInfo()
if not base_data then return end
local conf = self.model:GetCommonConfByPhase(base_data.phase)
if not conf then return end
-------------------------
local blessing_award = stringtotable(conf.awards)--累计奖励
-------------------------
for i,v in ipairs(blessing_award) do
self.list_item[i] = self.list_item[i] or self:CreateItem(GodActivityRewardItem, self["con_item_" .. i], self.layer_name)
self.list_item[i]:SetData("common",v)
end
self.lb_all_time_tmp.text = string.format("累计次数:<color=#2CF86F>%d</color>",base_data.blessing)
-------------------------
end
function GodActivityCommonView:SetPoolReward( )
if not self.is_loaded then return end
local base_data = self.model:GetActivityCommonInfo()
if not base_data then return end
-------------------------
local show_list = {}
local lv = RoleManager.Instance.mainRoleInfo.level
for k,v in pairs(Config.Godnormalpool) do
if (v.phase == base_data.phase or v.phase == 0) and v.need_lv <= lv and v.show ~= 0 then
local temp = stringtotable(v.awards)[1]
temp[4] = v.show
table.insert( show_list, temp )
end
end
local function sort_call( a,b )
return a[4] < b[4]
end
table.sort( show_list, sort_call )
self.award_item_con_1 = self.award_item_con_1 or self:AddUIComponent(UI.ItemListCreator)
local item_data_list = {
data_list = show_list,
item_con = self.Content_1,
scroll_view = self.scroll_1,
obj_pool_type = UIObjPool.UIType.AwardItem,
item_width = 88,
item_height = 88,
start_x = 15,
start_y = -11,
space_x = 6,
space_y = 1,
create_frequency = 0.01,
alignment = UnityEngine.TextAnchor.UpperLeft,
on_update_item = function(item, i, v)
item:IsNeedShowSeries(true)
item:SetDataWithMapId(v[2], 0, v[1])
item:SetItemSize(84, 84)
end,
}
self.award_item_con_1:UpdateItems(item_data_list)
end
function GodActivityCommonView:SetLeftReward( )
local conf = GodConst.ActivityCommonShowConf
for i=1,#conf do
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId( conf[i].id )
if basic then
lua_resM:setOutsideImageSprite(self,self["goods_show_" .. i .. "_img"],GameResPath.GetGoodsIcon(basic.goods_icon),true)
end
end
end
function GodActivityCommonView:SetData( data )
self.data = data
if self.is_loaded then
self.need_refreshData = false
self:UpdateView()
else
self.need_refreshData = true
end
end
function GodActivityCommonView:ShowDrawEffect( pool_type, draw_type, result_data )
if not self.is_loaded then return end
self.delay_show_reward = function()
if self.delay_result_id then
GlobalTimerQuest:CancelQuest(self.delay_result_id)
self.delay_result_id = nil
end
self.model:Fire(GodConst.OPEN_ACTIVITY_RESULT_VIEW, result_data )
self.model.draw_ing = false
if self._use_delete_method then return end
self.click_mask_obj:SetActive(false)
end
self.model.draw_ing = true
self.delay_result_id = setTimeout(self.delay_show_reward,3.5)
local data = {
name = "ui_shenzuochoujiang",
scale = 1.5,
pos = co.TempVector2(80, 95),
-- pos = co.TempVector2(135, 95),
time = 3.25,
}
self.model:Fire(GodConst.OPEN_ACTIVITY_EFFECT_VIEW,data)
end
function GodActivityCommonView:__delete( )
self.model.draw_ing = false
CustomActivityModel:getInstance():SetGoodsCanFly(true)
if self.delay_result_id then
GlobalTimerQuest:CancelQuest(self.delay_result_id)
self.delay_result_id = nil
-------------------------
if self.delay_show_reward then
local function delay( )
self.delay_show_reward()
end
setTimeout(delay,0.2)
end
end
end