2020-07-11 19:02:52 +00:00
|
|
|
using System.Drawing;
|
|
|
|
using SlatedGameToolkit.Framework.Graphics.Render;
|
|
|
|
using SlatedGameToolkit.Framework.Graphics.Textures;
|
|
|
|
using SlatedGameToolkit.Framework.Graphics.Window;
|
|
|
|
|
2020-07-12 18:26:32 +00:00
|
|
|
namespace WebsiteSim.Entities
|
2020-07-11 19:02:52 +00:00
|
|
|
{
|
|
|
|
public class ServerEntity : Entity
|
|
|
|
{
|
2020-07-11 23:43:47 +00:00
|
|
|
public const float MIN_SPEED = 1f;
|
|
|
|
public const float SPEED_STEP = 1f;
|
2020-07-11 19:02:52 +00:00
|
|
|
private readonly float length = 4/8f;
|
|
|
|
public float Speed { get; set; }
|
|
|
|
public override float CenterX {
|
|
|
|
get {
|
|
|
|
return base.X + (length * size) / 2f;
|
|
|
|
}
|
|
|
|
|
|
|
|
set {
|
|
|
|
base.X = value - (length * size) / 2f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private int size;
|
|
|
|
public int Size {
|
|
|
|
get {
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
set {
|
|
|
|
if (this.size != value) {
|
|
|
|
this.size = value;
|
|
|
|
this.mesh.TextureBounds = new RectangleF(0, 0, size, 1);
|
|
|
|
this.Width = value * length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public override RectangleF HitBox {
|
|
|
|
get {
|
|
|
|
RectangleF hitbox = base.HitBox;
|
2020-07-11 23:43:47 +00:00
|
|
|
hitbox.Width = Width;
|
2020-07-11 19:02:52 +00:00
|
|
|
return hitbox;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public ServerEntity(Texture texture, float initialX, float Y) : base(texture)
|
|
|
|
{
|
|
|
|
this.X = (Game.WIDTH_UNITS - this.Width) / 2f;
|
|
|
|
this.Height = length;
|
|
|
|
|
|
|
|
Size = 1;
|
|
|
|
|
2020-07-11 23:43:47 +00:00
|
|
|
this.Speed = MIN_SPEED;
|
2020-07-11 19:02:52 +00:00
|
|
|
|
|
|
|
CenterX = initialX;
|
|
|
|
mesh.X = X;
|
|
|
|
this.Y = Y;
|
|
|
|
mesh.Y = this.Y;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-07-11 22:09:33 +00:00
|
|
|
|
2020-07-11 19:02:52 +00:00
|
|
|
}
|