71 lines
2.8 KiB
C#
71 lines
2.8 KiB
C#
using Games.LogicObj;
|
||
using GCGame.Table;
|
||
using Module.Log;
|
||
using UnityEngine;
|
||
|
||
public abstract class Impact_ChangeModelMaterialBase : ImpactEffectBase
|
||
{
|
||
private ChangeMatPro _materialPropertyMod;
|
||
|
||
public int Token { get; private set; }
|
||
|
||
public override void StartEffect()
|
||
{
|
||
base.StartEffect();
|
||
if (objCharacter != null && Data != null)
|
||
{
|
||
if (bodyPart >= 0 && bodyPart < 4)
|
||
{
|
||
var paramid = Data.GetParamValuebyIndex(bodyPart);
|
||
var effectparam = TableManager.GetEffectParamByID(paramid, 0);
|
||
if (effectparam != null)
|
||
{
|
||
var matPath = effectparam.GetParamValuebyIndex(0); //材质路径
|
||
// 注:现在会锁定使用主贴图属性和法线贴图属性
|
||
//var mainTexName = effectparam.GetParamValuebyIndex(1); //材质主贴图属性名称
|
||
//var proNumStr = effectparam.GetParamValuebyIndex(3); //需要设置初始属性值得属性个数
|
||
var proInfoIdStr = effectparam.GetParamValuebyIndex(1); //材质的相关效果效果信息表现对应的ID (也是EffectParam表中的ID)
|
||
int proInfoId;
|
||
if (!int.TryParse(proInfoIdStr, out proInfoId))
|
||
{
|
||
proInfoId = -1;
|
||
LogModule.ErrorLog(string.Format("无法转化特效id={0}中的材质属性变化id为整数!", Data.EffectID));
|
||
}
|
||
|
||
var modelPart = BodyToModelPart(bodyPart);
|
||
// 建立ChangeMatPro
|
||
if (proInfoId > -1)
|
||
{
|
||
var modParam = TableManager.GetEffectParamByID(proInfoId, 0);
|
||
if (modParam != null && _materialPropertyMod == null)
|
||
{
|
||
_materialPropertyMod = new ChangeMatPro(objCharacter, modelPart, modParam);
|
||
_materialPropertyMod.Start(modParam, Data.Duration);
|
||
}
|
||
}
|
||
Token = AddMod(matPath, modelPart);
|
||
}
|
||
}
|
||
else
|
||
LogModule.ErrorLog(string.Format("配置表中id={0}的特效bodyPart={1}属性超过范围!", Data.EffectID, bodyPart));
|
||
}
|
||
}
|
||
|
||
public override void StopEffect()
|
||
{
|
||
base.StopEffect();
|
||
if (Token >= 0)
|
||
RemoveMod(Token, BodyToModelPart(bodyPart));
|
||
if (_materialPropertyMod != null)
|
||
_materialPropertyMod.StopEffect();
|
||
}
|
||
|
||
protected override void UpdateInherited()
|
||
{
|
||
if (_materialPropertyMod != null)
|
||
_materialPropertyMod.OnUpdate();
|
||
}
|
||
|
||
protected abstract int AddMod(string assetName, int modelPart);
|
||
protected abstract void RemoveMod(int token, int modelPart);
|
||
} |