源战役客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

339 řádky
11 KiB

--[[
新功能开启,包括功能图标、技能图标的展示
]]
NewModelOpenView = NewModelOpenView or BaseClass(BaseView)
local NewModelOpenView = NewModelOpenView
--模型资源图标ID
NewModelOpenView.model_icon_res = {
[1] = {ab_name = "mainRole_asset", res_name = "mainrole_level_btn"},
[2] = {ab_name = "mainUI_asset", res_name = "icon_leftBottom_1"}, --巫女
[3] = {ab_name = "mainUI_asset", res_name = "icon_leftBottom_32"}, --契兽
[4] = {ab_name = "mainUI_asset", res_name = "guide_icon_xingpang"}, --星盘
[5] = {ab_name = "mainUI_asset", res_name = "guide_icon_baoju"}, --宝具
[6] = {ab_name = "mainUI_asset", res_name = "guide_icon_bingwu"}, --兵武
[9] = {ab_name = "mainUI_asset", res_name = "icon_leftBottom_22"}, --宝宝
}
function NewModelOpenView:__init()
self.base_file = "func"
self.layout_file = "NewModelOpenView"
self.layer_name = "Activity"
self.destroy_imm = true
self.change_scene_close = true
self.open_guide_close = nil
self.hide_maincancas = false --隐藏主界面
self.click_bg_toClose = true
self.use_background = true --不一定显示遮罩
self.close_fog = true
self.model = FuncOpenModel:getInstance()
self.mainVo = RoleManager.Instance.mainRoleInfo
self.time_diff = 10
self.model.is_open_func_model_view = true
self.load_callback = function ()
self:LoadSuccess()
self:AddEvent()
end
self.open_callback = function ( )
self:OpenSuccess()
end
self.close_callback = function ()
self:CloseSuccess()
end
self.destroy_callback = function ( )
self:DestroySuccess()
end
end
function NewModelOpenView:Open( voList )
self.voList = voList
self.cur_vo = self.voList[1] or {}
BaseView.Open(self)
end
function NewModelOpenView:LoadSuccess()
self.center_obj = self:GetChild("mid/center_cont").gameObject
self.mask_obj = self:GetChild("mid/mask_img").gameObject
self.mask_img = self:GetChild("mid/mask_img"):GetComponent("Image")
self.title_img = self:GetChild("mid/center_cont/title_img"):GetComponent("Image")
self.name_txt = self:GetChild("mid/center_cont/up_cont/name_txt"):GetComponent("TMPro.TextMeshProUGUI")
self.desc_txt = self:GetChild("mid/center_cont/up_cont/desc_txt"):GetComponent("TMPro.TextMeshProUGUI")
self.time_txt = self:GetChild("mid/center_cont/time_txt"):GetComponent("TMPro.TextMeshProUGUI")
self.icon_cont = self:GetChild("icon_cont")
self.model_cont = self:GetChild("icon_cont/model_cont")
self.effect = self:GetChild("mid/center_cont/effect")
self.effect2 = self:GetChild("mid/center_cont/effect2")
self.up_cont = self:GetChild("mid/center_cont/up_cont").gameObject
-- self:MoveUIToBack(self.effect)
local function delay_method( )
self:AddUIEffect("ui_jihuoxinxitong01", self.effect, self.layer_name, nil, 1, true,nil,nil, nil, nil,nil,UIPartical.RenderingOther_List.UIBackward)
self:AddUIEffect("ui_jihuoxinxitong02", self.effect2, self.layer_name, nil, 1, true,nil,nil, nil, nil,nil,UIPartical.RenderingOther_List.UIBackward)
end
setTimeout(delay_method, 0.02) --延时0.02秒后再加载特效防止层级错乱
local nodes = {
"mid/center_cont/bg_img:img","mid/center_cont/up_cont/tipImg:img",
}
self:GetChildren(nodes)
self.mask_img.alpha = 0
self.mask_obj.transform.sizeDelta = Vector2(ScreenWidth,ScreenHeight)
-- self.mask_obj:SetActive(true)
local function bg_back_func( ... )
if self.background_wnd and self.background_wnd:GetComponent("RawImageExtend") then
self:MoveUIToBack(self.background_wnd:GetComponent("RawImageExtend"))
end
local function func( ... )
self:MoveUIToBack(self.bg_img_img)
end
lua_resM:setOutsideImageSprite(self, self.bg_img_img, GameResPath.GetFuncIcon("open_func_model_bg"),false,func)
end
if self.background_wnd then
bg_back_func()
else
self.bg_back_func = bg_back_func
end
self.transform:SetInsetAndSizeFromParentEdge(self.transform.EdgeLeft, 0, ScreenWidth)
end
function NewModelOpenView:AddEvent()
local function on_click( target )
if target == self.mask_obj then
if Scene.Instance.main_role then
local cfg = Scene.Instance.main_role:GetMainRoleStorycfg(PoseState.STORY)
if cfg and cfg.ignore_click then
return
end
end
self:PlayAction()
end
end
AddClickEvent(self.mask_obj, on_click)
end
function NewModelOpenView:OpenSuccess()
GlobalEventSystem:Fire(SceneEventType.CLOSE_DIALOGUE_VIEW)
GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
GlobalEventSystem:Fire(EventName.STOPAUTOFIGHT)
self:UpdateView()
self:PlaySound()
end
function NewModelOpenView:PlaySound( )
if IsTableEmpty(self.cur_vo) then
return
end
if self.cur_vo then
lua_soundM:StopEffect(self, LuaSoundManager.SOUND_TYPE.FUNC, self.sound_id)
-- lua_soundM:StopEffect(self, LuaSoundManager.SOUND_TYPE.FUNC, self.sound_id)
if self.cur_vo.sound and Trim(self.cur_vo.sound) ~= "" then
if lua_soundM then
self.sound_id = lua_soundM:PlayEffect(self, Trim(self.cur_vo.sound),false,LuaSoundManager.SOUND_TYPE.FUNC)
end
end
end
end
function NewModelOpenView:UpdateView()
if IsTableEmpty(self.cur_vo) then
return
end
if not self.cur_vo.fashion_type or self.cur_vo.fashion_type == 0 then
return
end
lua_resM:setImageSprite(self, self.title_img, "func_asset", "open_func_title3", true)
self:UpdateModelCon()
--设置文本
-- self.name_txt.text = self.cur_vo.saying
self.desc_txt.text = "[ " .. self.cur_vo.saying .. " ]"
--倒计时
self:StartTimer()
--创建图标
self:CreateFlyIcon()
lua_resM:setImageSprite(self, self.tipImg_img, "func_asset", "open_func_tip_"..self.cur_vo.fashion_type, true)
end
function NewModelOpenView:UpdateModelCon( )
--ai娘、座驾的模型展示需要单独做一些位置调整(原则,尽量不调整模型的pos,能调con的位置就调con的参数,模型太大调整scale)
local model_pos = nil
local model_scale = nil
local model_con_pos = Vector3(9,-10,0)
local rotate = nil
local can_rotate = nil
if self.cur_vo.fashion_type == FuncOpenModel.TypeId.FHorse then--座驾
-- model_pos = Vector3(0, 135, 0)
-- model_scale = 160
model_con_pos = Vector3(9,-120,350)
rotate = Vector3(0, 160, 0)
can_rotate = true
elseif self.cur_vo.fashion_type == FuncOpenModel.TypeId.FJarvis then--ai娘
-- model_pos = Vector3(0, 120, 0)
model_scale = 240
model_con_pos = Vector3(35,-30,150)
elseif self.cur_vo.fashion_type == FuncOpenModel.TypeId.FPearl then--宝具
-- model_pos = Vector3(0, 180, 0)
-- model_scale = 220
model_con_pos = Vector3(15,-20,0)
elseif self.cur_vo.fashion_type == FuncOpenModel.TypeId.FWeapon then--武器
-- model_pos = Vector3(0, 180, 0)
-- model_scale = 200
model_con_pos = Vector3(45,-10,280)
elseif self.cur_vo.fashion_type == FuncOpenModel.TypeId.FCloud then--AI娘翅膀
model_con_pos = Vector3(20,-10,0)
elseif self.cur_vo.fashion_type == FuncOpenModel.TypeId.FWing then--翅膀
model_con_pos = Vector3(20,-10,0)
elseif self.cur_vo.fashion_type == FuncOpenModel.TypeId.Child then--宝宝
model_con_pos = Vector3(20, -10, 0)
model_scale = 500
end
self.model_cont.transform.localPosition = model_con_pos
local res_data = {
father_node = self,
transform = self.model_cont,
fashion_type = self.cur_vo.fashion_type,
figure_id = self.cur_vo.figure_id,
position = model_pos,
scale = model_scale,
figure_texture = 1,
layer_name = self.layer_name,
can_rotate = can_rotate,
rotate = rotate,
ui_model_type = UIModelCommon.ModelType.BackModel,
}
FuncOpenModel:getInstance():SetModelRes(res_data)
if self.cur_vo.fashion_type == FuncOpenModel.TypeId.FHorse then--座驾
lua_soundM:PlayEffect(self, "activate_moto", false, LuaSoundManager.SOUND_TYPE.UI, 1)
end
end
function NewModelOpenView:StartTimer( )
if self.time_id == nil then
self.time_txt.text = HtmlColorTxt(self.time_diff, "#2cf86f") .. " 秒后自动关闭"
local function onTimer()
self.time_diff = self.time_diff - 1
if self.time_diff >= 0 then
self.time_txt.text = HtmlColorTxt(self.time_diff, "#2cf86f") .. " 秒后自动关闭"
else
if self.time_id then
GlobalTimerQuest:CancelQuest(self.time_id)
self.time_id = nil
end
self:PlayAction()
end
end
self.time_id = GlobalTimerQuest:AddPeriodQuest(onTimer,1,-1)
end
end
function NewModelOpenView:CreateFlyIcon( )
if self.cur_vo then
self.image_obj = UiFactory.createChild(self.icon_cont, UIType.ImageExtend)
self.image_obj.transform.sizeDelta = Vector2(78, 78)
self.image_icon = self.image_obj:GetComponent("ImageExtend")
local ab_name, res_name = "activityIcon_asset", ""
if self.cur_vo.winId and self.cur_vo.subId then
local fun_vo = OpenFun.LinkWin[self.cur_vo.winId.."@"..self.cur_vo.subId]
if fun_vo then
res_name = fun_vo.icon_res
end
end
if self.cur_vo.model_type and self.cur_vo.model_type ~= 0 and self.cur_vo.icon_res_name ~= nil then
res_name = self.cur_vo.icon_res_name
end
self.center_obj:SetActive(true)
self.image_obj:SetActive(false)
local function callback( ... )
if ab_name == "activityIcon_asset" then
self.image_obj.transform.sizeDelta = Vector2(60, 60)
end
end
if ab_name and ab_name ~= "" and res_name and res_name ~= "" then
lua_resM:setImageSprite(self, self.image_icon, ab_name, res_name, true, callback)
if ab_name == "activityIcon_asset" then
self.image_obj.transform.sizeDelta = Vector2(60, 60)
end
end
end
end
function NewModelOpenView:PlayAction( )
local function callback( )
GlobalEventSystem:Fire(EventName.SHOW_FUNC_OPEN_ICON,self.voList)
self.image_obj:SetActive(false)
self:Close()
end
if self.cur_vo and self.cur_vo.ignore_fly then
callback()
return
end
if not self.image_obj then
callback()
return
end
local pos = self.cur_vo.pos
if self.cur_vo then
pos = self.model:GetFlyPos(self.cur_vo)
end
self.center_obj:SetActive(false)
self.image_obj:SetActive(true)
self.model_cont.gameObject:SetActive(false)
if pos ~= nil then
self.tween_id = TweenLite.to(self, self.image_obj.transform, TweenLite.UiAnimationType.POS, pos, 0.8, callback)
end
end
--关闭界面后做什么
function NewModelOpenView:CloseSuccess( )
--完成引导
local main_role = Scene.Instance.main_role
if main_role then
main_role:ChangeState(PoseState.STAND)
end
local helpVo, endVo = GuideModel:getInstance():GetHelpVo(HelpType.TASK_ITEM_SHOW,1)
if helpVo and not endVo then
GlobalEventSystem:Fire(EventName.FINISH_CURRENT_HELP_STEP,helpVo)
else
--当前没有引导才继续做任务
GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK)
GlobalEventSystem:Fire(EventName.START_AUTO_DO_TASK)
end
-- if self.cur_vo.winId and self.cur_vo.subId then
-- OpenFun.Open(self.cur_vo.winId, self.cur_vo.subId)
-- else
-- end
if self.image_obj then
self.image_obj:SetActive(false)
end
GlobalEventSystem:Fire(EventName.SHOW_FUNC_OPEN_ICON,self.voList)
end
function NewModelOpenView:DestroySuccess( )
self.model.is_open_func_model_view = false
self:ClearUIEffect(self.effect)
self:ClearUIEffect(self.effect2)
if self.time_id then
GlobalTimerQuest:CancelQuest(self.time_id)
self.time_id = nil
end
end