summaryrefslogtreecommitdiff
path: root/Assets/Scripts
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts')
-rw-r--r--Assets/Scripts/Test 1/TestErika.cs12
-rw-r--r--Assets/Scripts/Unit/AnimationData.cs5
-rw-r--r--Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs31
-rw-r--r--Assets/Scripts/Unit/Components/UnitState/PCState.cs12
-rw-r--r--Assets/Scripts/Unit/Events/EventEffect.cs2
-rw-r--r--Assets/Scripts/Unit/UnitRootMotion.cs3
6 files changed, 47 insertions, 18 deletions
diff --git a/Assets/Scripts/Test 1/TestErika.cs b/Assets/Scripts/Test 1/TestErika.cs
index 967c3bdb..cb40b103 100644
--- a/Assets/Scripts/Test 1/TestErika.cs
+++ b/Assets/Scripts/Test 1/TestErika.cs
@@ -52,9 +52,15 @@ public class TestErika : MonoBehaviour
RootMotionProxy rootMotionProxy = erika.unit.GetOrAddComponent<RootMotionProxy>();
Animator animator = erika.unit.GetComponent<Animator>();
- AnimatorOverrideController animCtr = new AnimatorOverrideController(erika.animController);
- animCtr.name = erika.unitPrefab.name + " Override Controller";
- animator.runtimeAnimatorController = animCtr;
+ //AnimatorOverrideController animCtr = new AnimatorOverrideController(erika.animController);
+ //animCtr.name = erika.unitPrefab.name + " Override Controller";
+ //foreach(var anim in erika.actionData.actions)
+ //{
+ // animCtr[anim.Key] = anim.Value;
+ //}
+ animator.runtimeAnimatorController = erika.animController;
+
+ Debug.Assert(animator.runtimeAnimatorController is AnimatorOverrideController);
unitCtr.pcState.ChangeState(PCState.EUnitState.Idle, new PCState.IdleParam(), true);
}
diff --git a/Assets/Scripts/Unit/AnimationData.cs b/Assets/Scripts/Unit/AnimationData.cs
index 2250da76..84b75f47 100644
--- a/Assets/Scripts/Unit/AnimationData.cs
+++ b/Assets/Scripts/Unit/AnimationData.cs
@@ -79,6 +79,7 @@ public class ParameterDictionary : SerializableDictionary<EAnimationParameter, A
public enum EAnimationProperty
{
ComboTimeOffset = 1,
+ IgnoreY = 2,
}
[Serializable]
@@ -234,10 +235,10 @@ public class AnimationData : ScriptableObject
return true;
}
- public float GetProperty(EAnimationProperty property)
+ public float GetProperty(EAnimationProperty property, float defaultValue = 0)
{
if (!HasProperty(property))
- return 0;
+ return defaultValue;
return properties[property];
}
diff --git a/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs b/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs
index 243ce162..df074061 100644
--- a/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs
+++ b/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs
@@ -75,6 +75,15 @@ public class PCAnimation : UnitAnimation
public bool updateAnimationAuto { get; private set; } // 自动更新动画
+ private AnimatorOverrideController controller
+ {
+ get
+ {
+ Debug.Assert(owner.unitAnimation.animator.runtimeAnimatorController is AnimatorOverrideController);
+ return owner.unitAnimation.animator.runtimeAnimatorController as AnimatorOverrideController;
+ }
+ }
+
public override void Initialize()
{
base.Initialize();
@@ -139,9 +148,19 @@ public class PCAnimation : UnitAnimation
{
if (!applyRootCurve)
return;
- }
-
- public void AnimIdle()
+ }
+
+ AnimationData GetAnimationDataOfGivenState(string name)
+ {
+ string animName = controller[name].name;
+ string path = owner.folder + "AnimationData/" + animName + ".asset";
+ AnimationData data = ResourceManager.Instance.LoadAsset<AnimationData>(path);
+ return data;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public void AnimIdle()
{
CrossFade(EAnimState.Idle, 0.2f, 0);
}
@@ -164,7 +183,9 @@ public class PCAnimation : UnitAnimation
else if (id == 2) state = EAnimState.AirAttack2;
else if (id == 3) state = EAnimState.AirAttack3;
- CrossFade(state, 0.05f);
+ AnimationData data = GetAnimationDataOfGivenState(state.ToString());
+ Debug.Assert(data != null);
+ CrossFade(state, 0.02f, data.GetProperty(EAnimationProperty.ComboTimeOffset, defaultValue: 0));
}
public void AnimAttackToAir(float offset)
@@ -221,7 +242,7 @@ public class PCAnimation : UnitAnimation
base.Play(animState.ToString(), layerIndex, normalizedTime);
}
- private void CrossFade(EAnimState animState, float normalizedTransitionDuration, int layerIndex = 0, float normalizedTimeOffset = float.NegativeInfinity, float normalizedTransitionTime = 0.0f)
+ private void CrossFade(EAnimState animState, float normalizedTransitionDuration, float normalizedTimeOffset = float.NegativeInfinity, float normalizedTransitionTime = 0.0f, int layerIndex = 0)
{
base.CrossFade(animState.ToString(), normalizedTransitionDuration, layerIndex, normalizedTimeOffset, normalizedTransitionTime);
}
diff --git a/Assets/Scripts/Unit/Components/UnitState/PCState.cs b/Assets/Scripts/Unit/Components/UnitState/PCState.cs
index c8937895..1d0332cd 100644
--- a/Assets/Scripts/Unit/Components/UnitState/PCState.cs
+++ b/Assets/Scripts/Unit/Components/UnitState/PCState.cs
@@ -298,15 +298,15 @@ public class PCState : UnitState
}
}
- void OnAttackToAirExit()
- {
- }
+ void OnAttackToAirExit(EUnitState next)
+ {
+ }
- #endregion
+ #endregion
- #region AirAttack
+ #region AirAttack
- IEnumerator AirAttack(SkillParam param)
+ IEnumerator AirAttack(SkillParam param)
{
int id = 0;
m_Owner.pcAnimation.AnimAirAttack(id);
diff --git a/Assets/Scripts/Unit/Events/EventEffect.cs b/Assets/Scripts/Unit/Events/EventEffect.cs
index d6a3fa16..9798ed6a 100644
--- a/Assets/Scripts/Unit/Events/EventEffect.cs
+++ b/Assets/Scripts/Unit/Events/EventEffect.cs
@@ -21,5 +21,5 @@ public class EventEffect : AnimationEventBase
public Vector3 rotation;
[Tooltip("Scale")]
- public Vector3 scale;
+ public Vector3 scale = Vector3.one;
}
diff --git a/Assets/Scripts/Unit/UnitRootMotion.cs b/Assets/Scripts/Unit/UnitRootMotion.cs
index caf59d7c..86e44abd 100644
--- a/Assets/Scripts/Unit/UnitRootMotion.cs
+++ b/Assets/Scripts/Unit/UnitRootMotion.cs
@@ -104,7 +104,8 @@ public class UnitRootMotion : UnitComponent
Vector3 dest = m_Owner.unitAnimation.animator.deltaPosition;
dest.z = 0;
var state = m_Owner.unitAnimation.baseLayer.stateInfo;
- if (state.IsTag("IgnoreY"))
+ bool ignoreY = m_Owner.unitAnimation.baseLayer.animationData.GetProperty(EAnimationProperty.IgnoreY, 0) != 0;
+ if (state.IsTag("IgnoreY") || ignoreY)
{
dest.y = 0;
}