Better autopilot, guiframe tweaking, fixed ui scaling, aicontroller bugfixes, human walk/run anim uses HandIK
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
@@ -21,7 +22,7 @@ namespace Subsurface
|
||||
set { Character.AnimController.TargetMovement = value; }
|
||||
}
|
||||
|
||||
public Vector2 Position
|
||||
public Vector2 SimPosition
|
||||
{
|
||||
get { return Character.AnimController.Limbs[0].SimPosition; }
|
||||
}
|
||||
@@ -44,6 +45,11 @@ namespace Subsurface
|
||||
steeringManager = new SteeringManager(this);
|
||||
}
|
||||
|
||||
public virtual void DebugDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnAttacked(IDamageable attacker, float amount) { }
|
||||
|
||||
public virtual void SelectTarget(AITarget target) { }
|
||||
|
||||
@@ -6,6 +6,7 @@ using FarseerPhysics;
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Subsurface
|
||||
{
|
||||
@@ -264,6 +265,9 @@ namespace Subsurface
|
||||
|
||||
public override void OnAttacked(IDamageable attacker, float amount)
|
||||
{
|
||||
updateTargetsTimer = Math.Min(updateTargetsTimer, 0.1f);
|
||||
coolDownTimer *= 0.1f;
|
||||
|
||||
if (attacker==null || attacker.AiTarget==null) return;
|
||||
AITargetMemory targetMemory = FindTargetMemory(attacker.AiTarget);
|
||||
targetMemory.Priority += amount;
|
||||
@@ -319,7 +323,7 @@ namespace Subsurface
|
||||
Vector2.Normalize(attackPosition - limb.SimPosition));
|
||||
}
|
||||
|
||||
steeringManager.SteeringSeek(attackPosition + (limb.SimPosition-Position), 5.0f);
|
||||
steeringManager.SteeringSeek(attackPosition + (limb.SimPosition-SimPosition), 5.0f);
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -329,6 +333,7 @@ namespace Subsurface
|
||||
|
||||
if (attackTimer >= limb.attack.Duration)
|
||||
{
|
||||
wallAttackPos = Vector2.Zero;
|
||||
attackTimer = 0.0f;
|
||||
if (Vector2.Distance(limb.SimPosition, attackPosition)<5.0) coolDownTimer = attackCoolDown;
|
||||
|
||||
@@ -477,6 +482,32 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public override void DebugDraw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (Character.IsDead) return;
|
||||
|
||||
Vector2 pos = Character.Position;
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
if (selectedAiTarget!=null)
|
||||
{
|
||||
GUI.DrawLine(spriteBatch, pos, ConvertUnits.ToDisplayUnits(new Vector2(selectedAiTarget.Position.X, -selectedAiTarget.Position.Y)), Color.Red);
|
||||
|
||||
if (wallAttackPos!=Vector2.Zero)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, ConvertUnits.ToDisplayUnits(new Vector2(wallAttackPos.X, -wallAttackPos.Y)) - new Vector2(10.0f, 10.0f), new Vector2(20.0f, 20.0f), Color.Red, false);
|
||||
}
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, targetValue.ToString(), pos - Vector2.UnitY*20.0f, Color.Red);
|
||||
|
||||
}
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, targetValue.ToString(), pos - Vector2.UnitY * 80.0f, Color.Red);
|
||||
|
||||
spriteBatch.DrawString(GUI.Font, "updatetargets: "+updateTargetsTimer, pos - Vector2.UnitY * 100.0f, Color.Red);
|
||||
spriteBatch.DrawString(GUI.Font, "cooldown: " + coolDownTimer, pos - Vector2.UnitY * 120.0f, Color.Red);
|
||||
}
|
||||
|
||||
public override void FillNetworkData(NetOutgoingMessage message)
|
||||
{
|
||||
message.Write((byte)state);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Subsurface
|
||||
get;
|
||||
}
|
||||
|
||||
Vector2 Position
|
||||
Vector2 SimPosition
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Subsurface
|
||||
|
||||
private Vector2 DoSteeringSeek(Vector2 target, float speed = 1.0f)
|
||||
{
|
||||
Vector2 targetVel = target - host.Position;
|
||||
Vector2 targetVel = target - host.SimPosition;
|
||||
|
||||
if (targetVel.LengthSquared() < 0.00001f) return Vector2.Zero;
|
||||
|
||||
@@ -111,12 +111,12 @@ namespace Subsurface
|
||||
|
||||
float maxDistance = 2.0f;
|
||||
|
||||
Vector2 ahead = host.Position + Vector2.Normalize(host.Steering)*maxDistance;
|
||||
Vector2 ahead = host.SimPosition + Vector2.Normalize(host.Steering)*maxDistance;
|
||||
|
||||
if (rayCastTimer <= 0.0f)
|
||||
{
|
||||
rayCastTimer = RayCastInterval;
|
||||
Body closestBody = Submarine.CheckVisibility(host.Position, ahead);
|
||||
Body closestBody = Submarine.CheckVisibility(host.SimPosition, ahead);
|
||||
if (closestBody == null)
|
||||
{
|
||||
avoidSteering = Vector2.Zero;
|
||||
|
||||
@@ -5,32 +5,55 @@ namespace Subsurface
|
||||
{
|
||||
class SteeringPath
|
||||
{
|
||||
private Queue<WayPoint> nodes;
|
||||
|
||||
WayPoint currentNode;
|
||||
private List<WayPoint> nodes;
|
||||
|
||||
int currentIndex;
|
||||
|
||||
public SteeringPath()
|
||||
{
|
||||
nodes = new Queue<WayPoint>();
|
||||
nodes = new List<WayPoint>();
|
||||
}
|
||||
|
||||
public void AddNode(WayPoint node)
|
||||
{
|
||||
if (node == null) return;
|
||||
nodes.Enqueue(node);
|
||||
nodes.Add(node);
|
||||
}
|
||||
|
||||
public WayPoint CurrentNode
|
||||
{
|
||||
get { return currentNode; }
|
||||
get
|
||||
{
|
||||
if (currentIndex < 0 || currentIndex > nodes.Count - 1) return null;
|
||||
return nodes[currentIndex];
|
||||
}
|
||||
}
|
||||
|
||||
public WayPoint GetNode(Vector2 pos, float minDistance = 0.1f)
|
||||
public List<WayPoint> Nodes
|
||||
{
|
||||
if (nodes.Count == 0) return null;
|
||||
if (currentNode == null || Vector2.Distance(pos, currentNode.SimPosition) < minDistance) currentNode = nodes.Dequeue();
|
||||
get { return nodes; }
|
||||
}
|
||||
|
||||
return currentNode;
|
||||
public WayPoint NextNode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (currentIndex+1 < 0 || currentIndex+1 > nodes.Count - 1) return null;
|
||||
return nodes[currentIndex+1];
|
||||
}
|
||||
}
|
||||
|
||||
public void SkipToNextNode()
|
||||
{
|
||||
currentIndex++;
|
||||
}
|
||||
|
||||
public WayPoint CheckProgress(Vector2 pos, float minSimDistance = 0.1f)
|
||||
{
|
||||
if (nodes.Count == 0 || currentIndex>nodes.Count-1) return null;
|
||||
if (Vector2.Distance(pos, nodes[currentIndex].SimPosition) < minSimDistance) currentIndex++;
|
||||
|
||||
return CurrentNode;
|
||||
}
|
||||
|
||||
public void ClearPath()
|
||||
|
||||
@@ -59,6 +59,13 @@ namespace Subsurface
|
||||
aiController.Update(deltaTime);
|
||||
}
|
||||
|
||||
public override void DrawFront(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawFront(spriteBatch);
|
||||
|
||||
if (GameMain.DebugDraw) aiController.DebugDraw(spriteBatch);
|
||||
}
|
||||
|
||||
public override AttackResult AddDamage(IDamageable attacker, Vector2 position, Attack attack, float deltaTime, bool playSound = false)
|
||||
{
|
||||
AttackResult result = base.AddDamage(attacker, position, attack, deltaTime, playSound);
|
||||
@@ -113,7 +120,7 @@ namespace Subsurface
|
||||
LargeUpdateTimer = Math.Max(0, LargeUpdateTimer - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message)
|
||||
{
|
||||
if (type == NetworkEventType.KillCharacter)
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Subsurface
|
||||
get { return drawPosition; }
|
||||
}
|
||||
|
||||
public Vector2 Position
|
||||
public Vector2 SimPosition
|
||||
{
|
||||
get { return position; }
|
||||
}
|
||||
@@ -179,7 +179,7 @@ namespace Subsurface
|
||||
|
||||
foreach (BackgroundSprite member in Members)
|
||||
{
|
||||
midPoint += member.Position;
|
||||
midPoint += member.SimPosition;
|
||||
}
|
||||
|
||||
midPoint /= Members.Count;
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Subsurface
|
||||
|
||||
protected bool isDead;
|
||||
|
||||
bool isHumanoid;
|
||||
public readonly bool IsHumanoid;
|
||||
|
||||
//the name of the species (e.q. human)
|
||||
public readonly string SpeciesName;
|
||||
@@ -200,7 +200,7 @@ namespace Subsurface
|
||||
get { return bleeding; }
|
||||
set
|
||||
{
|
||||
if (MathUtils.IsValid(value)) return;
|
||||
if (!MathUtils.IsValid(value)) return;
|
||||
bleeding = Math.Max(value, 0.0f);
|
||||
}
|
||||
}
|
||||
@@ -344,9 +344,9 @@ namespace Subsurface
|
||||
|
||||
SpeciesName = ToolBox.GetAttributeString(doc.Root, "name", "Unknown");
|
||||
|
||||
isHumanoid = ToolBox.GetAttributeBool(doc.Root, "humanoid", false);
|
||||
IsHumanoid = ToolBox.GetAttributeBool(doc.Root, "humanoid", false);
|
||||
|
||||
if (isHumanoid)
|
||||
if (IsHumanoid)
|
||||
{
|
||||
AnimController = new HumanoidAnimController(this, doc.Root.Element("ragdoll"));
|
||||
AnimController.TargetDir = Direction.Right;
|
||||
@@ -660,7 +660,7 @@ namespace Subsurface
|
||||
if (closestCharacter != null)
|
||||
{
|
||||
if (closestCharacter != selectedCharacter) selectedCharacter = null;
|
||||
if (!closestCharacter.isHumanoid) closestCharacter = null;
|
||||
if (!closestCharacter.IsHumanoid) closestCharacter = null;
|
||||
}
|
||||
|
||||
closestItem = FindClosestItem(mouseSimPos);
|
||||
@@ -706,7 +706,7 @@ namespace Subsurface
|
||||
{
|
||||
selectedCharacter = null;
|
||||
}
|
||||
else if (closestCharacter != null && closestCharacter.isDead && closestCharacter.isHumanoid)
|
||||
else if (closestCharacter != null && closestCharacter.isDead && closestCharacter.IsHumanoid)
|
||||
{
|
||||
selectedCharacter = closestCharacter;
|
||||
}
|
||||
@@ -758,7 +758,7 @@ namespace Subsurface
|
||||
ControlLocalPlayer(deltaTime, cam);
|
||||
}
|
||||
|
||||
Control(deltaTime, cam);
|
||||
if (!(this is AICharacter)) Control(deltaTime, cam);
|
||||
|
||||
UpdateSightRange();
|
||||
aiTarget.SoundRange = 0.0f;
|
||||
@@ -820,7 +820,7 @@ namespace Subsurface
|
||||
CharacterHUD.Draw(spriteBatch, this, cam);
|
||||
}
|
||||
|
||||
public void DrawFront(SpriteBatch spriteBatch)
|
||||
public virtual void DrawFront(SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 pos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition);
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
@@ -30,14 +30,9 @@ namespace Subsurface
|
||||
|
||||
public override void UpdateAnim(float deltaTime)
|
||||
{
|
||||
if (character.IsDead) return;
|
||||
|
||||
Vector2 colliderPos = GetLimb(LimbType.Torso).SimPosition;
|
||||
if (character.IsDead) return;
|
||||
|
||||
if (!MathUtils.IsValid(RefLimb.body.SimPosition))
|
||||
{
|
||||
int a = 1;
|
||||
}
|
||||
Vector2 colliderPos = GetLimb(LimbType.Torso).SimPosition;
|
||||
|
||||
//if (inWater) stairs = null;
|
||||
|
||||
@@ -57,7 +52,7 @@ namespace Subsurface
|
||||
case Physics.CollisionStairs:
|
||||
if (inWater && TargetMovement.Y < 0.5f) return -1;
|
||||
Structure structure = fixture.Body.UserData as Structure;
|
||||
if (stairs == null && structure!=null)
|
||||
if (stairs == null && structure != null)
|
||||
{
|
||||
if (LowestLimb.SimPosition.Y < structure.SimPosition.Y)
|
||||
{
|
||||
@@ -70,7 +65,7 @@ namespace Subsurface
|
||||
}
|
||||
break;
|
||||
case Physics.CollisionPlatform:
|
||||
Structure platform = fixture.Body.UserData as Structure;
|
||||
Structure platform = fixture.Body.UserData as Structure;
|
||||
if (IgnorePlatforms || LowestLimb.Position.Y < platform.Rect.Y) return -1;
|
||||
break;
|
||||
case Physics.CollisionWall:
|
||||
@@ -118,12 +113,12 @@ namespace Subsurface
|
||||
if (closestFraction == 1) //raycast didn't hit anything
|
||||
{
|
||||
floorY = (currentHull == null) ? -1000.0f : ConvertUnits.ToSimUnits(currentHull.Rect.Y - currentHull.Rect.Height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
floorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
|
||||
}
|
||||
|
||||
|
||||
|
||||
IgnorePlatforms = (TargetMovement.Y < 0.0f);
|
||||
|
||||
@@ -175,18 +170,20 @@ namespace Subsurface
|
||||
aiming = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void UpdateStanding()
|
||||
{
|
||||
Vector2 handPos;
|
||||
|
||||
//if you're allergic to magic numbers, stop reading now
|
||||
|
||||
Limb leftFoot = GetLimb(LimbType.LeftFoot);
|
||||
Limb rightFoot = GetLimb(LimbType.RightFoot);
|
||||
Limb head = GetLimb(LimbType.Head);
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
|
||||
Limb waist = GetLimb(LimbType.Waist);
|
||||
Limb waist = GetLimb(LimbType.Waist);
|
||||
|
||||
Limb leftHand = GetLimb(LimbType.LeftHand);
|
||||
Limb rightHand = GetLimb(LimbType.RightHand);
|
||||
@@ -198,31 +195,31 @@ namespace Subsurface
|
||||
float walkCycleSpeed = head.LinearVelocity.X * walkAnimSpeed;
|
||||
if (stairs != null)
|
||||
{
|
||||
TargetMovement = new Vector2(MathHelper.Clamp(TargetMovement.X, -2.0f, 2.0f), TargetMovement.Y) ;
|
||||
TargetMovement = new Vector2(MathHelper.Clamp(TargetMovement.X, -1.5f, 1.5f), TargetMovement.Y);
|
||||
|
||||
if ((TargetMovement.X>0.0f && stairs.StairDirection == Direction.Right) ||
|
||||
if ((TargetMovement.X > 0.0f && stairs.StairDirection == Direction.Right) ||
|
||||
TargetMovement.X < 0.0f && stairs.StairDirection == Direction.Left)
|
||||
{
|
||||
TargetMovement *= 1.35f;
|
||||
TargetMovement *= 1.7f;
|
||||
walkCycleSpeed *= 1.7f;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
TargetMovement /= 1.2f;
|
||||
}
|
||||
|
||||
walkCycleSpeed *= 1.5f;
|
||||
TargetMovement /= 1.0f;
|
||||
walkCycleSpeed *= 1.5f;
|
||||
}
|
||||
}
|
||||
|
||||
Vector2 colliderPos = new Vector2(torso.SimPosition.X, floorY);
|
||||
|
||||
float walkPosX = (float)Math.Cos(walkPos);
|
||||
float walkPosY = (float)Math.Sin(walkPos);
|
||||
float runningModifier = (float)Math.Max(Math.Abs(movement.X) / 1.5f, 1.0);
|
||||
float runningModifier = (float)Math.Max(Math.Abs(TargetMovement.X) / 1.5f, 1.0);
|
||||
|
||||
Vector2 stepSize = new Vector2(
|
||||
this.stepSize.X * walkPosX * runningModifier,
|
||||
this.stepSize.Y * walkPosY * runningModifier * runningModifier);
|
||||
|
||||
|
||||
float footMid = waist.SimPosition.X;// (leftFoot.SimPosition.X + rightFoot.SimPosition.X) / 2.0f;
|
||||
|
||||
int limbsInWater = 0;
|
||||
@@ -231,184 +228,169 @@ namespace Subsurface
|
||||
if (limb.inWater) limbsInWater++;
|
||||
}
|
||||
|
||||
TargetMovement *= (1.0f - 0.5f*((float)limbsInWater/(float)Limbs.Count()));
|
||||
TargetMovement *= (1.0f - 0.5f * ((float)limbsInWater / (float)Limbs.Count()));
|
||||
|
||||
movement = MathUtils.SmoothStep(movement, TargetMovement, movementLerp);
|
||||
movement.Y = 0.0f;
|
||||
|
||||
|
||||
|
||||
//place the anchors of the head and the torso to make the ragdoll stand
|
||||
if (onGround && LowestLimb != null && (LowestLimb.SimPosition.Y-floorY < 0.5f || stairs != null) && head !=null)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
getUpSpeed = getUpSpeed * (head.SimPosition.Y - colliderPos.Y);//, 0.25f);
|
||||
Limb leg = GetLimb((i == 0) ? LimbType.LeftThigh : LimbType.RightThigh);// : leftLeg;
|
||||
|
||||
if (stairs != null)
|
||||
{
|
||||
if (LowestLimb.SimPosition.Y < stairs.SimPosition.Y) IgnorePlatforms = true;
|
||||
|
||||
torso.pullJoint.Enabled = true;
|
||||
torso.pullJoint.WorldAnchorB = new Vector2(
|
||||
MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.35f, getUpSpeed * 0.8f),
|
||||
MathHelper.SmoothStep(torso.SimPosition.Y, colliderPos.Y + TorsoPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 3.0f));
|
||||
if (leg.SimPosition.Y < torso.SimPosition.Y) continue;
|
||||
|
||||
|
||||
head.pullJoint.Enabled = true;
|
||||
head.pullJoint.WorldAnchorB = new Vector2(
|
||||
MathHelper.SmoothStep(head.SimPosition.X, footMid + movement.X * 0.4f, getUpSpeed * 0.8f),
|
||||
MathHelper.SmoothStep(head.SimPosition.Y, colliderPos.Y + HeadPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 3.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
torso.pullJoint.Enabled = true;
|
||||
torso.pullJoint.WorldAnchorB =
|
||||
MathUtils.SmoothStep(torso.SimPosition,
|
||||
new Vector2(footMid + movement.X * 0.3f, colliderPos.Y + TorsoPosition), getUpSpeed);
|
||||
|
||||
head.pullJoint.Enabled = true;
|
||||
head.pullJoint.WorldAnchorB =
|
||||
MathUtils.SmoothStep(head.SimPosition,
|
||||
new Vector2(footMid + movement.X * (0.2f + runningModifier / 10.0f), colliderPos.Y + HeadPosition), getUpSpeed);
|
||||
|
||||
waist.pullJoint.Enabled = true;
|
||||
waist.pullJoint.WorldAnchorB = waist.SimPosition + movement*0.1f;
|
||||
//MathUtils.SmoothStep(waist.SimPosition,
|
||||
//new Vector2(footMid + movement.X * 0.4f, colliderPos.Y + HeadPosition), getUpSpeed);
|
||||
}
|
||||
|
||||
|
||||
//moving horizontally
|
||||
if (TargetMovement.X != 0.0f)
|
||||
{
|
||||
//progress the walking animation
|
||||
walkPos -= (walkCycleSpeed / runningModifier)*0.8f;
|
||||
|
||||
MoveLimb(leftFoot,
|
||||
colliderPos + new Vector2(
|
||||
stepSize.X,
|
||||
(stepSize.Y > 0.0f) ? stepSize.Y : -0.15f),
|
||||
15.0f, true);
|
||||
|
||||
MoveLimb(rightFoot,
|
||||
colliderPos + new Vector2(
|
||||
-stepSize.X,
|
||||
(-stepSize.Y > 0.0f) ? -stepSize.Y : -0.15f),
|
||||
15.0f, true);
|
||||
|
||||
leftFoot.body.SmoothRotate(leftLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier);
|
||||
rightFoot.body.SmoothRotate(rightLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier);
|
||||
|
||||
if (runningModifier>1.0f)
|
||||
{
|
||||
if (walkPosY > 0.0f)
|
||||
{
|
||||
GetLimb(LimbType.LeftThigh).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * thighTorque);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetLimb(LimbType.RightThigh).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * thighTorque);
|
||||
}
|
||||
}
|
||||
|
||||
if (legTorque>0.0f)
|
||||
{
|
||||
if (Math.Sign(walkPosX) != Math.Sign(movement.X))
|
||||
{
|
||||
GetLimb(LimbType.LeftLeg).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * legTorque / runningModifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetLimb(LimbType.RightLeg).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * legTorque / runningModifier);
|
||||
}
|
||||
}
|
||||
|
||||
//calculate the positions of hands
|
||||
handPos = torso.SimPosition;
|
||||
handPos.X = -walkPosX * 0.2f;// *runningModifier;
|
||||
|
||||
float lowerY = -0.6f + runningModifier/3.5f;
|
||||
|
||||
handPos.Y = lowerY + (float)(Math.Abs(Math.Sin(walkPos - Math.PI * 1.5f) * 0.05)) / runningModifier;
|
||||
|
||||
Vector2 posAdditon = new Vector2(movement.X*0.07f, 0.0f);
|
||||
if (stairs!=null)
|
||||
{
|
||||
if ((stairs.StairDirection == Direction.Right && movement.X < 0.0f) ||
|
||||
(stairs.StairDirection == Direction.Left && movement.X > 0.0f))
|
||||
{
|
||||
posAdditon.Y -= 0.1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
posAdditon.Y += 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
if (!rightHand.Disabled)
|
||||
{
|
||||
rightHand.body.ApplyTorque(walkPosY * runningModifier * Dir);
|
||||
MoveLimb(rightHand, torso.SimPosition + posAdditon +
|
||||
new Vector2(
|
||||
-handPos.X,
|
||||
(Math.Sign(walkPosX) == Math.Sign(Dir)) ? handPos.Y : lowerY),
|
||||
15.0f, true);
|
||||
}
|
||||
|
||||
if (!leftHand.Disabled)
|
||||
{
|
||||
leftHand.body.ApplyTorque(-walkPosY * runningModifier * Dir);
|
||||
MoveLimb(leftHand, torso.SimPosition + posAdditon +
|
||||
new Vector2(
|
||||
handPos.X,
|
||||
(Math.Sign(walkPosX) == Math.Sign(-Dir)) ? handPos.Y : lowerY),
|
||||
15.0f, true);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
float movementFactor = (movement.X / 4.0f) * movement.X * Math.Sign(movement.X);
|
||||
|
||||
Vector2 footPos = new Vector2(
|
||||
colliderPos.X + movementFactor - Dir * 0.05f,
|
||||
colliderPos.Y - 0.2f - Math.Abs(movementFactor));
|
||||
|
||||
MoveLimb(leftFoot, footPos, 2.5f);
|
||||
MoveLimb(rightFoot, footPos, 2.5f);
|
||||
|
||||
leftFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f);
|
||||
rightFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f);
|
||||
|
||||
if (!rightHand.Disabled)
|
||||
{
|
||||
// MoveLimb(rightHand, handPos, 0.05f, true);
|
||||
//rightHand.body.ApplyLinearImpulse((handPos - rightHand.Position));
|
||||
rightHand.body.SmoothRotate(0.0f, 5.0f);
|
||||
|
||||
var rightArm = GetLimb(LimbType.RightArm);
|
||||
rightArm.body.SmoothRotate(0.0f, 20.0f);
|
||||
}
|
||||
|
||||
if (!leftHand.Disabled)
|
||||
{
|
||||
//MoveLimb(leftHand, handPos, 0.05f, true);
|
||||
//leftHand.body.ApplyLinearImpulse((handPos - leftHand.Position));
|
||||
leftHand.body.SmoothRotate(0.0f, 5.0f);
|
||||
|
||||
var leftArm = GetLimb(LimbType.LeftArm);
|
||||
leftArm.body.SmoothRotate(0.0f, 20.0f);
|
||||
}
|
||||
}
|
||||
leg.body.ApplyTorque(-Dir * leg.Mass * 10.0f);
|
||||
}
|
||||
|
||||
//for (int i = 0; i < 2; i++)
|
||||
//{
|
||||
// Limb leg = (i == 0) ? rightLeg : leftLeg;
|
||||
//place the anchors of the head and the torso to make the ragdoll stand
|
||||
|
||||
// if (leg.SimPosition.Y < waist.SimPosition.Y) continue;
|
||||
if (LowestLimb == null) return;
|
||||
|
||||
if (!onGround || (LowestLimb.SimPosition.Y - floorY > 0.5f && stairs == null)) return;
|
||||
|
||||
getUpSpeed = getUpSpeed * (head.SimPosition.Y - colliderPos.Y);
|
||||
|
||||
if (stairs != null)
|
||||
{
|
||||
if (LowestLimb.SimPosition.Y < stairs.SimPosition.Y) IgnorePlatforms = true;
|
||||
|
||||
torso.pullJoint.Enabled = true;
|
||||
torso.pullJoint.WorldAnchorB = new Vector2(
|
||||
MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.35f, getUpSpeed * 0.8f),
|
||||
MathHelper.SmoothStep(torso.SimPosition.Y, colliderPos.Y + TorsoPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 2.0f));
|
||||
|
||||
|
||||
head.pullJoint.Enabled = true;
|
||||
head.pullJoint.WorldAnchorB = new Vector2(
|
||||
MathHelper.SmoothStep(head.SimPosition.X, footMid + movement.X * 0.4f, getUpSpeed * 0.8f),
|
||||
MathHelper.SmoothStep(head.SimPosition.Y, colliderPos.Y + HeadPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 2.0f));
|
||||
|
||||
waist.pullJoint.Enabled = true;
|
||||
waist.pullJoint.WorldAnchorB = waist.SimPosition;// +movement * 0.3f;
|
||||
}
|
||||
else
|
||||
{
|
||||
torso.pullJoint.Enabled = true;
|
||||
torso.pullJoint.WorldAnchorB =
|
||||
MathUtils.SmoothStep(torso.SimPosition,
|
||||
new Vector2(footMid + movement.X * 0.3f, colliderPos.Y + TorsoPosition), getUpSpeed);
|
||||
|
||||
|
||||
head.pullJoint.Enabled = true;
|
||||
head.pullJoint.WorldAnchorB =
|
||||
MathUtils.SmoothStep(head.SimPosition,
|
||||
new Vector2(footMid + movement.X * 0.3f, colliderPos.Y + HeadPosition), getUpSpeed*1.2f);
|
||||
|
||||
waist.pullJoint.Enabled = true;
|
||||
waist.pullJoint.WorldAnchorB = waist.SimPosition + movement * 0.1f;
|
||||
//MathUtils.SmoothStep(waist.SimPosition,
|
||||
//new Vector2(footMid + movement.X * 0.4f, colliderPos.Y + HeadPosition), getUpSpeed);
|
||||
}
|
||||
|
||||
|
||||
//moving horizontally
|
||||
if (TargetMovement.X != 0.0f)
|
||||
{
|
||||
//progress the walking animation
|
||||
walkPos -= (walkCycleSpeed / runningModifier) * 0.8f;
|
||||
|
||||
MoveLimb(leftFoot,
|
||||
colliderPos + new Vector2(
|
||||
stepSize.X,
|
||||
(stepSize.Y > 0.0f) ? stepSize.Y : -0.15f),
|
||||
15.0f, true);
|
||||
|
||||
MoveLimb(rightFoot,
|
||||
colliderPos + new Vector2(
|
||||
-stepSize.X,
|
||||
(-stepSize.Y > 0.0f) ? -stepSize.Y : -0.15f),
|
||||
15.0f, true);
|
||||
|
||||
leftFoot.body.SmoothRotate(leftLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier);
|
||||
rightFoot.body.SmoothRotate(rightLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier);
|
||||
|
||||
if (runningModifier > 1.0f)
|
||||
{
|
||||
if (walkPosY > 0.0f)
|
||||
{
|
||||
GetLimb(LimbType.LeftThigh).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * thighTorque);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetLimb(LimbType.RightThigh).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * thighTorque);
|
||||
}
|
||||
}
|
||||
|
||||
if (legTorque > 0.0f)
|
||||
{
|
||||
if (Math.Sign(walkPosX) != Math.Sign(movement.X))
|
||||
{
|
||||
GetLimb(LimbType.LeftLeg).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * legTorque / runningModifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetLimb(LimbType.RightLeg).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * legTorque / runningModifier);
|
||||
}
|
||||
}
|
||||
|
||||
//calculate the positions of hands
|
||||
handPos = torso.SimPosition;
|
||||
handPos.X = -walkPosX * 0.4f;
|
||||
|
||||
float lowerY = -1.0f + (runningModifier - 1.0f) * 0.8f;
|
||||
|
||||
handPos.Y = lowerY + (float)(Math.Abs(Math.Sin(walkPos - Math.PI * 1.5f) * 0.15 * runningModifier));
|
||||
|
||||
Vector2 posAddition = new Vector2(-movement.X * 0.015f * runningModifier, 0.0f);
|
||||
|
||||
if (!rightHand.Disabled)
|
||||
{
|
||||
HandIK(rightHand, torso.SimPosition + posAddition +
|
||||
new Vector2(
|
||||
-handPos.X,
|
||||
(Math.Sign(walkPosX) == Math.Sign(Dir)) ? handPos.Y : lowerY), 0.7f*runningModifier);
|
||||
}
|
||||
|
||||
if (!leftHand.Disabled)
|
||||
{
|
||||
HandIK(leftHand, torso.SimPosition + posAddition +
|
||||
new Vector2(
|
||||
handPos.X,
|
||||
(Math.Sign(walkPosX) == Math.Sign(-Dir)) ? handPos.Y : lowerY), 0.7f * runningModifier);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
float movementFactor = (movement.X / 4.0f) * movement.X * Math.Sign(movement.X);
|
||||
|
||||
Vector2 footPos = new Vector2(
|
||||
colliderPos.X,
|
||||
colliderPos.Y - 0.2f);
|
||||
|
||||
MoveLimb(leftFoot, footPos, 2.5f);
|
||||
MoveLimb(rightFoot, footPos, 2.5f);
|
||||
|
||||
leftFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f);
|
||||
rightFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f);
|
||||
|
||||
if (!rightHand.Disabled)
|
||||
{
|
||||
rightHand.body.SmoothRotate(0.0f, 5.0f);
|
||||
|
||||
var rightArm = GetLimb(LimbType.RightArm);
|
||||
rightArm.body.SmoothRotate(0.0f, 20.0f);
|
||||
}
|
||||
|
||||
if (!leftHand.Disabled)
|
||||
{
|
||||
leftHand.body.SmoothRotate(0.0f, 5.0f);
|
||||
|
||||
var leftArm = GetLimb(LimbType.LeftArm);
|
||||
leftArm.body.SmoothRotate(0.0f, 20.0f);
|
||||
}
|
||||
}
|
||||
|
||||
// //leg.body.ApplyTorque(Dir * leg.Mass * 50.0f);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
@@ -416,23 +398,23 @@ namespace Subsurface
|
||||
{
|
||||
movement = MathUtils.SmoothStep(movement, TargetMovement, movementLerp);
|
||||
|
||||
if (inWater && movement.LengthSquared()>0.00001f)
|
||||
if (inWater && movement.LengthSquared() > 0.00001f)
|
||||
{
|
||||
movement = Vector2.Normalize(movement);
|
||||
}
|
||||
|
||||
|
||||
RefLimb.pullJoint.Enabled = true;
|
||||
RefLimb.pullJoint.WorldAnchorB =
|
||||
RefLimb.SimPosition + movement*0.15f;
|
||||
RefLimb.SimPosition + movement * 0.15f;
|
||||
|
||||
RefLimb.body.SmoothRotate(0.0f);
|
||||
|
||||
foreach (Limb l in Limbs)
|
||||
{
|
||||
if (l==RefLimb) continue;
|
||||
if (l == RefLimb) continue;
|
||||
l.body.SetTransform(RefLimb.SimPosition, RefLimb.Rotation);
|
||||
}
|
||||
//new Vector2(movement.X, floorY + HeadPosition), 0.5f);
|
||||
//new Vector2(movement.X, floorY + HeadPosition), 0.5f);
|
||||
}
|
||||
|
||||
void UpdateSwimming()
|
||||
@@ -447,20 +429,20 @@ namespace Subsurface
|
||||
|
||||
if (currentHull != null && (currentHull.Rect.Y - currentHull.Surface > 50.0f) && !head.inWater)
|
||||
{
|
||||
surfaceLimiter = (ConvertUnits.ToDisplayUnits(head.SimPosition.Y)-surfaceY);
|
||||
surfaceLimiter = (ConvertUnits.ToDisplayUnits(head.SimPosition.Y) - surfaceY);
|
||||
surfaceLimiter = Math.Max(1.0f, surfaceLimiter);
|
||||
if (surfaceLimiter > 20.0f) return;
|
||||
}
|
||||
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
Limb leftHand = GetLimb(LimbType.LeftHand);
|
||||
Limb rightHand = GetLimb(LimbType.RightHand);
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
Limb leftHand = GetLimb(LimbType.LeftHand);
|
||||
Limb rightHand = GetLimb(LimbType.RightHand);
|
||||
|
||||
Limb leftFoot = GetLimb(LimbType.LeftFoot);
|
||||
Limb rightFoot = GetLimb(LimbType.RightFoot);
|
||||
Limb leftLeg = GetLimb(LimbType.LeftLeg);
|
||||
Limb rightLeg = GetLimb(LimbType.RightLeg);
|
||||
|
||||
Limb leftFoot = GetLimb(LimbType.LeftFoot);
|
||||
Limb rightFoot = GetLimb(LimbType.RightFoot);
|
||||
Limb leftLeg = GetLimb(LimbType.LeftLeg);
|
||||
Limb rightLeg = GetLimb(LimbType.RightLeg);
|
||||
|
||||
float rotation = MathHelper.WrapAngle(torso.Rotation);
|
||||
rotation = MathHelper.ToDegrees(rotation);
|
||||
if (rotation < 0.0f) rotation += 360;
|
||||
@@ -475,12 +457,12 @@ namespace Subsurface
|
||||
|
||||
float targetSpeed = TargetMovement.Length();
|
||||
if (targetSpeed > 0.0f) TargetMovement /= targetSpeed;
|
||||
|
||||
|
||||
if (targetSpeed > 0.1f)
|
||||
{
|
||||
if (!aiming)
|
||||
{
|
||||
torso.body.SmoothRotate(MathUtils.VectorToAngle(TargetMovement)-MathHelper.PiOver2);
|
||||
torso.body.SmoothRotate(MathUtils.VectorToAngle(TargetMovement) - MathHelper.PiOver2);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -526,7 +508,7 @@ namespace Subsurface
|
||||
movement.Y -= 0.05f;
|
||||
|
||||
head.body.ApplyForce((new Vector2(movement.X,
|
||||
movement.Y / surfaceLimiter + 0.2f) - head.body.LinearVelocity * 0.2f) *
|
||||
movement.Y / surfaceLimiter + 0.2f) - head.body.LinearVelocity * 0.2f) *
|
||||
30.0f * head.body.Mass);
|
||||
|
||||
torso.body.ApplyForce((new Vector2(movement.X,
|
||||
@@ -546,7 +528,7 @@ namespace Subsurface
|
||||
transformedFootPos,
|
||||
Matrix.CreateRotationZ(torso.body.Rotation));
|
||||
|
||||
if (Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, rightThigh.Rotation))<0.3f)
|
||||
if (Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, rightThigh.Rotation)) < 0.3f)
|
||||
{
|
||||
MoveLimb(rightFoot, footPos - transformedFootPos, 1.0f);
|
||||
}
|
||||
@@ -554,14 +536,14 @@ namespace Subsurface
|
||||
{
|
||||
MoveLimb(leftFoot, footPos + transformedFootPos, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
handPos = (torso.SimPosition + head.SimPosition) / 2.0f;
|
||||
|
||||
//if (!rightHand.Disabled) rightHand.body.ApplyTorque(leftHand.body.Mass * Dir);
|
||||
//if (!leftHand.Disabled) leftHand.body.ApplyTorque(leftHand.body.Mass * Dir);
|
||||
|
||||
|
||||
//at the surface, not moving sideways -> hands just float around
|
||||
if (!headInWater && TargetMovement.X == 0.0f && TargetMovement.Y>0)
|
||||
if (!headInWater && TargetMovement.X == 0.0f && TargetMovement.Y > 0)
|
||||
{
|
||||
handPos.X = handPos.X + Dir * 0.6f;
|
||||
|
||||
@@ -612,12 +594,12 @@ namespace Subsurface
|
||||
|
||||
//MoveLimb(leftHand, handPos + leftHandPos,1.5f);
|
||||
HandIK(leftHand, handPos + leftHandPos, 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateClimbing()
|
||||
{
|
||||
if (character.SelectedConstruction == null || character.SelectedConstruction.GetComponent<Ladder>()==null)
|
||||
if (character.SelectedConstruction == null || character.SelectedConstruction.GetComponent<Ladder>() == null)
|
||||
{
|
||||
Anim = Animation.None;
|
||||
return;
|
||||
@@ -630,15 +612,15 @@ namespace Subsurface
|
||||
|
||||
Vector2 footPos, handPos;
|
||||
|
||||
Limb leftFoot = GetLimb(LimbType.LeftFoot);
|
||||
Limb rightFoot = GetLimb(LimbType.RightFoot);
|
||||
Limb head = GetLimb(LimbType.Head);
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
Limb leftFoot = GetLimb(LimbType.LeftFoot);
|
||||
Limb rightFoot = GetLimb(LimbType.RightFoot);
|
||||
Limb head = GetLimb(LimbType.Head);
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
|
||||
Limb waist = GetLimb(LimbType.Waist);
|
||||
Limb waist = GetLimb(LimbType.Waist);
|
||||
|
||||
Limb leftHand = GetLimb(LimbType.LeftHand);
|
||||
Limb rightHand = GetLimb(LimbType.RightHand);
|
||||
Limb leftHand = GetLimb(LimbType.LeftHand);
|
||||
Limb rightHand = GetLimb(LimbType.RightHand);
|
||||
|
||||
Vector2 ladderSimPos = ConvertUnits.ToSimUnits(
|
||||
character.SelectedConstruction.Rect.X + character.SelectedConstruction.Rect.Width / 2.0f,
|
||||
@@ -668,7 +650,7 @@ namespace Subsurface
|
||||
rightHand.body.ApplyTorque(Dir * 2.0f);
|
||||
|
||||
footPos = new Vector2(
|
||||
handPos.X - Dir*0.05f,
|
||||
handPos.X - Dir * 0.05f,
|
||||
head.SimPosition.Y - stepHeight * 2.7f - ladderSimPos.Y - 0.7f);
|
||||
|
||||
//if (movement.Y < 0) footPos.Y += 0.05f;
|
||||
@@ -712,7 +694,7 @@ namespace Subsurface
|
||||
// - reached the top or bottom of the ladder
|
||||
if (Math.Abs(torso.LinearVelocity.Y) > 5.0f ||
|
||||
TargetMovement.X != 0.0f ||
|
||||
(TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition*1.5f) ||
|
||||
(TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition * 1.5f) ||
|
||||
(TargetMovement.Y > 0.0f && handPos.Y > 0.3f))
|
||||
{
|
||||
Anim = Animation.None;
|
||||
@@ -721,7 +703,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//float punchTimer;
|
||||
//bool punching;
|
||||
|
||||
@@ -777,12 +759,12 @@ namespace Subsurface
|
||||
transformedHandlePos[0] = Vector2.Transform(handlePos[0], itemTransfrom);
|
||||
transformedHandlePos[1] = Vector2.Transform(handlePos[1], itemTransfrom);
|
||||
|
||||
Limb head = GetLimb(LimbType.Head);
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
Limb leftHand = GetLimb(LimbType.LeftHand);
|
||||
Limb rightHand = GetLimb(LimbType.RightHand);
|
||||
Limb head = GetLimb(LimbType.Head);
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
Limb leftHand = GetLimb(LimbType.LeftHand);
|
||||
Limb rightHand = GetLimb(LimbType.RightHand);
|
||||
|
||||
Vector2 itemPos = aim ? aimPos : holdPos;
|
||||
Vector2 itemPos = aim ? aimPos : holdPos;
|
||||
|
||||
float itemAngle;
|
||||
if (stunTimer <= 0.0f && aim && itemPos != Vector2.Zero)
|
||||
@@ -810,7 +792,7 @@ namespace Subsurface
|
||||
{
|
||||
itemAngle = (torso.body.Rotation + holdAngle * Dir);
|
||||
}
|
||||
|
||||
|
||||
Vector2 shoulderPos = limbJoints[2].WorldAnchorA;
|
||||
Vector2 transformedHoldPos = shoulderPos;
|
||||
|
||||
@@ -847,7 +829,7 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
Vector2 bodyVelocity = torso.body.LinearVelocity / 60.0f;
|
||||
|
||||
|
||||
item.body.ResetDynamics();
|
||||
item.body.SetTransform(MathUtils.SmoothStep(item.body.SimPosition, transformedHoldPos + bodyVelocity, 0.5f), itemAngle);
|
||||
|
||||
@@ -859,7 +841,7 @@ namespace Subsurface
|
||||
Limb hand = (i == 0) ? rightHand : leftHand;
|
||||
|
||||
HandIK(hand, transformedHoldPos + transformedHandlePos[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandIK(Limb hand, Vector2 pos, float force = 1.0f)
|
||||
@@ -883,20 +865,22 @@ namespace Subsurface
|
||||
float armAngle = MathUtils.SolveTriangleSSS(a, b, c);
|
||||
float handAngle = MathUtils.SolveTriangleSSS(b, a, c);
|
||||
|
||||
arm.body.SmoothRotate((ang2 - armAngle * Dir), 20.0f*force);
|
||||
hand.body.SmoothRotate((ang2 + handAngle * Dir), 100.0f*force);
|
||||
arm.body.SmoothRotate((ang2 - armAngle * Dir), 20.0f * force);
|
||||
hand.body.SmoothRotate((ang2 + handAngle * Dir), 100.0f * force);
|
||||
}
|
||||
|
||||
public override void Flip()
|
||||
{
|
||||
base.Flip();
|
||||
|
||||
walkPos = -walkPos;
|
||||
|
||||
Limb torso = GetLimb(LimbType.Torso);
|
||||
|
||||
Vector2 difference;
|
||||
|
||||
Matrix torsoTransform = Matrix.CreateRotationZ(torso.Rotation);
|
||||
|
||||
|
||||
for (int i = 0; i < character.SelectedItems.Length; i++)
|
||||
{
|
||||
if (character.SelectedItems[i] != null)
|
||||
@@ -926,7 +910,7 @@ namespace Subsurface
|
||||
l.body.SetTransform(torso.SimPosition + Vector2.Transform(difference, -torsoTransform), -l.body.Rotation);
|
||||
break;
|
||||
default:
|
||||
if (!inWater) l.body.SetTransform(l.body.SimPosition,
|
||||
if (!inWater) l.body.SetTransform(l.body.SimPosition,
|
||||
MathUtils.WrapAnglePi(l.body.Rotation * (l.DoesFlip ? -1.0f : 1.0f)));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,9 @@ namespace Subsurface
|
||||
{
|
||||
int width = 500, height = 400;
|
||||
|
||||
GUIFrame frame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style);
|
||||
GUIFrame backFrame = new GUIFrame(Rectangle.Empty, Color.Black*0.5f);
|
||||
|
||||
GUIFrame frame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style, backFrame);
|
||||
frame.Padding = new Vector4(30.0f, 30.0f, 30.0f, 30.0f);
|
||||
|
||||
new GUITextBlock(new Rectangle(0,0,100,20), name, GUI.Style, Alignment.TopLeft, Alignment.TopLeft, frame, false, GUI.LargeFont);
|
||||
@@ -142,7 +144,7 @@ namespace Subsurface
|
||||
|
||||
|
||||
|
||||
return frame;
|
||||
return backFrame;
|
||||
}
|
||||
|
||||
public static void LoadAll(List<string> filePaths)
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Subsurface
|
||||
body.CollidesWith = Physics.CollisionAll & ~Physics.CollisionCharacter & ~Physics.CollisionMisc;
|
||||
}
|
||||
|
||||
impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 10.0f);
|
||||
impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", character.IsHumanoid ? 15.0f : 50.0f);
|
||||
|
||||
body.UserData = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user