源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

264 行
8.4 KiB

--[[@------------------------------------------------------------------
@description:幻光激活展示界面
@author:huangcong
----------------------------------------------------------------------]]
LightActiveView = LightActiveView or BaseClass(BaseView)
local LightActiveView = LightActiveView
function LightActiveView:__init()
self.base_file = "light"
self.layout_file = "LightActiveView"
self.layer_name = "Activity"
self.destroy_imm = true
self.use_background = false
self.append_to_ctl_queue = true --是否要添加进界面堆栈
self.need_show_money = false --是否要显示顶部的金钱栏
self.use_background = true
self.hide_maincancas = true --全屏界面需要放开隐藏主UI
self.append_to_ctl_queue = true --添加进入控制队列
self.item_list = {}
self.model = LightModel:getInstance()
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 LightActiveView:DestroySuccess( )
if self.time_id then
TimerQuest.CancelQuest(GlobalTimerQuest, self.time_id)
self.time_id = nil
end
end
function LightActiveView:Open(cur_select_right)
self.cur_select_right = cur_select_right or 1001
GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT) --停止自动挂机
BaseView.Open(self)
end
function LightActiveView:OpenSuccess( )
self:UpdateView()
end
function LightActiveView:LoadSuccess()
local nodes = {
"bg:raw","closeBtn:obj","activeBtn:obj","roleCon",
"attr_scroll", "attr_scroll/Viewport/attr_con",
"powerText:txt", "skillDesc:txt", "lb_attr:txt", "skillName:txt", "lb_attr_des:txt",
"lightNameImg:img", "skillImg:img","icon_special:img", "titleBg",
}
self:GetChildren(nodes)
local function func( ... )
self:MoveUIToBack(self.bg, nil,nil, {alpha = 0.8})
self:MoveUIToBack(self.titleBg, nil,nil, {alpha = 0.8})
end
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("openFunc_light_bg"), false,func)
if self.need_load_again then
self:UpdateView()
end
end
function LightActiveView:AddEvent()
local on_click = function ( click_obj )
if self.closeBtn_obj == click_obj then--关闭按钮
self:Close()
elseif self.activeBtn_obj == click_obj then--激活
self:Close()
--如果是引导,则在退出,统一跳转
-- local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,1)
-- if not helpVo then
-- GlobalEventSystem:Fire(EventName.OPEN_NEW_MAIN_ROLE_VIEW,NewMainRoleModel.TabId.Light,nil,self.cur_select_right)
-- end
end
end
AddClickEvent(self.activeBtn_obj, on_click)
AddClickEvent(self.closeBtn_obj, on_click)
end
function LightActiveView:UpdateView()
if not self.is_loaded then
self.need_load_again = true
return
end
if not self.cur_select_right then
print("huangcong:LightActiveView [start:95] 数据不正确:")
return
end
self:ShowModel()
self:UpdateSkill()
self:UpdateAttrProp()
self:UpdateSpeacielProp()
lua_resM:setImageSprite(self, self.lightNameImg_img, "light_asset", "light_"..self.cur_select_right,true)
end
--更新技能
function LightActiveView:UpdateSkill( )
if not self.is_loaded then return end
local conf = self.model:GetLightConfOne( self.cur_select_right )
if not conf then return end
local skill_info = stringtotable(conf.skill)
local skill_id = tonumber(skill_info[1])
local skill_conf = SkillManager:getInstance():getSkillFromConfig(skill_info[1])
self.skillName_txt.text = HtmlColorTxt(Trim(skill_conf.name or ""), "#ffde6c")
--特殊写死,只需要描述的一部分
if skill_id == 120001 then
self.skillDesc_txt.text = "攻击时有30%的概率令敌人流血,每秒损失1%气血"
else
self.skillDesc_txt.text = Trim(skill_conf.lvs[tonumber(skill_info[2])].desc or "")
end
lua_resM:setOutsideImageSprite(self, self.skillImg_img, GameResPath.GetSkillIcon(tonumber(skill_info[1])),true)
end
--更新属性列表
function LightActiveView:UpdateAttrProp( )
if not self.is_loaded then return end
local basic = self.model:GetLightInfoOne( self.cur_select_right )
local grade,star = 0,0
if basic then
grade = basic.grade
star = basic.lv
end
-------------------------
local conf = self.model:GetLightLvConfOne( self.cur_select_right, grade, star )
if not conf then return end
-------------------------
local base_attr = stringtotable(conf.attrs)
self.powerText_txt.text = GetFighting(base_attr)
--处理一下attr_list 改成两个一组
local count = math.ceil(#base_attr / 2)
local new_base_attr = {}
for i = 1, count do
local data = {
attr_id1 = base_attr[i*2-1] and base_attr[i*2-1][1] or nil,
value1 = base_attr[i*2-1] and base_attr[i*2-1][2] or nil,
next_value1 = base_attr[i*2-1] and base_attr[i*2-1][3] or nil,
attr_id2 = base_attr[i*2] and base_attr[i*2][1] or nil,
value2 = base_attr[i*2] and base_attr[i*2][2] or nil,
next_value2 = base_attr[i*2] and base_attr[i*2][3] or nil,
}
table.insert(new_base_attr, data)
end
if not self.attr_list_com then
self.attr_list_com = self:AddUIComponent(UI.ItemListCreator)
end
local info = {
data_list = new_base_attr,
item_con = self.attr_con,
item_class = LightAttrItem,
item_width = 430,
item_height = 36,
space_x = 0,
start_x = 4,
scroll_view = self.attr_scroll,
create_frequency = 0.05,
is_scroll_back_on_update = false,
init_value = "LightActiveItem",--不同的预制
on_update_item = function(item, i, v)
item:SetData(i,v,true)
end,
}
self.attr_list_com:UpdateItems(info)
end
--更新特殊数
function LightActiveView:UpdateSpeacielProp( )
local basic = self.model:GetLightInfoOne( self.cur_select_right )
local grade,star = 0,0
if basic then
grade = basic.grade
star = basic.lv
end
-------------------------
--当前属性,下层属性
local lv_conf = self.model:GetLightLvConfOne( self.cur_select_right, grade, star )
if not lv_conf then return end
--特殊属性
local temp_data2 = stringtotable(lv_conf.spe_attrs)
if temp_data2[1] then
local _, name1, _, val1 = WordManager:GetPropertyInfo(tonumber(temp_data[1][1]), tonumber(temp_data[1][2]))
self.lb_attr_txt.text = name1 .. "" .. val1
self.lb_attr_des_txt.text = ""
SetAttrIconByColorType(self, self.icon_special_img, tonumber(temp_data[1][1]), nil, 2)
else
local min_val = 999
local min_grade,min_lv = 0,0
local attr_id = false
for k,v in pairs(Config.Visuslv) do
if v.id == self.cur_select_right then
for a,b in pairs(stringtotable(v.spe_attrs)) do
attr_id = attr_id or b[1]
if b[1] == attr_id then
if b[2] < min_val then
min_val = b[2]
min_grade = v.grade
min_lv = v.lv
end
end
end
end
end
if attr_id then
local _, name1, _, val1 = WordManager:GetPropertyInfo(attr_id, min_val)
self.lb_attr_txt.text = name1 .. "" .. val1
self.lb_attr_des_txt.text = "" .. min_grade .. "" .. min_lv .. "" .. "解锁)"
SetAttrIconByColorType(self, self.icon_special_img, attr_id, nil, 2)
else
self.lb_attr_txt.text = ""
self.lb_attr_des_txt.text = ""
end
end
end
function LightActiveView:ShowModel( )
if not self.is_loaded then
return
end
local res_data = {
father_node = self,
transform = self.roleCon,
fashion_type = FuncOpenModel.TypeId.Clothes,
raycast_size = Vector2(0,0),
scale = 210,
position = Vector3(0,-80,-142),
layer_name = "UI",
ui_model_type = UIModelCommon.ModelType.BackModel,
show_shadow = false,
use_bloom = false,
light_id = self.cur_select_right,
}
FuncOpenModel:getInstance():SetModelRes(res_data)
end
function LightActiveView:Close()
--完成引导
local helpVo, endVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_LIGHT,1)
if helpVo then
GlobalEventSystem:Fire(EventName.OPEN_NEW_MAIN_ROLE_VIEW,NewMainRoleModel.TabId.Light,nil,self.cur_select_right)
GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
end
if not helpVo or endVo then
GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK) --引导需要 保留
end
BaseView.Close(self)
self:ActivitySkill()
end
--关闭界面,直接激活节能
function LightActiveView:ActivitySkill()
self.model:Fire(LightModel.REQUEST_CCMD_EVENT, 14703, self.cur_select_right)
end