diff options
author | chai <chaifix@163.com> | 2021-09-02 09:59:31 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-09-02 09:59:31 +0800 |
commit | 3ad68338dff5229d3fd8ec9f3ee994d7e37fb0ed (patch) | |
tree | b5fbf74148147019f75dd4c078fd76f4804330ec /Assets/Scripts/Unit | |
parent | f7e60ab9a52e557aa2250477d018b2768bccc028 (diff) |
*override rootmotion
Diffstat (limited to 'Assets/Scripts/Unit')
-rw-r--r-- | Assets/Scripts/Unit/AfterImage.meta | 8 | ||||
-rw-r--r-- | Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs | 18 | ||||
-rw-r--r-- | Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs.meta | 11 | ||||
-rw-r--r-- | Assets/Scripts/Unit/AnimationData.cs | 12 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Collider/ColliderAttributes.cs | 58 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitAfterImage.cs | 41 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitAfterImage.cs.meta | 11 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs | 28 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Controller/PCController.cs | 8 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Events/EventMesh_AfterImage.cs | 82 | ||||
-rw-r--r-- | Assets/Scripts/Unit/TimelineEventProxy.cs | 21 |
11 files changed, 266 insertions, 32 deletions
diff --git a/Assets/Scripts/Unit/AfterImage.meta b/Assets/Scripts/Unit/AfterImage.meta new file mode 100644 index 00000000..952c1fde --- /dev/null +++ b/Assets/Scripts/Unit/AfterImage.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9153d0fdbafce2244b1c761816e5f9c0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs b/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs new file mode 100644 index 00000000..0ddc5ef8 --- /dev/null +++ b/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class AfterImageAvatar : MonoBehaviour +{ + #region 序列化内容 + + + + #endregion + + public void Initialized() + { + + } + +} diff --git a/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs.meta b/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs.meta new file mode 100644 index 00000000..85c289bb --- /dev/null +++ b/Assets/Scripts/Unit/AfterImage/AfterImageAvatar.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 89864711140932040a5827c91d9e5adc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/AnimationData.cs b/Assets/Scripts/Unit/AnimationData.cs index 4d229346..4114966c 100644 --- a/Assets/Scripts/Unit/AnimationData.cs +++ b/Assets/Scripts/Unit/AnimationData.cs @@ -76,6 +76,16 @@ public enum EAnimationParameter [Serializable]
public class ParameterDictionary : SerializableDictionary<EAnimationParameter, AnimationParameter> { }
+public class RootMotionOverrideData
+{
+ public class PosData
+ {
+ Vector3 position;
+ float frame;
+ }
+ List<PosData> positions;
+}
+
// 某个动画的数据,包括帧事件、碰撞盒、速度曲线
[CreateAssetMenu(fileName = "Animation Data")]
public class AnimationData : ScriptableObject
@@ -91,6 +101,8 @@ public class AnimationData : ScriptableObject public List<ColliderData> blockBoxes;
public List<ColliderData> defendBoxes;
+ public RootMotionOverrideData overrideRootMotion;
+
// 对应的进度的播放速度,默认是1
[UnityEngine.Serialization.FormerlySerializedAs("curve")]
public AnimationCurve speedCurve;
diff --git a/Assets/Scripts/Unit/Collider/ColliderAttributes.cs b/Assets/Scripts/Unit/Collider/ColliderAttributes.cs index 9b9c142f..47998b3c 100644 --- a/Assets/Scripts/Unit/Collider/ColliderAttributes.cs +++ b/Assets/Scripts/Unit/Collider/ColliderAttributes.cs @@ -36,17 +36,64 @@ public class IfNotAttribute : Attribute } - public class WhenAttribute : Attribute { - public WhenAttribute(string name, float value) + public WhenAttribute(string name, object value) { this.conditionName = name; - this.value = value; + this.value = (int)value; + } + + public WhenAttribute(string name, params object[] values)
+ {
+ this.conditionName = name;
+ this.values = new List<float>();
+ foreach(var v in values)
+ {
+ this.values.Add((float)v);
+ }
+ } + + public bool IsSatisfied(float v)
+ {
+ if (values != null)
+ return values.Contains(v);
+ return value == v;
} public string conditionName; public float value; + public List<float> values; +} + +public class AndWhenAttribute : Attribute +{ + public AndWhenAttribute(string name, object value) + { + this.conditionName = name;
+ this.value = (int)value; + } + + public AndWhenAttribute(string name, params object[] values)
+ {
+ this.conditionName = name;
+ this.values = new List<float>();
+ foreach (var v in values)
+ {
+ this.values.Add((float)v);
+ }
+ } + + public bool IsSatisfied(float v)
+ {
+ if (values != null)
+ return values.Contains(v);
+ return value == v;
+ } + + public string conditionName; + public float value; + public List<float> values; } public class WhenNotAttribute : Attribute @@ -81,3 +128,8 @@ public class FoldoutAttribute : Attribute public string title; public int count; // 下面的元素的个数 } + + +public class HDRAttribute : Attribute
+{
+} diff --git a/Assets/Scripts/Unit/Components/UnitAfterImage.cs b/Assets/Scripts/Unit/Components/UnitAfterImage.cs new file mode 100644 index 00000000..369f63c9 --- /dev/null +++ b/Assets/Scripts/Unit/Components/UnitAfterImage.cs @@ -0,0 +1,41 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class AfterImageSpawner +{ + private float m_CurTime; + + private float m_Duration; + + public void OnUpdate() + { + float dt = Time.deltaTime; + m_CurTime += dt; + + + } + +} + +[DisallowMultipleComponent] +public class UnitAfterImage : UnitComponent +{ + + private List<AfterImageSpawner> m_Spawners; + + public override void OnUpdate() + { + base.OnUpdate(); + + if(m_Spawners != null) + { + for(int i = 0; i < m_Spawners.Count; ++i) + { + m_Spawners[i].OnUpdate(); + } + } + + } + +}
\ No newline at end of file diff --git a/Assets/Scripts/Unit/Components/UnitAfterImage.cs.meta b/Assets/Scripts/Unit/Components/UnitAfterImage.cs.meta new file mode 100644 index 00000000..21cdf37f --- /dev/null +++ b/Assets/Scripts/Unit/Components/UnitAfterImage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 567816c152acc834f9bd41efec9ee51c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs b/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs index 33bd4d4e..dbd4dd49 100644 --- a/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs +++ b/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs @@ -71,6 +71,8 @@ public class PCAnimation : UnitAnimation public bool applyRootMotion { get; set; }// 动态设置root motion public bool applyRootCurve { get; set; } // 程序生成的root motion + public bool updateAnimationAuto { get; private set; } // 自动更新动画 + public override void Initialize() { base.Initialize(); @@ -89,7 +91,9 @@ public class PCAnimation : UnitAnimation } applyRootMotion = true; - } + + updateAnimationAuto = true; + } public override void OnUpdate() { @@ -97,11 +101,8 @@ public class PCAnimation : UnitAnimation UpdateLayer(); UpdateAnimation(); - - if (applyRootMotion) - UpdateRootMotion(); - if (applyRootCurve) - UpdateRootCurve(); + UpdateRootMotion(); + UpdateRootCurve(); } void UpdateLayer() @@ -116,18 +117,25 @@ public class PCAnimation : UnitAnimation void UpdateAnimation() { - m_Animator.speed = 1; - m_Animator.Update(Time.deltaTime); - m_Animator.speed = 0; - } + if(updateAnimationAuto)
+ {
+ m_Animator.speed = 1;
+ m_Animator.Update(Time.deltaTime);
+ m_Animator.speed = 0; + }
+ } void UpdateRootMotion() { + if (!applyRootMotion) + return; m_Owner.unitRootMotion.UpdateRootMotion(); } void UpdateRootCurve() { + if (!applyRootCurve) + return; } public void AnimIdle() diff --git a/Assets/Scripts/Unit/Controller/PCController.cs b/Assets/Scripts/Unit/Controller/PCController.cs index 93228d31..ba12b3f5 100644 --- a/Assets/Scripts/Unit/Controller/PCController.cs +++ b/Assets/Scripts/Unit/Controller/PCController.cs @@ -8,6 +8,8 @@ public class PCController : UnitController {
public static PCController instance;
+ private UnitAfterImage unitAfterImage;
+
public override UnitType type { get { return UnitType.PC; } }
private void Awake()
@@ -24,11 +26,15 @@ public class PCController : UnitController unitAnimation = gameObject.GetOrAddComponent<PCAnimation>();
unitAnimation.Initialize();
- }
+
+ unitAfterImage = gameObject.GetOrAddComponent<UnitAfterImage>();
+ unitAfterImage.Initialize();
+ }
public override void Update()
{
base.Update();
+ unitAfterImage.OnUpdate();
}
public override void OnHit(CollisionInfo info)
diff --git a/Assets/Scripts/Unit/Events/EventMesh_AfterImage.cs b/Assets/Scripts/Unit/Events/EventMesh_AfterImage.cs index ee792ddc..76d5060e 100644 --- a/Assets/Scripts/Unit/Events/EventMesh_AfterImage.cs +++ b/Assets/Scripts/Unit/Events/EventMesh_AfterImage.cs @@ -2,20 +2,78 @@ public class EventMesh_AfterImage : AnimationEventBase
{
- public enum ELife
- {
- FrameBased = 0,
- FixedTime = 1,
- }
+ public enum ESpawnRange // 生成残影的范围
+ {
+ Once = 0, // 只生成一个残影
+ Duration = 1, // 给定一个时间范围内
+ WaitForAfterImageStopEvent = 2, // 等待触发afterImageStopEvent
+ Manual = 3, // 手动停止生成
+ }
+
+ public enum ETimeMode
+ {
+ FrameBased = 0,
+ FixedTime = 1,
+ }
+
+ public enum ESpawnPosition
+ {
+ InitPosition = 0, // 在触发事件的位置生成
+ Follow = 1, // 跟随
+ }
+
+ public enum ESpawnMode
+ {
+ Count = 0, // 生成固定数量个,间隔平均
+ Interval = 1, // 等时间间隔生成
+ Curve = 2, // 曲线
+ }
+
+ public enum EEffect // 效果
+ {
+ Original = 0, // 原样
+ RimLight = 1, // 边缘光
+ FullColor = 2, // 全着色
+ Ink = 3, // 墨水效果
+ Distorsion = 4, // 扭曲
+ Dissolve = 5, // 溶解
+ }
public override TimelineEventProxy.EEventType type { get { return TimelineEventProxy.EEventType.EventMesh_AfterImage; } }
public override string shortName { get { return "A"; } }
- public ELife lifeType;
- [When("lifeType", (int)ELife.FixedTime), Tooltip("持续时间(按时间,scaledTime)")]
- public float durationInFixedTime;
- [When("lifeType", (int)ELife.FrameBased), Tooltip("持续时间(按帧, unscaledTime)")]
- public float durationInFrame;
+ public ETimeMode timeMode;
+
+ [Comment("[ 残影生成 ]", TextAnchor.MiddleCenter)]
+ public ESpawnRange spawnRange;
+
+ [When("spawnRange", ESpawnRange.Duration), AndWhen("timeMode", ETimeMode.FixedTime), Tooltip("整个生成的持续时间(按时间,scaledTime)")]
+ public float durationInFixedTime;
+ [When("spawnRange", ESpawnRange.Duration), AndWhen("timeMode", ETimeMode.FrameBased), Tooltip("整个生成的持续时间(按帧, unscaledTime)")]
+ public float durationInFrame;
+
+ public ESpawnPosition spawnPosition;
+
+ public ESpawnMode spawnMode;
+ [When("spawnMode", ESpawnMode.Count)]
+ public int spawnCount;
+ [When("spawnMode", ESpawnMode.Interval), AndWhen("timeMode", ETimeMode.FixedTime)]
+ public float intervalInFixedTime;
+ [When("spawnMode", ESpawnMode.Interval), AndWhen("timeMode", ETimeMode.FrameBased)]
+ public float intervalInFrame;
+ [When("spawnMode", ESpawnMode.Curve)]
+ public AnimationCurve spawnCurve;
+
+ [Comment("[ 残影效果 ]", TextAnchor.MiddleCenter)]
+ public EEffect effect;
+
+ [When("timeMode", ETimeMode.FixedTime), Tooltip("单个残影持续时间(按时间,scaledTime)")]
+ public float lifetimeInFixedTime;
+ [When("timeMode", ETimeMode.FrameBased), Tooltip("单个残影持续时间(按帧, unscaledTime)")]
+ public float lifetimeInFrame;
+
+ [When("effect", EEffect.RimLight)]
+ [HDR] public Color rimColor;
-}
-
\ No newline at end of file + [HDR] public Color color;
+}
\ No newline at end of file diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs index de067455..4a71400c 100644 --- a/Assets/Scripts/Unit/TimelineEventProxy.cs +++ b/Assets/Scripts/Unit/TimelineEventProxy.cs @@ -54,7 +54,8 @@ public partial class TimelineEventProxy EventCamera_Blur, // 相机模糊 EventCamera_WhiteOut, // 相机白屏 - EventMesh_AfterImage, // 角色残像 + EventMesh_AfterImage, // 角色残像
+ EventMesh_AfterImageStop, // 角色残像停止事件
EventMesh_FadeIn, // 角色透明度 EventMesh_FadeOut, // 角色透明度 EventMesh_Gloss, // 角色泛光 @@ -79,16 +80,16 @@ public partial class TimelineEventProxy private Transform m_Root; - private UnitController m_Owner; + public UnitController owner { get; private set; }
- private UnitAnimation m_UnitAnimation { get { return m_Owner.unitAnimation; } } + private UnitAnimation m_UnitAnimation { get { return owner.unitAnimation; } } private AnimationData m_PrevAnimationData;
public TimelineEventProxy(Transform root, UnitController owner = null) { m_Root = root; - m_Owner = owner; + this.owner = owner; m_PrevAnimationData = null; } @@ -200,7 +201,7 @@ public partial class TimelineEventProxy GameObject obj = GameObject.Instantiate(prefab);
Projectile projectile = obj.GetComponent<Projectile>();
ProjectileInfo info = new ProjectileInfo();
- info.owner = m_Owner;
+ info.owner = owner;
info.position = m_Root.transform.position + e.posOffset;
info.rotation = e.rotation;
info.scale = e.scale;
@@ -219,6 +220,14 @@ public partial class TimelineEventProxy #endif
}
- #endregion + void EventMesh_AfterImage(AnimationEventBase animEvent)
+ {
+ EventMesh_AfterImage afterImage = animEvent as EventMesh_AfterImage;
+ if (afterImage == null)
+ return ;
+
+ }
+
+ #endregion }
\ No newline at end of file |