summaryrefslogtreecommitdiff
path: root/ActiveRagdoll/Assets/TABG/Scripts/Data
diff options
context:
space:
mode:
Diffstat (limited to 'ActiveRagdoll/Assets/TABG/Scripts/Data')
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs32
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Data/RigidbodyHolder.cs27
-rw-r--r--ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs7
3 files changed, 59 insertions, 7 deletions
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs
index 7a1a9f7..b581821 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/AnimationHandler.cs
@@ -15,7 +15,6 @@ namespace Rigging.Data
public string theString;
}
-
public class AnimationHandler : RiggingDataBase
{
/*
@@ -32,6 +31,37 @@ namespace Rigging.Data
{
animationState = newState;
}
+ }
+
+ [Serializable]
+ public class AnimationParam<T>
+ {
+ private Player player;
+
+ [SerializeField]
+ public T[] values;
+
+ public AnimationParam()
+ {
+ }
+
+ public void SetPlayer(Player p)
+ {
+ player = p;
+ }
+
+ public T CurrentValue()
+ {
+ return values[player.status.animation.animationState];
+ }
+
+ public T current
+ {
+ get
+ {
+ return values[player.status.animation.animationState];
+ }
+ }
}
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/RigidbodyHolder.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/RigidbodyHolder.cs
index eefa961..d1f01b1 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Data/RigidbodyHolder.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/RigidbodyHolder.cs
@@ -16,14 +16,35 @@ namespace Rigging.Data
allRigs = rootBone.gameObject.GetComponentsInChildren<Rigidbody>();
}
- private void Update()
+ public Rigidbody[] GetAllRigs()
{
+ return allRigs;
}
- public Rigidbody[] GetAllRigs()
+ public void AddForceToAll(Vector3 force, ForceMode mode)
{
- return allRigs;
+ for(int i = 0; i < allRigs.Length; ++i)
+ {
+ allRigs[i].AddForce(force, mode);
+ }
}
+
+ public void ModifyVelocityForEach(System.Func<Rigidbody, Vector3> modifier)
+ {
+ for (int i = 0; i < allRigs.Length; i++)
+ {
+ allRigs[i].velocity = modifier(allRigs[i]);
+ }
+ }
+
+ public void SetVelocityToAll(Vector3 vel)
+ {
+ for (int i = 0; i < allRigs.Length; i++)
+ {
+ allRigs[i].velocity = vel;
+ }
+ }
+
}
} \ No newline at end of file
diff --git a/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs b/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs
index f35f068..3caa488 100644
--- a/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs
+++ b/ActiveRagdoll/Assets/TABG/Scripts/Data/StepHandler.cs
@@ -11,7 +11,7 @@ namespace Rigging.Data
public float staticCounter;
- public Step steps;
+ public AnimationParam<Step> steps;
public bool isLeft;//左脚还是右脚在前面
@@ -34,6 +34,7 @@ namespace Rigging.Data
animationHandler = player.status.animation;
hip = player.body.hip.transform;
}
+ steps.SetPlayer(player);
}
protected override void OnUpdate()
@@ -46,8 +47,8 @@ namespace Rigging.Data
Switch();
}
}
- else if (counter > steps.minTime
- && (steps.minAngle == 0f || steps.minAngle < Vector3.Angle(leftLeg.forward, rightLeg.forward))
+ else if (counter > steps.current.minTime
+ && (steps.current.minAngle == 0f || steps.current.minAngle < Vector3.Angle(leftLeg.forward, rightLeg.forward))
&& isLeft == hip.InverseTransformPoint(leftLeg.position + leftLeg.forward).z > hip.InverseTransformPoint(rightLeg.position + rightLeg.forward).z)
{
Switch();