Collider-controlled monster movement

This commit is contained in:
Regalis
2016-10-16 22:23:32 +03:00
parent f3e74a6a41
commit 704c7c7561
7 changed files with 205 additions and 363 deletions
+13 -3
View File
@@ -242,7 +242,6 @@ namespace Barotrauma
body.Restitution = 0.05f;
body.BodyType = BodyType.Dynamic;
//body.AngularDamping = Limb.LimbAngularDamping;
body.UserData = this;
@@ -260,6 +259,11 @@ namespace Barotrauma
body = BodyFactory.CreateRectangle(GameMain.World, width, height, density);
bodyShape = Shape.Rectangle;
}
else if (radius != 0.0f && width != 0.0f)
{
body = BodyFactory.CreateCapsuleHorizontal(GameMain.World, width, radius, density);
bodyShape = Shape.Capsule;
}
else if (radius != 0.0f && height != 0.0f)
{
body = BodyFactory.CreateCapsule(GameMain.World, height, radius, density);
@@ -436,7 +440,7 @@ namespace Barotrauma
case PhysicsBody.Shape.Capsule:
bodyShapeTexture = GUI.CreateCapsule(
(int)ConvertUnits.ToDisplayUnits(radius),
(int)ConvertUnits.ToDisplayUnits(height));
(int)ConvertUnits.ToDisplayUnits(Math.Max(height,width)));
break;
case PhysicsBody.Shape.Circle:
bodyShapeTexture = GUI.CreateCircle((int)ConvertUnits.ToDisplayUnits(radius));
@@ -444,12 +448,18 @@ namespace Barotrauma
}
}
float rot = -DrawRotation;
if (bodyShape == PhysicsBody.Shape.Capsule && width > height)
{
rot -= MathHelper.PiOver2;
}
spriteBatch.Draw(
bodyShapeTexture,
new Vector2(DrawPosition.X, -DrawPosition.Y),
null,
color,
-DrawRotation,
rot,
new Vector2(bodyShapeTexture.Width / 2, bodyShapeTexture.Height / 2),
1.0f, SpriteEffects.None, 0.0f);
}