Simpler anim logic for off-screen characters (all limbs except refLimb are hidden)

This commit is contained in:
Regalis
2015-09-29 20:06:15 +03:00
parent 45178e745b
commit 655862fc0f
10 changed files with 116 additions and 36 deletions

View File

@@ -4,6 +4,7 @@ using System.Xml.Linq;
using FarseerPhysics;
using FarseerPhysics.Dynamics.Joints;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
namespace Subsurface
{
@@ -48,6 +49,11 @@ namespace Subsurface
public override void UpdateAnim(float deltaTime)
{
if (PlayerInput.KeyHit(Keys.I))
{
SimplePhysicsEnabled = !SimplePhysicsEnabled;
}
if (character.IsDead)
{
UpdateDying(deltaTime);
@@ -68,6 +74,10 @@ namespace Subsurface
stunTimer -= deltaTime;
return;
}
else if (SimplePhysicsEnabled)
{
UpdateSimpleAnim();
}
else
{
if (inWater)
@@ -80,7 +90,6 @@ namespace Subsurface
}
}
if (flip)
{
//targetDir = (movement.X > 0.0f) ? Direction.Right : Direction.Left;
@@ -208,6 +217,31 @@ namespace Subsurface
floorY = Limbs[0].SimPosition.Y;
}
}
void UpdateSimpleAnim()
{
movement = MathUtils.SmoothStep(movement, TargetMovement*swimSpeed, 1.0f);
if (movement == Vector2.Zero) return;
float movementAngle = MathUtils.VectorToAngle(movement) - MathHelper.PiOver2;
RefLimb.body.SmoothRotate(
(rotateTowardsMovement) ?
RefLimb.body.Rotation + MathUtils.GetShortestAngle(RefLimb.body.Rotation, movementAngle) :
HeadAngle*Dir);
RefLimb.pullJoint.Enabled = true;
RefLimb.pullJoint.WorldAnchorB =
RefLimb.SimPosition + movement * 0.1f;
RefLimb.body.SmoothRotate(0.0f);
foreach (Limb l in Limbs)
{
if (l == RefLimb) continue;
l.body.SetTransform(RefLimb.SimPosition, RefLimb.Rotation);
}
}
void UpdateWalkAnim(float deltaTime)
{