161 lines
5.0 KiB
Lua
161 lines
5.0 KiB
Lua
------------------------------------------------
|
|
--作者: gzg
|
|
--日期: 2021-03-08
|
|
--文件: FGameObjectSoulEquip.lua
|
|
--模块: FGameObjectSoulEquip
|
|
--描述: 魂甲模型
|
|
--注意: 在类中的定义字段,不能赋值为nil,需要赋值为一个值.
|
|
------------------------------------------------
|
|
--引用
|
|
local LuaFGameObjectAnim = CS.Thousandto.Plugins.LuaType.LuaFGameObjectAnim;
|
|
local ShaderManager = CS.Thousandto.Core.Asset.ShaderManager
|
|
local WrapMode = CS.UnityEngine.WrapMode
|
|
local SlotNameDefine = CS.Thousandto.Core.Asset.SlotNameDefine
|
|
|
|
|
|
--在类中的定义字段,不能赋值为nil,需要赋值为一个值.默认可以为0
|
|
local FGameObjectSoulEquip = {
|
|
--CS父类对象
|
|
_SuperObj_ = 0,
|
|
--这里如果定义成员,这里必须
|
|
}
|
|
|
|
--#region --类继承的固定模板
|
|
|
|
--构造函数
|
|
function FGameObjectSoulEquip:New(...)
|
|
local _m = Utils.DeepCopy(self)
|
|
_m._SuperObj_ = LuaFGameObjectAnim.Create(...);
|
|
_m:_InitBindOverride_();
|
|
_m:_InitContent_();
|
|
Utils.BuildInheritRel(_m);
|
|
return _m
|
|
end
|
|
|
|
|
|
--绑定Override的方法
|
|
function FGameObjectSoulEquip:_InitBindOverride_()
|
|
--重载函数的重定义
|
|
self._SuperObj_.OnSwitchShaderDelegate = Utils.Handler(self.OnSwitchShader, self, nil, true);
|
|
self._SuperObj_.OnGetBoneIndexDelegate = Utils.Handler(self.OnGetBoneIndex, self, nil, true);
|
|
self._SuperObj_.OnTranslateAnimNameDelegate = Utils.Handler(self.OnTranslateAnimName, self, nil, true);
|
|
self._SuperObj_.OnCheckAnimEnablePlayDelegate = Utils.Handler(self.OnCheckAnimEnablePlay, self, nil, true);
|
|
self._SuperObj_.OnMountToParentDelegate = Utils.Handler(self.OnMountToParent, self, nil, true);
|
|
self._SuperObj_.OnUnMountFromParentDelegate = Utils.Handler(self.OnUnMountFromParent, self, nil, true);
|
|
self._SuperObj_.OnDestoryAfterDelegate = Utils.Handler(self.OnDestoryAfter, self, nil, true);
|
|
--...
|
|
end
|
|
|
|
--初始化
|
|
function FGameObjectSoulEquip:_InitContent_()
|
|
--todo
|
|
end
|
|
|
|
--卸载
|
|
function FGameObjectSoulEquip:Free()
|
|
LuaFGameObjectAnim.Destroy(self._SuperObj_);
|
|
Utils.Destory(self);
|
|
end
|
|
|
|
function FGameObjectSoulEquip:GetCSObj()
|
|
return self._SuperObj_;
|
|
end
|
|
--#endregion
|
|
|
|
--#region-- Overrider 继承父类函数
|
|
|
|
-- <summary>
|
|
-- C#对象删除
|
|
-- </summary>
|
|
-- <param name="skin">FSkinBase</param>
|
|
-- <param name="part">FSkinPartBase</param>
|
|
function FGameObjectSoulEquip:OnDestoryAfter()
|
|
Utils.Destory(self);
|
|
end
|
|
|
|
--/ <summary>
|
|
--/ 获取骨骼索引
|
|
--/ </summary>
|
|
--/ <param name="modelType">ModelTypeCode</param>
|
|
--/ <param name="modelID">int</param>
|
|
--/ <returns></returns>
|
|
function FGameObjectSoulEquip:OnGetBoneIndex( modelType, modelID)
|
|
|
|
if (modelType == UnityUtils.GetObjct2Int(ModelTypeCode.Mount))then
|
|
return modelID / 100;
|
|
end
|
|
return modelID;
|
|
end
|
|
|
|
|
|
--/ <summary>
|
|
--/ 动作转换
|
|
--/ </summary>
|
|
--/ <param name="animName">string</param>
|
|
--/ <param name="mode">WrapMode</param>
|
|
--/ <returns>string</returns>
|
|
function FGameObjectSoulEquip:OnTranslateAnimName(animName,mode)
|
|
if animName == AnimClipNameDefine.NormalRun
|
|
or animName == AnimClipNameDefine.FastRun
|
|
or animName == AnimClipNameDefine.FightRunFront
|
|
or animName == AnimClipNameDefine.FightRunBack
|
|
or animName == AnimClipNameDefine.FightRunLeft
|
|
or animName == AnimClipNameDefine.FightRunRight
|
|
then
|
|
return AnimClipNameDefine.NormalRun,WrapMode.Loop;
|
|
end
|
|
return AnimClipNameDefine.NormalIdle,WrapMode.Loop;
|
|
end
|
|
|
|
--/ <summary>
|
|
--/ 判断动作是否正在播放
|
|
--/ </summary>
|
|
--/ <param name="animName">string</param>
|
|
--/ <returns>bool</returns>
|
|
function FGameObjectSoulEquip:OnCheckAnimEnablePlay(animName)
|
|
|
|
local _lpi = self.LastPlayInfo;
|
|
if (_lpi ~= nil and _lpi.WrapMode == WrapMode.Loop)then
|
|
|
|
return _lpi.Name ~= animName;
|
|
end
|
|
return true;
|
|
end
|
|
|
|
--/ <summary>
|
|
--/ 挂在到父类
|
|
--/ </summary>
|
|
--/ <param name="parent">FGameObject</param>
|
|
--/ <returns>bool</returns>
|
|
function FGameObjectSoulEquip:OnMountToParent(parent)
|
|
|
|
if (parent ~= nil and parent.RealTransform ~= nil and self.RealTransform ~= nil) then
|
|
--首先把对象设置到根目录下
|
|
self:SetParent(parent.RootTransform, false);
|
|
local wing = self.RealTransform;
|
|
if (wing ~= nil) then
|
|
--这里针对翅膀做特殊处理
|
|
local slot_Wing = parent:FindTransform(SlotNameDefine.Wing, true);
|
|
wing.parent = slot_Wing;
|
|
UnityUtils.ResetTransform(wing);
|
|
wing.localPosition = Vector3(0, -0.1, 0);
|
|
self.RealGameObject:SetActive(false);
|
|
self.RealGameObject:SetActive(true);
|
|
|
|
if (parent.LastPlayInfo ~= nil ) then
|
|
parent.LastPlayInfo.WrapMode = WrapMode.Loop;
|
|
self:PlayAnim(parent.LastPlayInfo, false);
|
|
end
|
|
end
|
|
return true;
|
|
end
|
|
return false;
|
|
end
|
|
|
|
function FGameObjectSoulEquip:OnUnMountFromParent(parent)
|
|
self:RealComeBackToRoot();
|
|
return true;
|
|
end
|
|
--#endregion
|
|
|
|
return FGameObjectSoulEquip |