源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

2013 lines
76 KiB

--ui挂接模型处理
UIModelCommon = UIModelCommon or BaseClass(UIPartical)
UIModelCommon.ModelType =
{
RT = 1,
BackModel = 2,
Model = 3,
}
local UIModelCommon = UIModelCommon
local ModelPartName = ModelPartName
function UIModelCommon:__init(go,parent,model_data)
self.particle_mgr = ParticleManager:getInstance()
self.model_type = UIModelCommon.ModelType.RT
self.gameObject = go
self.parent = parent
self.model_data = model_data
self.particle_list = {}
self.load_res_target = {}
self.show_shadow = model_data.show_shadow
self.raycastParent = model_data.raycastParent
self.layer_name = model_data.layer_name or "UI"
self.delay_play_action_timer_list = {}
self.pearl_list = {}
self.pearl_parent = {}
end
function UIModelCommon:__delete()
self.cache_bones = {}
self:ClearActionTimerList()
self:RemoveAllParticle()
if self.cache_effect_list then
for obj_type, list in pairs(self.cache_effect_list) do
for k,v in pairs(list) do
destroy(v.go)
end
end
end
if self.light_go then
destroy(self.light_go)
end
if self.clothe then
self.clothe:DeleteMe()
self.clothe = nil
end
if self.head_wear then
self.head_wear:DeleteMe()
self.head_wear = nil
end
if self.weapon_clothe_obj then
self.weapon_clothe_obj:DeleteMe()
self.weapon_clothe_obj = nil
self.weapon_clothe_id = nil
end
if self.role then
destroy(self.role)
self.role = nil
end
if self.horse_gameObject then
destroy(self.horse_gameObject)
self.horse_gameObject = nil
end
if self.gameObject then
destroy(self.gameObject)
end
if self.weapon_hand_list then
for k,v in pairs(self.weapon_hand_list) do
destroy(v)
self.weapon_hand_list[k] = nil
end
end
if self.head_wear_animator then
self.head_wear_animator = nil
end
if self.deay_show_warSoul then
GlobalTimerQuest:CancelQuest(self.deay_show_warSoul)
self.deay_show_warSoul = nil
end
if self.deay_show_light then
GlobalTimerQuest:CancelQuest(self.deay_show_light)
self.deay_show_light = nil
end
if self.weapon_event_id then
GlobalEventSystem:UnBind(self.weapon_event_id)
self.weapon_event_id = nil
end
if self.fahion_event_id then
GlobalEventSystem:UnBind(self.fahion_event_id)
self.fahion_event_id = nil
end
if self.cloth_event_id then
GlobalEventSystem:UnBind(self.cloth_event_id)
self.cloth_event_id = nil
end
if self.args_fun_event_id then
GlobalEventSystem:UnBind(self.args_fun_event_id)
self.args_fun_event_id = nil
end
if self.viseble_change_id then
GlobalEventSystem:UnBind(self.viseble_change_id)
self.viseble_change_id = nil
end
for k,v in pairs(self.pearl_list) do
v:DeleteMe()
end
self.pearl_list = {}
for k,v in pairs(self.pearl_parent) do
if self.pearl_parent[k] then
destroy(self.pearl_parent[k])
self.pearl_parent[k] = nil
end
end
self.pearl_parent = {}
if self.raycastGo then
destroy(self.raycastGo)
end
lua_resM:clearReference(self.load_res_target)
self:StopSkillPreViewTimer()
end
function UIModelCommon:AddEvents()
if self.can_rotate then
local function touch_begin(target,pos_x, pos_y)
self.pos_x = pos_x
end
local function draging(target,pos_x, pos_y)
self:OnDragging(pos_x, pos_y)
end
local function touch_end(target,pos_x, pos_y)
end
local rtGo = self.parent.gameObject
if self.model_data.raycast_size then
self.parent:GetComponent("RawImage").raycastTarget = false
self.raycastGo = GameObject.New("raycast_"..self.parent.gameObject.name)
self.raycastGo.transform:SetParent(self.parent.transform)
local eImage = self.raycastGo:AddComponent(typeof(LuaFramework.EmptyRaycast))
self.raycastGo.transform.localPosition = Vector3.zero
self.raycastGo.transform.sizeDelta = Vector2(self.model_data.raycast_size.x, self.model_data.raycast_size.y)
self.raycastGo.transform.localScale = Vector3.one
eImage.raycastTarget = true
-- if type(self.raycastParent) ~= "userdata" and self.raycastParent.use_background then
self.raycastGo.transform:SetSiblingIndex(1)
-- else
-- self.raycastGo.transform:SetSiblingIndex(0)
-- end
rtGo = self.raycastGo
else
self.parent:GetComponent("RawImage").raycastTarget = true
end
AddDragBeginEvent(rtGo, touch_begin)
AddDragEvent(rtGo, draging)
AddDragEndEvent(rtGo, touch_end)
-- AddUpEvent(self.parent.gameObject, touch_end)
elseif self.skill_preview and self.skill_id then
local function on_click()
self:PlaySkillEffect(self.role, self.skill_id)
end
local rtGo = self.parent.gameObject
if self.model_data.raycast_size then
self.parent:GetComponent("RawImage").raycastTarget = false
self.raycastGo = GameObject.New("raycast_"..self.parent.gameObject.name)
self.raycastGo.transform:SetParent(self.parent.transform)
local eImage = self.raycastGo:AddComponent(typeof(LuaFramework.EmptyRaycast))
self.raycastGo.transform.localPosition = Vector3.zero
self.raycastGo.transform.sizeDelta = Vector2(self.model_data.raycast_size.x, self.model_data.raycast_size.y)
self.raycastGo.transform.localScale = Vector3.one
eImage.raycastTarget = true
self.raycastGo.transform:SetSiblingIndex(1)
rtGo = self.raycastGo
else
self.parent:GetComponent("RawImage").raycastTarget = true
end
AddClickEvent(rtGo,on_click)
else
self.parent:GetComponent("RawImage").raycastTarget = false
end
if self.type and self.type == SceneBaseType.MainRole then
--武器变化
local weapon_fun = function (_type, weapon_id, career, weapon_clothe)
if self.do_not_main_role_cloth_res_change then return end
if not IsNull(self.role) then
self:CreateWeapon(_type, weapon_id, career, weapon_clothe)
end
end
self.weapon_event_id = GlobalEventSystem:Bind(SceneEventType.MAIN_ROLE_WEAPON_RES_CHANGE, weapon_fun)
--时装变化(暂不包括武器时装)
local fashion_fun = function (_type, fashion_model_id, texture_id)
if self.do_not_main_role_cloth_res_change then return end
if not IsNull(self.role) then
if self.clothe_res_id then
if self.clothe_res_id == fashion_model_id then
self:CreateClothTexture(fashion_model_id, texture_id)
else
self:SetData(self.parent, self.model_data)
end
end
end
end
self.fahion_event_id = GlobalEventSystem:Bind(SceneEventType.MAIN_ROLE_FASHION_RES_CHANGE, fashion_fun)
--衣服改变
local cloth_fun = function (_type, clothe_res_id)
if self.do_not_main_role_cloth_res_change then return end
if not IsNull(self.role) then
self:SetData(self.parent, self.model_data)
end
end
self.cloth_event_id = GlobalEventSystem:Bind(SceneEventType.MAIN_ROLE_CLOTH_RES_CHANGE, cloth_fun)
--默认摄像机参数改变
local on_args_fun = function ()
self:SetCameraArgs(true)
end
self.args_fun_event_id = GlobalEventSystem:Bind(EventName.UPDATE_UIMODEL_CAMERA_DEFAULT_ARGS, on_args_fun)
end
--visible改变时重新播动作
local action_fun = function()
if not IsNull(self.role) and self.replay_action_name then
local is_show = self.role and self.role.activeInHierarchy
if not is_show then
self._has_set_hide = true
end
--从隐藏到显示
if is_show == true and self._has_set_hide then
self._has_set_hide = false
local last_action = self.replay_action_name or "show"
local action_list = {last_action}
self:DelayPlayNextAction(nil, action_list, 0)
end
end
end
self.viseble_change_id = GlobalEventSystem:Bind(BaseView.ChangeVisible, action_fun)
end
function UIModelCommon:OnDragging(pos_x, pos_y)
if pos_x and self.pos_x then
local delta_x = pos_x - self.pos_x
local speed = 6
if self.role then
if delta_x > 0 then
self.rotate = self.rotate - speed
-- self.role.transform:Rotate(Vector3(0, -speed, 0))
if self.horse_transform and (self.type == SceneBaseType.Include_Horse
or self.type == SceneBaseType.Baby_Include_Horse) then
--如果人物身上有马,要旋转马,因为self.role被丢进马里去当子物体了
self.horse_transform:Rotate(Vector3.up, -speed, UnityEngine.Space.World)
else
self.role.transform:Rotate(Vector3.up, -speed, UnityEngine.Space.World)
end
else
self.rotate = self.rotate + speed
-- self.role.transform:Rotate(Vector3(0, speed, 0))
if self.horse_transform and (self.type == SceneBaseType.Include_Horse
or self.type == SceneBaseType.Baby_Include_Horse) then
--如果人物身上有马,要旋转马,因为self.role被丢进马里去当子物体了
self.horse_transform:Rotate(Vector3.up, speed, UnityEngine.Space.World)
else
self.role.transform:Rotate(Vector3.up, speed, UnityEngine.Space.World)
end
end
self.pos_x = pos_x
end
else
print("---UIModelClassByRT--OnDragging-pos_x-:", pos_x)
print("---UIModelClassByRT--OnDragging-pos_y-:", pos_y)
end
end
function UIModelCommon:ClearActionTimerList()
if self.delay_play_action_timer_list then
for i, id in ipairs(self.delay_play_action_timer_list) do
GlobalTimerQuest:CancelQuest(id)
end
self.delay_play_action_timer_list = {}
end
end
function UIModelCommon:PlayActions(action_name_list,action_delta,animator)
if IsNull(self.role) then return end
animator = animator or self.role:GetComponent("Animator")
if not IsTableEmpty(action_name_list) then
local action_name = action_delta and action_name_list[1] or table.remove(action_name_list, 1)
if action_name then
local animator = self.role:GetComponent("Animator")
animator:CrossFade( action_name,0, 0.0 )
if not IsTableEmpty(action_name_list) then
self.delay_play_action_timer_list = self.delay_play_action_timer_list or {}
if action_delta then
self:DelayPlayNextActionLoop(animator, action_name_list, action_delta)
else
self:DelayPlayNextAction(animator, action_name_list)
end
end
end
end
end
--随机循环动作列表 暂时不添加音效
--action_name_list.idle_name 默认待机动作
function UIModelCommon:DelayPlayNextActionLoop(animator, action_name_list, action_delta)
if animator == nil then return end
if IsTableEmpty(action_name_list) then return end
animator:Update(0)
local cur_state = animator:GetCurrentAnimatorStateInfo(0)
local action_time = 0
if not cur_state then return end
action_time = cur_state.length
local idle_action = action_name_list.idle_name or "idle"
local delay_play = function ()
local action_name = action_name_list[ math.random(1,#action_name_list)]
animator:CrossFade(action_name, 0.0, 0.0)
self:DelayPlayNextActionLoop(animator, action_name_list, action_delta)
end
local play_idle = function ()
animator:CrossFade(idle_action, 0.3, 0.0 )
end
--清理计时器列表
if #self.delay_play_action_timer_list >= 20 then
self:ClearActionTimerList()
end
action_delta = action_delta < action_time and action_time + 1 or action_delta
table.insert(self.delay_play_action_timer_list, GlobalTimerQuest:AddDelayQuest(play_idle,action_time))
table.insert(self.delay_play_action_timer_list, GlobalTimerQuest:AddDelayQuest(delay_play,action_delta))
end
--延迟播放下一个动作
function UIModelCommon:DelayPlayNextAction(animator, action_name_list, force_delay_action_time)
if not IsTableEmpty(action_name_list) then
animator = animator or self.role:GetComponent("Animator")
local cur_state = 0
local action_time = 0
if force_delay_action_time and force_delay_action_time > 0 then
action_time = force_delay_action_time
else
animator:Update(0)
cur_state = animator:GetCurrentAnimatorStateInfo(0)
action_time = cur_state.length
end
if animator and action_time and action_time > 0 then
local delay_play = function ()
if IsNull(animator) or self._use_delete_method then
return
end
local action_name = table.remove(action_name_list, 1)
if animator and action_name then
animator:CrossFade(action_name, 0.1, 0.0 )
if not IsNull(self.head_wear_animator) then
self.head_wear_animator:CrossFade(action_name, 0.2, 0.0 )
end
self:CreateEffect(self.type, self.clothe_res_id, self.role, action_name)
if not IsTableEmpty(action_name_list) then
self:DelayPlayNextAction(animator, action_name_list)
else
--播完动作再重置一下相机灯光参数
if self.use_light_data then
self:ApplyCameraLightData()
end
end
else
return
end
end
table.insert(self.delay_play_action_timer_list, GlobalTimerQuest:AddDelayQuest(delay_play,action_time))
else
return
end
end
return
end
--创建武器
function UIModelCommon:CreateWeapon(_type, weapon_res_id, career, weapon_clothe)
if _type and _type == SceneBaseType.Monster then
return
end
self.weapon_res_id = weapon_res_id
if _type and weapon_res_id then
local abName,weapon_attach_list,weapon_res_list = GameResPath.GetWeaponRes(_type,weapon_res_id,career)
local function localWeaponCallback(objs, is_gameObject)
if not self._use_delete_method then
if weapon_attach_list and objs then
if self.weapon_container then
for k,v in pairs(self.weapon_container) do
destroy(v.go)
end
end
if self.weapon_clothe_obj then
self.weapon_clothe_obj:DeleteMe()
self.weapon_clothe_obj = nil
end
local bone_go = nil
self.weapon_container = {}
for k,boneName in ipairs(weapon_attach_list) do
bone_go = FindBone(self.role.transform,boneName)
if bone_go then
local go = is_gameObject and objs[k] or newObject(objs[k-1])
if go then
go.transform.parent = bone_go.transform
go.transform.localPosition = Vector3.zero
go.transform.localRotation = Quaternion.Euler(Vector3.zero)
go.transform.localScale = Vector3.one
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
self:CheckShadow(go, weapon_attach_list[i])
self.weapon_container[boneName] = {go = go, abName = abName, resName = weapon_res_list[k], index = k}
go:SetActive(true)
-- if weapon_clothe and weapon_clothe ~= "" and tonumber(weapon_clothe) ~= 0 then
-- local mesh = go:GetComponentInChildren(typeof(UnityEngine.MeshRenderer))
-- if mesh and mesh.material then
-- local res = weapon_res_id .. "_" .. weapon_clothe
-- self.weapon_clothe_obj = Weapon.New( mesh.material, res)
-- end
-- end
end
end
end
--部件特效,参数为部件类型与id
self:CreateEffect(SceneBaseType.FWeapon, self.weapon_res_id)
end
end
end
if self.role and self.role.transform and abName and weapon_res_list then
LuaResManager:getInstance():loadPrefabs(self,abName,weapon_res_list, localWeaponCallback)
end
end
end
--时装衣服贴图
function UIModelCommon:CreateClothTexture(fashion_model_id, texture_id)
self.fashion_model_id = fashion_model_id
self.texture_id = texture_id
-- if fashion_model_id and texture_id and tonumber(texture_id) ~= 0 and self.gameObject then --使用贴图
-- if self.clothe then
-- self.clothe:DeleteMe()
-- self.clothe = nil
-- end
-- local texture_res = fashion_model_id .. "_" .. texture_id
-- self.skin_mesh_renderer = self.gameObject:GetComponentInChildren(typeof(UnityEngine.SkinnedMeshRenderer))
-- if self.skin_mesh_renderer and self.skin_mesh_renderer.material and texture_res then
-- self.clothe = Clothe.New(self.skin_mesh_renderer.material,texture_res)
-- end
-- end
end
--创建翅膀
function UIModelCommon:CreateWing(_type, wing_id)
if _type and wing_id then
if self.role_type == SceneBaseType.Pet then--巫女+翅膀
_type = SceneBaseType.FCloud
end
local abName, resName = GameResPath.GetModelClotheRes(_type, wing_id)
local function localWingCallback(objs, is_gameObject)
if self._use_delete_method then
return
end
if not objs or not objs[0] then
logWarn("cannot find wing res = "..self.wing_id)
return
end
local go = is_gameObject and objs[0] or newObject(objs[0])
go:SetActive(true)
local bone = FindBone(self.role.transform, AttachNode.Wing)
if bone == nil then
return
end
go.transform:SetParent(bone)
go.transform.localPosition = Vector3.zero
go.transform.localRotation = Quaternion.identity
go.transform.localScale = Vector3.one
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
-- 修改翅膀节点下的面片渲染的sortingOrder与带Canvas组件的父节点同级,保证不会被UI背景盖住
local shinned_meshRender_com_list = go:GetComponentsInChildren(typeof(UnityEngine.SkinnedMeshRenderer),true)
if shinned_meshRender_com_list.Length > 0 then
for i=1,shinned_meshRender_com_list.Length do
shinned_meshRender_com_list[i-1].sortingOrder = self:GetCurrLayerDepth(self.layer_name)
end
end
-- 修改翅膀节点下的渲染队列
self:SetUILayer(self.parent.transform)
end
local animator = go:GetComponent("Animator")
if not IsNull(animator) then
animator.cullingMode = UnityEngine.AnimatorCullingMode.AlwaysAnimate
animator:CrossFade( "idle",0, 0.0 )
end
--部件特效,参数为部件类型与id
self:CreateEffect(SceneBaseType.FWing, self.wing_id, go)
end
if self.role.transform and abName and resName then
LuaResManager:getInstance():loadPrefab(self,abName,resName, localWingCallback)
end
end
end
--创建活跃度形象
function UIModelCommon:CreateLivenessImage(_type, image_id)
if _type and image_id and image_id ~= 0 then
local prefixStr = image_id < 10 and "00" or "0"
local effect_name = "effect_huoyuedu_" .. prefixStr .. image_id
self.particle_mgr:AddUIModelEffect(effect_name,self,true,nil,7,nil,nil,nil,nil,nil,false)
end
end
--创建头发
function UIModelCommon:CreateHeadWear(_type, head_wear_id, head_clothe_id)
--self.head_wear_id = head_wear_id
--self.head_clothe_id = head_clothe_id
if _type and head_wear_id then
local abName, resName = GameResPath.GetHeadRes(_type, head_wear_id)
local function localHeadWearCallback(objs, is_gameObject)
if self._use_delete_method then
return
end
if not objs or not objs[0] then
logWarn("cannot find headwear res = "..head_wear_id)
return
end
if self.default_headWear_go and self.default_headWear_abName then
lua_resM:AddObjToPool(self, self.default_headWear_abName, self.default_headWear_abName, self.default_headWear_go)
self.default_headWear_go = nil
self.default_headWear_abName = nil
end
local go = is_gameObject and objs[0] or newObject(objs[0])
go:SetActive(true)
local bone = FindBone(self.role.transform, AttachNode.Head)
if bone == nil then
return
end
go.transform:SetParent(bone)
go.transform.localPosition = Vector3.zero
go.transform.localRotation = Quaternion.identity
go.transform.localScale = Vector3.one
--头发动作
local animator = go:GetComponent("Animator")
if IsNull(animator) then
return
end
-- if self.curr_body_action_name then
-- animator:CrossFade(self.curr_body_action_name, 0, 0.0)
-- end
self.head_wear_animator = animator
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
self:CheckShadow(go, resName)
-- local mesh = go:GetComponentInChildren(typeof(UnityEngine.MeshRenderer))
-- if mesh and mesh.material then
-- if head_clothe_id and tonumber(head_clothe_id) ~= 0 then
-- if self.head_clothe then
-- self.head_clothe:DeleteMe()
-- self.head_clothe = nil
-- end
-- local texture_res = head_wear_id .. "_" .. head_clothe_id
-- self.head_clothe = Clothe.New(mesh.material, texture_res)
-- end
-- end
end
if self.role.transform and abName and resName then
if not resMgr:GetAssetBundle(abName) and self.career then--没有当前头发 需要异步加载 就先创建默认头饰
if self.default_headWear_go and self.default_headWear_abName then
--self:SetUILayer(self.default_headWear_go.transform, UIPartical.RenderingOther_List.DEFAULT)
lua_resM:AddObjToPool(self, self.default_headWear_abName, self.default_headWear_abName, self.default_headWear_go)
self.default_headWear_go = nil
self.default_headWear_abName = nil
end
local local_default_headWear_abName = ModelPartName[6] .. string.format("10%d000", self.career)
local local_default_headWear_go = lua_resM:GetObjFormPool(self, local_default_headWear_abName, local_default_headWear_abName)
if local_default_headWear_go then
local bone = FindBone(self.role.transform, AttachNode.Head)
if bone == nil then
return
end
local_default_headWear_go.transform:SetParent(bone)
local_default_headWear_go.transform.localPosition = Vector3.zero
local_default_headWear_go.transform.localRotation = Quaternion.identity
local_default_headWear_go.transform.localScale = Vector3.one
self.default_headWear_go = local_default_headWear_go
self.default_headWear_abName = local_default_headWear_abName
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
end
self:CheckShadow(self.default_headWear_go, resName)
end
LuaResManager:getInstance():loadPrefab(self,abName,resName, localHeadWearCallback)
end
end
end
--创建真·头饰,上面的那个应该叫头发
function UIModelCommon:CreateHatWear(hat_wear_id)
if hat_wear_id then
local abName, resName = GameResPath.GetHatRes(hat_wear_id)
local function localHeadWearCallback(objs, is_gameObject)
if self._use_delete_method then
return
end
if not objs or not objs[0] then
logWarn("cannot find headwear res = "..hat_wear_id)
return
end
if self.default_hat_go and self.default_hat_abName then
lua_resM:AddObjToPool(self, self.default_hat_abName, self.default_hat_abName, self.default_hat_go)
self.default_hat_go = nil
self.default_hat_abName = nil
end
local go = is_gameObject and objs[0] or newObject(objs[0])
go:SetActive(true)
local bone = FindBone(self.role.transform, AttachNode.Head)
if bone == nil then
return
end
go.transform:SetParent(bone)
go.transform.localPosition = Vector3.zero
go.transform.localRotation = Quaternion.identity
go.transform.localScale = Vector3.one
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
self:CheckShadow(go, resName)
-- local mesh = go:GetComponentInChildren(typeof(UnityEngine.MeshRenderer))
-- if mesh and mesh.material then
-- if head_clothe_id and tonumber(head_clothe_id) ~= 0 then
-- if self.head_clothe then
-- self.head_clothe:DeleteMe()
-- self.head_clothe = nil
-- end
-- local texture_res = hat_wear_id .. "_" .. head_clothe_id
-- self.head_clothe = Clothe.New(mesh.material, texture_res)
-- end
-- end
end
if self.role.transform and abName and resName then
if not resMgr:GetAssetBundle(abName) and self.career then--没有当前头发 需要异步加载 就先创建默认头饰
if self.default_hat_go and self.default_hat_abName then
--self:SetUILayer(self.default_hat_go.transform, UIPartical.RenderingOther_List.DEFAULT)
lua_resM:AddObjToPool(self, self.default_hat_abName, self.default_hat_abName, self.default_hat_go)
self.default_hat_go = nil
self.default_hat_abName = nil
end
local local_default_hat_abName = ModelPartName[6] .. string.format("10%d000", self.career)
local local_default_hat_go = lua_resM:GetObjFormPool(self, local_default_hat_abName, local_default_hat_abName)
if local_default_hat_go then
local bone = FindBone(self.role.transform, AttachNode.Head)
if bone == nil then
return
end
local_default_hat_go.transform:SetParent(bone)
local_default_hat_go.transform.localPosition = Vector3.zero
local_default_hat_go.transform.localRotation = Quaternion.identity
local_default_hat_go.transform.localScale = Vector3.one
self.default_hat_go = local_default_hat_go
self.default_hat_abName = local_default_hat_abName
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
end
self:CheckShadow(self.default_hat_go, resName)
end
LuaResManager:getInstance():loadPrefab(self,abName,resName, localHeadWearCallback)
end
end
end
function UIModelCommon:CreateLightEffect( light_id, parent_go )
-- if self.deay_show_light then
-- GlobalTimerQuest:CancelQuest(self.deay_show_light)
-- self.deay_show_light = nil
-- end
-- local function delay( )
-- local show_type = (self.model_type == UIModelCommon.ModelType.BackModel) and "UIBackRole" or "UI"
-- self.light_effect_id = self.particle_mgr:AddTargetEffect(LightModel:GetInstance():GetLightResById(light_id), self.role, true, nil, nil, 7,nil,nil,nil,nil,show_type)
-- if self.light_effect_id then
-- self.particle_list[self.light_effect_id] = self.light_effect_id
-- end
-- end
-- self.deay_show_light = setTimeout(delay,0)
local effect_obj_type = nil
local effect_vo = {name = LightModel:GetInstance():GetLightResById(light_id)}
local bone = FindBone(parent_go and parent_go.transform or self.transform, "root")
if bone then
local function load_finish_func(objs, is_gameObject)
if not objs or not objs[0] then
return
end
if IsNull(bone) then
if is_gameObject then destroy(objs[0]) end
return
end
local go = is_gameObject and objs[0] or newObject(objs[0])
if not self.light_go then--没有就直接赋值
self.light_go = go
else--有就直接销毁原来的继续赋值新的
if self.light_go then
destroy(self.light_go)
end
self.light_go = go
end
go:SetActive(true)
if effect_vo.is_world_particle then
AttachGameRoot(go.transform)
else
go.transform:SetParent(bone)
end
SetLocalPosition(go.transform)
SetLocalRotation(go.transform)
SetLocalScale(go.transform, 1)
if effect_obj_type or (self.model_data and self.model_data.attach_game_root) then
self:SetUILayer(go.transform, UIPartical.RenderingOther_List.DEFAULT)
elseif ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(go.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(go.transform)
end
if not effect_obj_type then
local effect_sortingOrder = self:GetCurrLayerDepth(self.layer_name)
UIDepth.SetUIDepth(go,false,effect_sortingOrder)
end
end
lua_resM:loadPrefab(self, effect_vo.name, effect_vo.name, load_finish_func, false)
end
end
function UIModelCommon:CreateWarSoulEffect( warSoul_effect_res,warSoul_effect_pos,warSoul_effect_scale )
if self.deay_show_warSoul then
GlobalTimerQuest:CancelQuest(self.deay_show_warSoul)
self.deay_show_warSoul = nil
end
local function delay( )
local function load_callback( ... )
if warSoul_effect_scale then
self.particle_mgr:SetEffectScale(self.warSoul_effect_id, warSoul_effect_scale)
end
if warSoul_effect_pos then
self.particle_mgr:SetEffectLocalPos(self.warSoul_effect_id, warSoul_effect_pos.x,warSoul_effect_pos.y,warSoul_effect_pos.z)
end
local effect = self.particle_mgr:GetEffect(self.warSoul_effect_id)
local root_dummy_node = FindBone(self.role.transform, "Dummy001")
-- self.transform.localRotation = Quaternion.Euler(0, 0, 0)
if root_dummy_node and effect then
effect.transform:SetParent(root_dummy_node)
-- effect.localPosition = warSoul_effect_pos or Vector3.zero
effect.transform.localRotation = Quaternion.Euler(0, 180, 0)
-- effect.localScale = Vector3.one
end
end
self.warSoul_effect_id = self.particle_mgr:AddTargetEffect(warSoul_effect_res, self.role, true, nil, nil, 7, nil,nil,nil,nil,"UI" or self.layer_name,load_callback,nil,nil,nil,nil,warSoul_effect_pos)
if self.particle_list and self.warSoul_effect_id then
self.particle_list[self.warSoul_effect_id] = self.warSoul_effect_id
end
end
self.deay_show_warSoul = setTimeout(delay,0.01)
end
--创建足迹
function UIModelCommon:CreateFootmark(footmark_id)
end
function UIModelCommon:PlaySkillEffect(attacker, skill_id, next_anim, custom_end_callback)
if attacker and skill_id and SkillManager and SkillManager.Instance then
--正在播放技能中
if self.duration_timer then return end
local movie_cfg = SkillManager.Instance:GetFightSkillMovie(skill_id)
if movie_cfg then
if movie_cfg.anim then
if self.skill_preview_callback then
self.skill_preview_callback(1)
end
local action_name = {[1] = movie_cfg.anim,}
self:PlayActions(action_name)
local duration_time = movie_cfg.back_swing and movie_cfg.back_swing or 2
self:StopSkillPreViewTimer()
local function PlaySkillEffectEnd()
if self.skill_preview_callback then
self:PlayActions({[1] = "idle",})
self.skill_preview_callback(2)
elseif next_anim then
self:PlayActions({[1] = next_anim,})
end
if custom_end_callback then
custom_end_callback()
end
self:StopSkillPreViewTimer()
end
self.duration_timer = GlobalTimerQuest:AddDelayQuest(PlaySkillEffectEnd,duration_time)
end
if movie_cfg.particles then
for i = 1, #movie_cfg.particles do
local cfg = movie_cfg.particles[i]
local res = cfg.res
local x, y = attacker.transform.position.x, attacker.transform.position.y
local dir = GameMath.AngleToDirection(270 - self.rotate)
local scale = cfg.scale
local attach_type = cfg.attach_type
local play_time = cfg.play_time
if cfg.custom_angle then
dir = GameMath.AngleToDirection(cfg.custom_angle)
end
local pos_type = cfg.pos_type
--所有特效都是特定播放轨迹,所以这里简单的都从人物跟节点发出
pos_type = 0
self.particle_mgr:AddUIModelEffect( res, self, false, play_time, attach_type,dir, nil,nil,nil,nil,nil,false)
-- --播放特效方法1
-- self.particle_mgr:AddUIModelEffect(res,self,true,nil,attach_type,nil,nil,nil,nil,nil,false)
--播放后特效方法2
-- local particle_id = nil
-- if pos_type == 2 or pos_type == 6 then --在攻击者坐标上
-- if cfg.offset_dist and cfg.offset_dist ~= 0 and dir then
-- co.NormaliseXYTable(dir)
-- local dist = GameMath.ChangeEllipseValue(dir, cfg.offset_dist)
-- x = x + dir.x * dist
-- y = y + dir.y * dist
-- end
-- particle_id = self.particle_mgr:AddPosEffect( res, co.TableXY(x, y), (play_time ~= 0), play_time, dir ,nil, nil, nil, nil, nil, max_depth)
-- elseif pos_type == 7 then --特效沿攻击方向移动
-- local move_speed = cfg.move_speed or 100
-- local move_dist = cfg.move_dist or 300
-- particle_id = self.particle_mgr:AddPosEffect( res, co.TableXY(x, y), true, 0 , dir, nil, nil, move_speed, move_dist, nil, max_depth)
-- else
-- particle_id = self.particle_mgr:AddTargetEffect(res, attacker, (play_time ~= 0), play_time, dir, attach_type, nil, nil, nil, max_depth)
-- end
-- if particle_id then
-- if cfg.scale then
-- self.particle_mgr:SetEffectScale(particle_id, cfg.scale)
-- end
-- self.particle_list[particle_id] = true
-- end
end
end
end
end
end
function UIModelCommon:CreateEffect(obj_type, id, parent_go, action_name, effect_obj_type)
if effect_obj_type then
obj_type = effect_obj_type
end
if obj_type == SceneBaseType.Role or obj_type == SceneBaseType.MapModel then
return
end
-- RT加载怪物模型时不加载一切特效
if obj_type == SceneBaseType.Monster and self.model_type == UIModelCommon.ModelType.RT then
return
end
self.cache_effect_list = self.cache_effect_list or {}
local cache_effect_type = action_name and obj_type .. "_action" or obj_type
if self.cache_effect_list[cache_effect_type] then
for k,v in pairs(self.cache_effect_list[cache_effect_type]) do
destroy(v.go)
end
end
self.cache_effect_list[cache_effect_type] = {}
local parent_go = parent_go or self.transform
--武器要区分职业
-- if obj_type and obj_type == SceneBaseType.FWeapon then
-- print('=======Msh:UIModelCommon.lua[851] =======', id, action_name)
-- PrintCallStack()
-- end
if obj_type and obj_type == SceneBaseType.FWeapon and id and tonumber(id) < 1000 then
local career = self.career
if not career and RoleManager.Instance and RoleManager.Instance.mainRoleInfo then
career = RoleManager.Instance.mainRoleInfo.career
end
career = career or 1
id = tonumber(id) + career*1000
end
local temp_cfg = Config.SceneObjectParticle[obj_type] and Config.SceneObjectParticle[obj_type][id]
if action_name and action_name ~= "" then
--动作特效
temp_cfg = temp_cfg and temp_cfg.action_effect_list
temp_cfg = temp_cfg and temp_cfg[action_name]
-- self.last_action_effect_list = self.last_action_effect_list or {}
else
--模型特效
temp_cfg = temp_cfg and temp_cfg.body_effect_list
local temp_id = obj_type.."_"..id
if self.last_effect_id and self.last_effect_id == temp_id then
return
end
self.last_effect_id = temp_id
end
if not temp_cfg then
return
end
local function on_load_res( bone_name, effect_vo )
if not parent_go then
return
end
local bone = FindBone(parent_go and parent_go.transform or self.transform, bone_name)
if bone or effect_vo.is_world_particle then
local function load_finish_func(objs, is_gameObject)
if not objs or not objs[0] then
return
end
if IsNull(bone) then
if is_gameObject then destroy(objs[0]) end
return
end
local go = is_gameObject and objs[0] or newObject(objs[0])
table.insert(self.cache_effect_list[cache_effect_type], {go = go})
if effect_vo.is_world_particle then
AttachGameRoot(go.transform)
else
go.transform:SetParent(bone)
end
SetLocalPosition(go.transform)
SetLocalRotation(go.transform)
SetLocalScale(go.transform, 1)
if effect_obj_type or (self.model_data and self.model_data.attach_game_root) then
self:SetUILayer(go.transform, UIPartical.RenderingOther_List.DEFAULT)
elseif ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(go.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(go.transform)
end
if not effect_obj_type then
local effect_sortingOrder = self:GetCurrLayerDepth(self.layer_name)
UIDepth.SetUIDepth(go,false,effect_sortingOrder)
end
end
lua_resM:loadPrefab(self, effect_vo.name, effect_vo.name, load_finish_func, false)
end
end
for key, effect_vo in pairs(temp_cfg) do
local bone_name = effect_vo.bone
if obj_type and obj_type == SceneBaseType.FWeapon then
for k,v in pairs(self.weapon_container) do
parent_go = v.go
on_load_res(bone_name, effect_vo)
end
else
on_load_res(bone_name, effect_vo)
end
end
end
--主动添加挂在自己身上的例子特效
function UIModelCommon:AddParticle(id,particle_tranform,attach_type,is_weapon,effect_pos)
if self._use_delete_method then
return
end
if is_weapon then
if self.weapon then
local effect_root = self.weapon.transform:Find("Bone_wq")
if effect_root then
particle_tranform.parent = effect_root
particle_tranform.localPosition = effect_pos or Vector3.zero
particle_tranform.localRotation = Quaternion.Euler(0, 0, 0)
particle_tranform.localScale = Vector3.one
self.particle_list[id] = particle_tranform
local effect = self.particle_mgr:GetEffect(id)
if effect then
effect:SetSpeed(self.particle_speed)
end
end
end
else
local bone_name = ParticleAttachNode[attach_type]
local transform = self.role
if bone_name and transform then
local bone = nil
if bone_name == AttachNode.SceneObj then
bone = transform
else
bone = FindBone(self.role.transform,bone_name)
end
if bone == nil then
logWarn("AddParticle ".. transform.name .." cannot find bone " .. bone_name)
return
end
particle_tranform.parent = bone.transform
particle_tranform.localPosition = effect_pos or Vector3.zero
if bone_name == AttachNode.SceneObj then
particle_tranform.localRotation = Quaternion.Euler(self.rotateX, 0, 0)
else
particle_tranform.localRotation = Quaternion.Euler(0, 0, 0)
end
particle_tranform.localScale = Vector3.one
self.particle_list[id] = particle_tranform
local effect = self.particle_mgr:GetEffect(id)
if effect then
effect:SetSpeed(self.particle_speed)
end
end
end
end
--删除挂在伙伴身上的特效
--is_acive = false 被动删除挂在自己身上的粒子特效 由特效播放完来调用
--is_acive = true 主动删除挂在自己身上的特效 会通知particlemanager去删除 默认false
function UIModelCommon:RemoveParticle(id,is_acive)
self.particle_list[id] = nil
if is_acive then
self.particle_mgr:DelEffect(id)
end
end
function UIModelCommon:CheckShadow(go, name)
--先不处理
if true then
return
end
if not go or not self.show_shadow then
return
end
local scene_info =
{
shadow_angle = 60,
shadow_alpha = 0.7,
shadow_len = 7,
}
local scale = scene_info.shadow_len / 7
local light_x = math.cos(scene_info.shadow_angle * math.pi / 180) * scale
local light_z = (math.sin(scene_info.shadow_angle * math.pi / 180)) * scale
local shadow2_mat_light_vector4 = self.model_data.shadow2_light_pos or Vector4(light_x, -1, light_z, 0)
--local shadow2_mat_plane_vector4 = Vector4(0, 1, 0, 0.5)
local shadow2_mat_plane_vector4 = self.model_data.shadow2_plane_pos or Vector4(0, 1, 0, 0.5)
local render = go:GetComponentInChildren(typeof(UnityEngine.SkinnedMeshRenderer)) or go:GetComponentInChildren(typeof(UnityEngine.MeshRenderer))
if render then
local mats = render.sharedMaterials
local lua_mats = {}
local shadow_index = nil
local mats_len = mats.Length
local need_create_shadow = true
local change = false
for i = 0, mats_len - 1 do
lua_mats[i + 1] = mats[i]
if IsNull(mats[i]) then
shadow_index = i + 1
elseif string.find(mats[i].name, "shadow2", 1, true) then
mats[i]:SetVector("_LightDir", shadow2_mat_light_vector4)
mats[i]:SetFloat("_ShadowAlpha", scene_info.shadow_alpha)
mats[i]:SetVector("_Plane", shadow2_mat_plane_vector4)
-- self.shadow_timer_list[name] = {shadow2_mat_plane_vector4 = shadow2_mat_plane_vector4,material = mats[i]}
need_create_shadow = false
elseif mats[i].shader.name == "Unlit/Texture" or string.find(mats[i].shader.name, "XRay", 1, true) then
mats[i].shader = ShaderTools.GetShader("Unlit-Texture-NoFog")
change = true
end
end
if not shadow_index then
shadow_index = mats_len + 1
end
if not lua_mats[shadow_index] and need_create_shadow then
local shadow2_mat = Material.New(ShaderTools.shadow2)
shadow2_mat:SetVector("_LightDir", shadow2_mat_light_vector4)
shadow2_mat:SetFloat("_ShadowAlpha", scene_info.shadow_alpha)
shadow2_mat:SetVector("_Plane", shadow2_mat_plane_vector4)
-- self.shadow_timer_list[name] = {shadow2_mat_plane_vector4 = shadow2_mat_plane_vector4,material = shadow2_mat}
lua_mats[shadow_index] = shadow2_mat
change = true
end
if change then
render.materials = lua_mats
end
end
end
--主动删除挂在伙伴身上的特效
function UIModelCommon:RemoveAllParticle()
for id,_ in pairs(self.particle_list) do
self.particle_mgr:DelEffect(id)
end
self.particle_list = {}
end
function UIModelCommon:GetCacheBones(transform, bone_name)
self.cache_bones = self.cache_bones or {}
local temp_bone = self.cache_bones[bone_name]
if temp_bone and not IsNull(temp_bone) then
return temp_bone
end
local transform = transform or self.transform
temp_bone = FindBone(transform, bone_name)
self.cache_bones[bone_name] = temp_bone
return temp_bone
end
function UIModelCommon:StopSkillPreViewTimer()
if self.duration_timer then
GlobalTimerQuest:CancelQuest(self.duration_timer)
self.duration_timer = nil
end
end
function UIModelCommon:GetRolePositionOffset()
local pos = Vector3(0, 0, 0)
if self.role_position_offset and (self.type == SceneBaseType.Role or self.type == SceneBaseType.MainRole) and self.clothe_res_id then
local career = 0
career = math.floor(self.clothe_res_id / 1000 )
if career and UIModelClassByRT.Role_Position_Offset[career] then
pos = UIModelClassByRT.Role_Position_Offset[career]
end
end
return pos
end
function UIModelCommon:ChangeModelLocalPosition(x, y, z)
if not self.role then return end
local offset = self:GetRolePositionOffset()
x = x or (self.role.transform.localPosition.x - offset.x)
y = y or (self.role.transform.localPosition.y - offset.y)
z = z or (self.role.transform.localPosition.z - offset.z)
self.role.transform.localPosition = Vector3(x, y, z) + offset
end
function UIModelCommon:GetModelDefaultLocalPosition( )
return self.default_position
end
function UIModelCommon:SetData(parent,model_data)
end
function UIModelCommon:LoadRole(model_data, role_con)
self.role_con = role_con
self.model_data = model_data
self.career = model_data.career
self.clothe_res_id = model_data.clothe_res_id
self.weapon_res_id = model_data.weapon_res_id
self.weapon_clothe_id = model_data.weapon_clothe_id
self.type = model_data.role_type or model_data.type or nil
self.size = model_data.size or Vector2(600,360)
model_data.action_name_list = model_data.action_name_list or {"show"}
self.action_name_list = model_data.action_name_list
self.replay_action_name = self.action_name_list[#self.action_name_list] or "show"
self.can_rotate = model_data.can_rotate == nil or model_data.can_rotate == true
self.scale = model_data.scale
self.position = model_data.position
self.fashion_model_id = model_data.fashion_model_id
self.texture_id = model_data.texture_id
self.action_delta = model_data.action_delta
self.renderSize = model_data.renderSize
self.partner_id = model_data.partner_id
self.skill_id = model_data.skill_id
self.lCallBack = model_data.lCallBack
self.wing_id = model_data.wing_id
self.image_id = model_data.image_id
self.head_wear_id = model_data.head_wear_id
self.head_clothe_id = model_data.head_clothe_id
self.footmark_id = model_data.footmark_id
self.light_id = model_data.light_id
self.warSoul_effect_res = model_data.warSoul_effect_res
self.warSoul_effect_pos = model_data.warSoul_effect_pos
self.warSoul_effect_scale = model_data.warSoul_effect_scale
self.use_bloom = model_data.use_bloom
self.free_param = model_data.free_param
self.pearl_vo = model_data.pearl_vo
self.pearl_pos = model_data.pearl_pos
self.rotate = model_data.rotate or 0
if self.type == SceneBaseType.Include_Horse then--self.free_param为契兽id
self.weapon_res_id = nil--坐骑上不要武器
end
if model_data.load_dance_pose then -- 如果是加载跳舞的模型,需要屏蔽武器
self.weapon_res_id = nil
end
-- self.bloom_camera = self.gameObject.transform:Find("Camera/BloomClipCamera"):GetComponent("Camera")
self.skill_preview = model_data.skill_preview
self.skill_preview_callback = model_data.skill_preview_callback
self.camera_args = model_data.camera_args
self.using_material = model_data.using_material --or "render_texture"
self.using_sprite_bg = model_data.using_sprite_bg
self.role_position_offset = model_data.role_position_offset
self.layer_name = model_data.layer_name or "UI"
self.talisman_id = model_data.talisman_id
self.show_reflection = model_data.show_reflection
self.reflect_pos = model_data.reflect_pos
self.show_root = model_data.show_root == nil and true or model_data.show_root
self.hat_wear_id = model_data.hat_wear_id
self.dynamic_bone = model_data.dynamic_bone
self.use_light_data = model_data.use_light_data
self.psionic_effect = model_data.psionic_effect -- 圣物光环特效
self.pokemon_diamond_effect = model_data.pokemon_diamond_effect --宠物宝石光环特效
self.show_baby_attack_effect = model_data.show_baby_attack_effect -- 宝宝攻击特效
self.show_jarvis_all_figure_data = model_data.show_jarvis_all_figure_data -- ai娘模型展示包括翅膀磁炮幻甲全套装备,如有需要使用请参考排行榜传参
self.effect_obj_type = model_data.effect_obj_type --特效主体类型
self.role_action_sound = model_data.role_action_sound
self.need_play_skill_effect = 101091 or model_data.need_play_skill_effect
self.do_not_main_role_cloth_res_change = model_data.do_not_main_role_cloth_res_change--时装更改广播之后,不要刷新uimodelcommon的改变
local anName,resName = GameResPath.GetModelClotheRes(self.type, self.clothe_res_id, self.dynamic_bone)
if self.fashion_model_id then --时装
anName,resName = GameResPath.GetModelClotheRes(self.type, self.fashion_model_id, self.dynamic_bone)
elseif self.type == SceneBaseType.Baby_Include_Horse then -- 宝宝骑载具
anName,resName = GameResPath.GetModelClotheRes(SceneBaseType.Baby, self.clothe_res_id, self.dynamic_bone)
end
local function loadRoleCallback(objs, is_gameObject)
if self._use_delete_method then
return
end
if not objs or not objs[0] then
return
end
self:RemoveAllParticle()
if self.role then
destroy(self.role)
end
self.role = is_gameObject and objs[0] or newObject(objs[0])
local animator = self.role:GetComponent("Animator")
if not IsNull(animator) then
local custom_speed = Config.ConfigModelSpeed.ModelActionSpeed[tonumber(self.clothe_res_id)]
if custom_speed then
if animator then
animator.speed = custom_speed
end
end
if self.type == SceneBaseType.Role or self.type == SceneBaseType.MainRole then
if animator then
self.custom_speed = Config.ConfigModelSpeed.MainRoleActionSpeed.Idle
animator.speed = self.custom_speed
end
end
animator.cullingMode = UnityEngine.AnimatorCullingMode.AlwaysAnimate
end
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.Model or self.model_type == UIModelCommon.ModelType.BackModel then
self.role.transform:SetParent(self.parent.transform)
else
self.role.transform:SetParent(role_con)
end
self.role.transform.localRotation = self.model_data.model_rotation and Quaternion.Euler(self.model_data.model_rotation) or Quaternion.identity
self.transform = self.role.transform
self.role.gameObject:SetActive(self.show_root)
if self.type == SceneBaseType.Include_Horse or --self.free_param为契兽id
self.type == SceneBaseType.Baby_Include_Horse then -- 普通载具或宝宝载具
local horse_abName,horse_resName
if self.type == SceneBaseType.Baby_Include_Horse then -- 宝宝载具
horse_abName,horse_resName = GameResPath.GetModelClotheRes(SceneBaseType.Baby_Horse, self.free_param)
elseif self.type == SceneBaseType.Include_Horse then -- 普通载具
horse_abName,horse_resName = GameResPath.GetModelClotheRes(SceneBaseType.Horse, self.free_param)
end
local function loadHorseCallback(objs, is_gameObject)
if self._use_delete_method then
return
end
if not objs or not objs[0] then
return
end
if self.horse_gameObject then
destroy(self.horse_gameObject)
end
self.horse_gameObject = is_gameObject and objs[0] or newObject(objs[0])
self.horse_transform = self.horse_gameObject.transform
self.horse_gameObject:GetComponent("Animator").cullingMode = UnityEngine.AnimatorCullingMode.AlwaysAnimate
self.horse_transform.localScale = Vector3.one
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.Model or self.model_type == UIModelCommon.ModelType.BackModel then
self.horse_transform:SetParent(self.parent.transform)
else
self.horse_transform:SetParent(role_con)
end
self.horse_transform.localPosition = Vector3.zero
if self.position then
self.horse_transform.localPosition = Vector3(self.position.x, self.position.y,self.position.z)
else
self.horse_transform.localPosition = Vector3.zero
end
if self.scale then
self.horse_transform.localScale = Vector3(self.scale*50,self.scale*50,self.scale*50)
else
self.horse_transform.localScale = Vector3.one
end
if self.transform then
local bone = FindBone(self.horse_transform, AttachNode.Ride)
if bone == nil then
return
end
self.transform:SetParent(bone)
self.transform.localPosition = Vector3.zero
self.transform.localScale = Vector3.one
self.transform.localRotation = Quaternion.Euler(Vector3.zero)
end
local rotate_type = type(self.rotate)
if rotate_type == "number" then
self.horse_transform:Rotate(Vector3(0, 270 + (self.rotate), 0))
elseif rotate_type == "table" then
self.horse_transform:Rotate(self.rotate)
else
self.horse_transform:Rotate(Vector3(0, self.rotate, 0))
end
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
--部件特效,参数为部件类型与id
if self.type ~= SceneBaseType.Baby_Include_Horse then
self:CreateEffect(SceneBaseType.Horse, self.free_param, self.horse_gameObject)
self:SetParticleDepth(self.horse_gameObject)
end
local horse_animator = self.horse_gameObject:GetComponent("Animator")
self.horse_animator = horse_animator
if self.horse_action_name then
self.horse_animator:CrossFade(self.horse_action_name, 0, 0, 0)
end
--有坐骑的,加载完坐骑,才执行回调
if self.lCallBack then self.lCallBack(self) end
end
LuaResManager:getInstance():loadPrefab(self,horse_abName,horse_resName, loadHorseCallback)
end
if self.model_data.attach_game_root then
AttachGameRoot(self.role.transform)
end
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
if self.type == SceneBaseType.Include_Horse or
self.type == SceneBaseType.Baby_Include_Horse then
self.role.transform.localPosition = Vector3.zero
else
self.role.transform.localPosition = self.position or Vector3(0,75,-300)
end
elseif self.model_type == UIModelCommon.ModelType.Model then
if self.type == SceneBaseType.Include_Horse or
self.type == SceneBaseType.Baby_Include_Horse then
self.role.transform.localPosition = Vector3.zero
else
if self.position then
self.role.transform.localPosition = self.position
else
self.role.transform.localPosition = Vector3.zero
end
end
else
if self.type == SceneBaseType.Include_Horse or
self.type == SceneBaseType.Baby_Include_Horse then
self.role.transform.localPosition = Vector3.zero
else
if self.position and not self.show_shadow then
self.role.transform.localPosition = self.position + self:GetRolePositionOffset()
else
if self.show_shadow then
self.role.transform.localPosition = Vector3(0, 119, 0) + self:GetRolePositionOffset()
else
self.role.transform.localPosition = Vector3.zero + self:GetRolePositionOffset()
end
end
end
end
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
-- if self.type == SceneBaseType.Equip or self.type == SceneBaseType.FWing or self.type == SceneBaseType.MainRole then
local shinned_meshRender_com_list = self.role:GetComponentsInChildren(typeof(UnityEngine.SkinnedMeshRenderer),true)
if shinned_meshRender_com_list.Length > 0 then
for i=1,shinned_meshRender_com_list.Length do
shinned_meshRender_com_list[i-1].sortingOrder = self:GetCurrLayerDepth(self.layer_name)
-- shinned_meshRender_com_list[i-1].sortingOrder = self:GetCurrLayerDepth(self.layer_name)+1
end
end
-- end
end
-- 保存一次默认坐标
self.default_position = self.default_position or self.role.transform.localPosition
if self.scale then
if self.type == SceneBaseType.Include_Horse or
self.type == SceneBaseType.Baby_Include_Horse then
--如果是坐骑模式,这里不要重新设置角色的scale,否则会导致大人开小车或小人开大车的情况
else
self.role.transform.localScale = Vector3(self.scale,self.scale,self.scale)
end
else
self.role.transform.localScale = Vector3(100,100,100)
end
if self.type == SceneBaseType.Include_Horse or
self.type == SceneBaseType.Baby_Include_Horse then
--如果是坐骑模式,也没必要再设置rotate了
else
local rotate_type = type(self.rotate)
if rotate_type == "number" then
local rotate_x = 0
if self.model_type == UIModelCommon.ModelType.Model and self.rotate == 0 then
rotate_x = 10
end
self.role.transform:Rotate(Vector3(rotate_x, 180 + (self.rotate), 0))
self.rotate = self.rotate or self.rotate
elseif rotate_type == "table" then
self.role.transform:Rotate(self.rotate)
self.rotate = self.rotate.y or self.rotate.y
else
self.role.transform:Rotate(Vector3(0, 180, 0))
self.rotate = self.rotate or 0
end
end
--主体模型特效,参数为主体的类型与id
self:CreateEffect(self.type, self.clothe_res_id, nil, nil, self.effect_obj_type)
local real_model = self.role.gameObject.transform:Find(resName)
if real_model then
self:CheckShadow(real_model, resName)
end
local action_delta = model_data.action_delta
local action_name_list = model_data.action_name_list
if not IsTableEmpty(action_name_list) then
local action_name = action_delta and action_name_list[1] or table.remove(action_name_list, 1)
if action_name then
local animator = self.role:GetComponent("Animator")
if IsNull(animator) then
return
end
--用来判断是否是骑着马的
if self.type == SceneBaseType.Include_Horse then
local ride_action_cfg = Config.otherFightInfo.on_horse_action[self.free_param] or Config.otherFightInfo.on_horse_action[0]
self.horse_action_name = action_name
if self.horse_animator then
self.horse_animator:CrossFade(action_name, 0, 0, 0)
end
if action_name == "idle" or action_name == "casual" or action_name == "hited" or action_name == "show" then
if ride_action_cfg then
self.curr_body_action_name = ride_action_cfg.idle_action
else
self.curr_body_action_name = "ride"
end
elseif action_name == "run" or action_name == "fly" then
if ride_action_cfg then
self.curr_body_action_name = ride_action_cfg.run_action
else
self.curr_body_action_name = "riderun"
end
end
elseif self.type == SceneBaseType.Baby_Include_Horse then -- 宝宝坐骑
local ride_action_cfg = Config.otherFightInfo.on_baby_horse_action[self.free_param] or Config.otherFightInfo.on_baby_horse_action[0]
self.horse_action_name = action_name
if self.horse_animator then
self.horse_animator:CrossFade(action_name, 0, 0, 0)
end
if action_name == "idle" or action_name == "casual" or action_name == "hited" or action_name == "show" then
if ride_action_cfg then
self.curr_body_action_name = ride_action_cfg.idle_action
else
self.curr_body_action_name = "ride"
end
elseif action_name == "run" or action_name == "fly" then
if ride_action_cfg then
self.curr_body_action_name = ride_action_cfg.run_action
else
self.curr_body_action_name = "ride"
end
end
else
self.curr_body_action_name = action_name
end
--动作音效
if self.role_action_sound then
lua_soundM:PlayEffect(self, self.role_action_sound, false, LuaSoundManager.SOUND_TYPE.ROLE, 1)
end
--动作
animator:CrossFade(self.curr_body_action_name,0, 0.0 )
--动作特效
self:CreateEffect(self.type, self.clothe_res_id, self.role, self.curr_body_action_name)
if not IsTableEmpty(action_name_list) then
self.delay_play_action_timer_list = self.delay_play_action_timer_list or {}
if action_delta then
self:DelayPlayNextActionLoop(animator, action_name_list, action_delta)
else
self:DelayPlayNextAction(animator, action_name_list, model_data.delay_action_delta)
end
end
end
else
end
if self.weapon_res_id and self.weapon_res_id ~= 0 then
self:CreateWeapon(self.type, self.weapon_res_id, self.career, self.weapon_clothe_id)
self:CreateClothTexture(self.fashion_model_id, self.texture_id)
end
if self.pearl_vo then
self:CreatePearls(self.pearl_vo)
end
if self.wing_id then
self:CreateWing(SceneBaseType.FWing, self.wing_id)
end
if self.image_id then
self:CreateLivenessImage(self.type,self.image_id)
end
if self.head_wear_id then
self:CreateHeadWear(self.type, self.head_wear_id, self.head_clothe_id)
end
if self.hat_wear_id then
self:CreateHatWear(self.hat_wear_id)
end
if self.footmark_id then
self:CreateFootmark(self.footmark_id)
end
--针对怪物跟伙伴的贴图设置材质图片
if self.texture_id and (self.type == SceneBaseType.Partner or self.type == SceneBaseType.Monster or self.type == SceneBaseType.Npc or SceneBaseType.Horse) then
self:CreateClothTexture(self.clothe_res_id, self.texture_id)
end
if self.light_id and self.light_id > 0 then
--挂人物身上的幻光在这里加
self:CreateLightEffect(self.light_id)
end
if self.warSoul_effect_res and self.warSoul_effect_res ~= nil then
self:CreateWarSoulEffect(self.warSoul_effect_res,self.warSoul_effect_pos,self.warSoul_effect_scale)
end
--宝具
if self.talisman_id and self.talisman_id ~= 0 then
self:CreateTalisman(self.talisman_id)
end
self:SetCameraArgs()
-- if self.use_bloom then
-- self:CreateRoleBloomEffect(self.camera, self.bloom_camera)
-- end
--如果不是坐骑模式,才加载完人物模型返回加载回调
if self.type ~= SceneBaseType.Include_Horse or
self.type == SceneBaseType.Baby_Include_Horse then
if self.lCallBack then self.lCallBack(self) end
end
-- 发行需求 设置绿幕模式
self:UpdateModelGreenScreen()
--灯光参数
if self.use_light_data then
self:ApplyLightData()
end
-- 圣物光环特效
if self.psionic_effect then
local show_type = (self.model_type == UIModelCommon.ModelType.BackModel) and "UIBackRole" or "UI"
local function load_callback( ... )
if self.psionic_effect_id then
self.particle_mgr:SetEffectScale(self.psionic_effect_id, PsionicConst.EffectSize[self.psionic_effect])
self.particle_mgr:SetEffectOrder(self.psionic_effect_id, self:GetCurrLayerDepth(self.layer_name))
end
end
self.psionic_effect_id = self.particle_mgr:AddTargetEffect(self.psionic_effect, self.role, true, nil, nil, 7,nil,nil,1,nil,show_type,load_callback)
self.particle_list[self.psionic_effect_id] = self.psionic_effect_id
end
--宠物宝石光环特效
if self.type == SceneBaseType.Pokemon and self.pokemon_diamond_effect then
local show_type = (self.model_type == UIModelCommon.ModelType.BackModel) and "UIBackRole" or "UI"
self.pokemon_diamond_effect_id = self.particle_mgr:AddTargetEffect(self.pokemon_diamond_effect, self.role, true, nil, nil, 7,nil,nil,1,nil,show_type)
self.particle_list[self.pokemon_diamond_effect_id] = self.pokemon_diamond_effect_id
end
if self.show_baby_attack_effect then
local play_effect_func = function ( )
local show_type = (self.model_type == UIModelCommon.ModelType.BackModel) and "UIBackRole" or "UI"
local temp_cfg = ChildConst.SKILL_EFFECT_SHOW_CFG[self.show_baby_attack_effect] or {}
-- local scale = temp_cfg.scale or 0.5
self.show_baby_attack_effect_id = self.particle_mgr:AddTargetEffect(self.show_baby_attack_effect, self.role, false, nil, dir, 7,nil,nil,1,nil, show_type)
if temp_cfg.scale then
-- print('Msh:UIModelCommon.lua[1543] temp_cfg.scale', temp_cfg.scale)
self.particle_mgr:SetEffectScale(self.show_baby_attack_effect_id, temp_cfg.scale)
end
self.particle_list[self.show_baby_attack_effect_id] = self.show_baby_attack_effect_id
end
setTimeout(play_effect_func, 0.4)
end
--ai娘全套装备模型展示
if self.type == SceneBaseType.Pet and self.show_jarvis_all_figure_data then
self:CreateJarvisAll()
end
--技能特效
if self.need_play_skill_effect then
self:PlaySkillEffect(self.role, self.skill_id)
end
end
if self.type == SceneBaseType.FWeapon then
--创建左右手武器,单独显示用,不走上面的逻辑
local career = self.career or RoleManager.Instance.mainRoleInfo.career
local weapon_res_id = GameResPath:GetFWeaponResName( career,self.fashion_model_id or self.clothe_res_id )
local abName,weapon_attach_list,weapon_res_list = GameResPath.GetWeaponRes(SceneBaseType.FWeapon,weapon_res_id,career)
local function localWeaponCallback( objs, is_gameObject )
if self.weapon_container then
for k,v in pairs(self.weapon_container) do
destroy(v.go)
end
end
self:CreateWeaponOnly(objs, is_gameObject, weapon_attach_list)
-- 发行需求 设置绿幕模式
self:UpdateModelGreenScreen()
end
LuaResManager:getInstance():loadPrefabs(self,abName,weapon_res_list, localWeaponCallback)
else
LuaResManager:getInstance():loadPrefab(self,anName,resName, loadRoleCallback)
end
end
function UIModelCommon:SetCameraArgs(use_default)
end
---------排行榜ai娘总榜把ai娘的磁炮星翼幻甲等全套装备一起展示出来-------------------------->>>>>>>
function UIModelCommon:CreateJarvisAll( )
self:CreateJarvisGun()--磁炮
self:CreateJarvisCloud()--星翼
self:CreateJarvisArmour()--幻甲
end
function UIModelCommon:CreateJarvisGun( )
if not self.show_jarvis_all_figure_data.f_gun_figure_id then return end
local abName, resName = GameResPath.GetModelClotheRes(SceneBaseType.FGun, self.show_jarvis_all_figure_data.f_gun_figure_id)
local function localGunCallback(objs, is_gameObject)
if self._use_delete_method then
return
end
if not objs or not objs[0] then
logWarn("cannot find wing res = "..self.show_jarvis_all_figure_data.f_gun_figure_id)
return
end
local go = is_gameObject and objs[0] or newObject(objs[0])
go:SetActive(true)
local bone = FindBone(self.role.transform, AttachNode.Root)
if bone == nil then
return
end
go.transform:SetParent(bone)
go.transform.localPosition = Vector3.zero
go.transform.localRotation = Quaternion.identity
go.transform.localScale = Vector3.one
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
local animator = go:GetComponent("Animator")
if not IsNull(animator) then
animator.cullingMode = UnityEngine.AnimatorCullingMode.AlwaysAnimate
animator:CrossFade( "idle",0, 0.0 )
end
--部件特效,参数为部件类型与id
self:CreateEffect(SceneBaseType.FGun, self.show_jarvis_all_figure_data.f_gun_figure_id, go)
end
if self.role.transform and abName and resName then
LuaResManager:getInstance():loadPrefab(self,abName,resName, localGunCallback)
end
end
function UIModelCommon:CreateJarvisCloud( )
if not self.show_jarvis_all_figure_data.f_cloud_figure_id then return end
local abName, resName = GameResPath.GetModelClotheRes(SceneBaseType.FCloud, self.show_jarvis_all_figure_data.f_cloud_figure_id)
local function localWingCallback(objs, is_gameObject)
if self._use_delete_method then
return
end
if not objs or not objs[0] then
logWarn("cannot find wing res = "..self.show_jarvis_all_figure_data.f_cloud_figure_id)
return
end
local go = is_gameObject and objs[0] or newObject(objs[0])
go:SetActive(true)
local bone = FindBone(self.role.transform, AttachNode.Wing)
if bone == nil then
return
end
go.transform:SetParent(bone)
go.transform.localPosition = Vector3.zero
go.transform.localRotation = Quaternion.identity
go.transform.localScale = Vector3.one
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
local animator = go:GetComponent("Animator")
if not IsNull(animator) then
animator.cullingMode = UnityEngine.AnimatorCullingMode.AlwaysAnimate
animator:CrossFade( "idle",0, 0.0 )
end
--部件特效,参数为部件类型与id
self:CreateEffect(SceneBaseType.FCloud, self.show_jarvis_all_figure_data.f_cloud_figure_id, go)
end
if self.role.transform and abName and resName then
LuaResManager:getInstance():loadPrefab(self,abName,resName, localWingCallback)
end
end
function UIModelCommon:CreateJarvisArmour( )
if not self.show_jarvis_all_figure_data.f_armour_figure_id then return end
local abName, resName = GameResPath.GetModelClotheRes(SceneBaseType.FArmour, self.show_jarvis_all_figure_data.f_armour_figure_id)
local function localWingCallback(objs, is_gameObject)
if self._use_delete_method then
return
end
if not objs or not objs[0] then
logWarn("cannot find wing res = "..self.show_jarvis_all_figure_data.f_armour_figure_id)
return
end
local go = is_gameObject and objs[0] or newObject(objs[0])
go:SetActive(true)
local bone = FindBone(self.role.transform, AttachNode.Root)
if bone == nil then
return
end
go.transform:SetParent(bone)
go.transform.localPosition = Vector3.zero
go.transform.localRotation = Quaternion.identity
go.transform.localScale = Vector3.one
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
local animator = go:GetComponent("Animator")
if not IsNull(animator) then
animator.cullingMode = UnityEngine.AnimatorCullingMode.AlwaysAnimate
animator:CrossFade( "idle",0, 0.0 )
end
--部件特效,参数为部件类型与id
self:CreateEffect(SceneBaseType.FArmour, self.show_jarvis_all_figure_data.f_armour_figure_id, go)
end
if self.role.transform and abName and resName then
LuaResManager:getInstance():loadPrefab(self,abName,resName, localWingCallback)
end
end
---------排行榜ai娘总榜把ai娘的磁炮星翼幻甲等全套装备一起展示出来--------------------------<<<<<<<<<<<<
function UIModelCommon:CreatePearls( vo )
if IsTableEmpty(vo) then
return
end
if self.transform and self.role.transform then
local info = vo
self.pearl_list = self.pearl_list or {}
self.pearl_parent = self.pearl_parent or {}
local ellipse_config = Config.otherFightInfo.PearlEllipse
local around_ellipse_config = Config.otherFightInfo.PearlUIEllipse
for i=1, #info do
if info[i] and info[i].type_id ~= 0 or info[i].skin_model_id then
local temp_pearl = self.pearl_list[i]
if not temp_pearl then
temp_pearl = GalaxyPearl.New(self.role.transform,ellipse_config,around_ellipse_config)
temp_pearl:SetStartPostion(1/#info * i)
self.pearl_list[i] = temp_pearl
end
temp_pearl:LoadPearlVo(self, false, info[i], false, info[i].skin_model_id, true)
end
end
end
end
--在人物旁边展示宝具
function UIModelCommon:CreateTalisman(talisman_id)
_type = SceneBaseType.FPearl
local abName, resName = GameResPath.GetModelClotheRes(_type, talisman_id)
local function localTalismanCallback(objs, is_gameObject)
if self._use_delete_method then
return
end
if not objs or not objs[0] then
logWarn("cannot find talisman res = "..self.talisman_id)
return
end
local go = is_gameObject and objs[0] or newObject(objs[0])
go:SetActive(true)
-- local bone = FindBone(self.role.transform, AttachNode.Wing)
-- if bone == nil then
-- return
-- end
go.transform:SetParent(self.role.transform)
go.transform.localPosition = Vector3(-0.8,0.6,-0.8)
go.transform.localRotation = Quaternion.identity
go.transform.localScale = Vector3.one
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(self.parent.transform)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(self.parent.transform)
end
local animator = go:GetComponent("Animator")
if not IsNull(animator) then
animator.cullingMode = UnityEngine.AnimatorCullingMode.AlwaysAnimate
animator:CrossFade( "idle",0, 0.0 )
end
--部件特效,参数为部件类型与id
self:CreateEffect(SceneBaseType.FPearl, self.talisman_id, go)
end
if self.role.transform and abName and resName then
LuaResManager:getInstance():loadPrefab(self,abName,resName, localTalismanCallback)
end
end
--创建左右手武器,单独显示用
function UIModelCommon:CreateWeaponOnly(objs,is_gameObject,weapon_attach_list)
if self._use_delete_method then return end
self.weapon_hand_list = self.weapon_hand_list or {}
self.weapon_container = {}
-------------------------
self:RemoveAllParticle()
if self.role then
destroy(self.role)
end
-------------------------
for i,v in ipairs(weapon_attach_list) do
if self.weapon_hand_list[i] then
destroy(self.weapon_hand_list[i])
end
if objs and objs[i - 1] then
self.weapon_hand_list[i] = is_gameObject and objs[i] or newObject(objs[i - 1])
self.weapon_container[i] = {go = self.weapon_hand_list[i]}
local animator = self.weapon_hand_list[i]:GetComponent("Animator")
if not IsNull(animator) then
local custom_speed = Config.ConfigModelSpeed.ModelActionSpeed[tonumber(self.clothe_res_id)]
if custom_speed then
if animator then
animator.speed = custom_speed
end
end
animator.cullingMode = UnityEngine.AnimatorCullingMode.AlwaysAnimate
end
local paredt_node = false
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.Model or self.model_type == UIModelCommon.ModelType.BackModel then
paredt_node = self.parent.transform
else
paredt_node = self.role_con
end
self.weapon_hand_list[i].transform:SetParent(paredt_node)
-------------------------
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self:SetUIbackRoleLayer(paredt_node)
elseif self.model_type == UIModelCommon.ModelType.Model then
self:SetUILayer(paredt_node)
end
--角度,要反向
self.weapon_hand_list[i].transform.localRotation = Quaternion.Euler(Vector3(0,180,0))
--缩放
if self.scale then
self.weapon_hand_list[i].transform.localScale = Vector3(self.scale,self.scale,self.scale)
else
self.weapon_hand_list[i].transform.localScale = Vector3(100,100,100)
end
--坐标
if ClientConfig.is_use_model_render or self.model_type == UIModelCommon.ModelType.BackModel then
self.weapon_hand_list[i].transform.localPosition = self.position or Vector3(0,75,-300)
elseif self.model_type == UIModelCommon.ModelType.Model then
if self.position then
self.weapon_hand_list[i].transform.localPosition = self.position
else
self.weapon_hand_list[i].transform.localPosition = Vector3.zero
end
else
if self.position and not self.show_shadow then
self.weapon_hand_list[i].transform.localPosition = self.position + self:GetRolePositionOffset()
else
if self.show_shadow then
self.weapon_hand_list[i].transform.localPosition = Vector3(0, 119, 0) + self:GetRolePositionOffset()
else
self.weapon_hand_list[i].transform.localPosition = Vector3.zero + self:GetRolePositionOffset()
end
end
end
local action_delta = self.action_delta
local action_name_list = self.action_name_list
local animator = self.weapon_hand_list[i]:GetComponent("Animator")
if IsNull(animator) then
return
end
animator:CrossFade("show3",0, 0.0 )
--动作特效
if not IsTableEmpty(action_name_list) then
if action_delta then
self:DelayPlayNextActionLoop(animator, action_name_list, action_delta)
else
self:DelayPlayNextAction(animator, action_name_list)
end
end
end
end
self:CreateEffect(self.type, self.clothe_res_id, self.role)
end
-- 发行需求:切换绿幕
function UIModelCommon:UpdateModelGreenScreen( )
-- 获取模型节点根节点
if self.model_data and self.model_data.use_green_screen then
-- camera_type:1 主摄像机 2 UI摄像机 3 UIModel摄像机
CheatModel:getInstance():SetupGreenScreenEffect(true, self, self.model_data.green_screen_camera_type)
end
end
--灯光参数
function UIModelCommon:ApplyLightData( )
self:ApplyCameraLightData()
local cfg = Config.lightsData
local temp_vet4 = Vector4(0,0,0,0)
for k,v in pairs(cfg) do
temp_vet4.x = v[1]
temp_vet4.y = v[2]
temp_vet4.z = v[3]
temp_vet4.w = v[4]
Shader.SetGlobalVector(k, temp_vet4)
end
end
function UIModelCommon:ApplyCameraLightData( )
local light_camera = MainCamera.Instance.camera_gameObject
if not IsNull(light_camera) then
local dir = -light_camera.transform.forward;
dir:Normalize()
Shader.SetGlobalVector("_GlobalLightDir", Vector4(dir.x, dir.y, dir.z, 1))
end
end
function UIModelCommon:SetAnimatorSpeed(speed)
if self.role then
local animator = self.role:GetComponent("Animator")
if animator then
animator.speed = speed
end
end
end