|
@ -47,10 +47,7 @@ namespace SemiColinGames { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public class NPC { |
|
|
public class NPC { |
|
|
// TODO: load sprite sizes from metadata.
|
|
|
|
|
|
private const int spriteWidth = 96; |
|
|
|
|
|
private const int spriteHeight = 82; |
|
|
|
|
|
private const int groundPadding = 7; |
|
|
|
|
|
|
|
|
private readonly Sprite sprite; |
|
|
private readonly Vector2 spriteCenter; |
|
|
private readonly Vector2 spriteCenter; |
|
|
private readonly Vector2 eyeOffset = new Vector2(4, -9); |
|
|
private readonly Vector2 eyeOffset = new Vector2(4, -9); |
|
|
|
|
|
|
|
@ -59,8 +56,10 @@ namespace SemiColinGames { |
|
|
private readonly Vector2 halfSize = new Vector2(12, 24); |
|
|
private readonly Vector2 halfSize = new Vector2(12, 24); |
|
|
|
|
|
|
|
|
public NPC(Point position, int facing) { |
|
|
public NPC(Point position, int facing) { |
|
|
|
|
|
sprite = Sprites.Executioner; |
|
|
Position = position; |
|
|
Position = position; |
|
|
spriteCenter = new Vector2(spriteWidth / 2, spriteHeight - halfSize.Y - groundPadding); |
|
|
|
|
|
|
|
|
spriteCenter = new Vector2( |
|
|
|
|
|
sprite.Width / 2, sprite.Height - halfSize.Y - sprite.GroundPadding); |
|
|
physicsBox = new AABB(position.ToVector2(), halfSize); |
|
|
physicsBox = new AABB(position.ToVector2(), halfSize); |
|
|
Facing = facing; |
|
|
Facing = facing; |
|
|
fsm = new FSM<NPC>(new Dictionary<string, IState<NPC>> { |
|
|
fsm = new FSM<NPC>(new Dictionary<string, IState<NPC>> { |
|
@ -104,8 +103,8 @@ namespace SemiColinGames { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void Draw(SpriteBatch spriteBatch) { |
|
|
public void Draw(SpriteBatch spriteBatch) { |
|
|
Rectangle textureSource = Sprites.Executioner.GetTextureSource( |
|
|
|
|
|
fsm.StateName, Clock.ModelTime.TotalSeconds); |
|
|
|
|
|
|
|
|
Rectangle textureSource = |
|
|
|
|
|
sprite.GetTextureSource(fsm.StateName, Clock.ModelTime.TotalSeconds); |
|
|
SpriteEffects effect = Facing == 1 ? |
|
|
SpriteEffects effect = Facing == 1 ? |
|
|
SpriteEffects.None : SpriteEffects.FlipHorizontally; |
|
|
SpriteEffects.None : SpriteEffects.FlipHorizontally; |
|
|
Color color = Color.White; |
|
|
Color color = Color.White; |
|
|