89 lines
No EOL
2.6 KiB
C#
89 lines
No EOL
2.6 KiB
C#
using System;
|
|
using Inky.Skeletron;
|
|
using Microsoft.Xna.Framework;
|
|
using Nez;
|
|
using Edge = Inky.Skeletron.Edge;
|
|
using Random = Nez.Random;
|
|
|
|
namespace Inky
|
|
{
|
|
public class Lanky2 : RenderableComponent
|
|
{
|
|
public override float Height => 100;
|
|
public override float Width => 100;
|
|
|
|
public readonly int LegLength;
|
|
public readonly int ArmLength;
|
|
public readonly int BodyWidth;
|
|
public readonly int BodyHeight;
|
|
public readonly int HeadWidth;
|
|
public readonly int HeadHeight;
|
|
|
|
public Alignment LegAlignment;
|
|
public Alignment ArmAlignment;
|
|
|
|
private float _headShift;
|
|
public float HeadShift
|
|
{
|
|
get => _headShift;
|
|
set => _headShift = Math.Clamp(value, -1, 1);
|
|
}
|
|
|
|
private float _eyeShift;
|
|
public float EyeShift
|
|
{
|
|
get => _eyeShift;
|
|
set => _eyeShift = Math.Clamp(value, -1, 1);
|
|
}
|
|
|
|
private float _mouthShift;
|
|
public float MouthShift
|
|
{
|
|
get => _mouthShift;
|
|
set => _mouthShift = Math.Clamp(value, -1, 1);
|
|
}
|
|
|
|
private float _mouthWidth;
|
|
public float MouthWidth
|
|
{
|
|
get => _mouthWidth;
|
|
set => _mouthWidth = Math.Clamp(value, 0, 1);
|
|
}
|
|
|
|
private float _legWobble;
|
|
|
|
public float LegWobble
|
|
{
|
|
get => _legWobble;
|
|
set => _legWobble = Math.Clamp(value, -1, 1);
|
|
}
|
|
|
|
public Skeletron.Rectangle _body;
|
|
|
|
public Lanky2()
|
|
{
|
|
BodyHeight = (int) ((Random.NextFloat(0.5f) + 0.5f) * 100);
|
|
_body = new Skeletron.Rectangle(100, BodyHeight);
|
|
var _head = new Skeletron.Rectangle(40, 40);
|
|
_body.Attach(Edge.Top, _head);
|
|
|
|
// readonly
|
|
LegLength = (int)((Random.NextFloat(0.6f) + 0.6f) * BodyHeight);
|
|
_body.Attach(Edge.Bottom, new Line(LegLength, true), 0.4f);
|
|
_body.Attach(Edge.Bottom, new Line(LegLength, true), -0.4f);
|
|
|
|
ArmLength = (int)((Random.NextFloat(0.3f) + 0.3f) * BodyHeight);
|
|
_body.Attach(Edge.Left, new Line(ArmLength, true), 0.4f);
|
|
_body.Attach(Edge.Right, new Line(ArmLength, true), -0.4f);
|
|
|
|
LegAlignment = Alignment.Center;
|
|
ArmAlignment = Alignment.Center;
|
|
MouthWidth = 0.5f;
|
|
}
|
|
|
|
public override void Render(Batcher batcher, Camera camera)
|
|
{
|
|
_body.Draw(batcher, Entity.Position.X, Entity.Position.Y, Color.Black);
|
|
}
|
|
}
|
|
} |