protected void Start() { if (!dungeon) { dungeon = FindObjectOfType <DungeonManager>(); } shader = gameObject.AddComponent <ShaderManager>(); constants = dungeon.constants; _animator = GetComponent <Animator>(); if (!_animator) { _animator = GetComponentInChildren <Animator>(); } var localScale = transform.localScale; flipScale = Mathf.Abs(localScale.x); hurtbox = new Hitbox(box, localScale); }
public void ToYaml(MaterialAnim materialAnim, FMAA.AnimationType animType) { MaterialAnimConfigs = new List <MatAnimConfig>(); Name = materialAnim.Name; Path = materialAnim.Path; FrameCount = materialAnim.FrameCount; Loop = materialAnim.Loop; foreach (var mat in materialAnim.MaterialAnimDataList) { MatAnimConfig matConfig = new MatAnimConfig(); matConfig.Name = mat.Name; MaterialAnimConfigs.Add(matConfig); foreach (var paramInfo in mat.ParamAnimInfos) { ParamInfo paramCfg = new ParamInfo(); paramCfg.Name = paramInfo.Name; paramCfg.IsConstant = paramInfo.ConstantCount != 0; matConfig.ParamInfos.Add(paramCfg); if (paramInfo.ConstantCount != 0) { paramCfg.Constants = new List <ConstantConfig>(); for (int i = 0; i < paramInfo.ConstantCount; i++) { AnimConstant constant = mat.Constants[paramInfo.BeginConstant + i]; ConstantConfig ConstantValue = new ConstantConfig(); ConstantValue.Offset = ConvertParamOffset(constant.AnimDataOffset, animType); ConstantValue.Value = constant.Value; paramCfg.Constants.Add(ConstantValue); } } if (paramInfo.BeginCurve != ushort.MaxValue) { paramCfg.CurveData = new List <CurveConfig>(); for (int i = 0; i < paramInfo.IntCurveCount + paramInfo.FloatCurveCount; i++) { var curve = mat.Curves[(int)paramInfo.BeginCurve + i]; var CurveCfg = new CurveConfig(); CurveCfg.Offset = ConvertParamOffset(curve.AnimDataOffset, animType); if (curve.Scale == 0) { curve.Scale = 1; } for (int f = 0; f < curve.Frames.Length; f++) { int frame = (int)curve.Frames[f]; float Value = curve.Offset + curve.Keys[f, 0] * curve.Scale; CurveCfg.KeyFrames.Add(frame, Value); } paramCfg.CurveData.Add(CurveCfg); } } } foreach (var patternInfo in mat.TexturePatternAnimInfos) { PatternInfo infoCfg = new PatternInfo(); infoCfg.Name = patternInfo.Name; infoCfg.IsConstant = patternInfo.BeginConstant != ushort.MaxValue; matConfig.TexturePatternInfos.Add(infoCfg); if (infoCfg.IsConstant) { infoCfg.ConstantValue = new ConstantTPConfig(); int Index = (int)mat.Constants[(int)patternInfo.BeginConstant].Value; infoCfg.ConstantValue.Texture = materialAnim.TextureNames[Index]; } if (patternInfo.CurveIndex != ushort.MaxValue) { var curve = mat.Curves[(int)patternInfo.CurveIndex]; infoCfg.CurveData = new CurveTPConfig(); if (curve.Scale == 0) { curve.Scale = 1; } for (int f = 0; f < curve.Frames.Length; f++) { int frame = (int)curve.Frames[f]; int Value = (int)curve.Offset + (int)curve.Keys[f, 0] * (int)curve.Scale; infoCfg.CurveData.KeyFrames.Add(frame, materialAnim.TextureNames[Value]); } } } } }