2020-07-12 04:19:50 +00:00
|
|
|
using SkinnerBox.Utilities;
|
2020-07-11 19:02:52 +00:00
|
|
|
using SlatedGameToolkit.Framework.Graphics.Textures;
|
|
|
|
using SlatedGameToolkit.Framework.Utilities.Collections.Pooling;
|
|
|
|
using System;
|
|
|
|
using System.Drawing;
|
|
|
|
|
|
|
|
namespace SkinnerBox.Entities
|
|
|
|
{
|
|
|
|
public class WarningEntity : Entity, IPoolable
|
|
|
|
{
|
|
|
|
public float LifeTime { get; set; }
|
|
|
|
public TransitionValue aliveTime;
|
|
|
|
|
|
|
|
public WarningEntity(ITexture texture) : base(texture) {
|
2020-07-11 23:43:47 +00:00
|
|
|
this.Width = 1f;
|
|
|
|
this.Height = 1f;
|
2020-07-11 19:02:52 +00:00
|
|
|
Reset();
|
|
|
|
}
|
|
|
|
public void Reset()
|
|
|
|
{
|
|
|
|
LifeTime = 0;
|
|
|
|
X = 0 - Width;
|
|
|
|
mesh.X = X;
|
2020-07-11 23:43:47 +00:00
|
|
|
Y = - Height;
|
2020-07-11 19:02:52 +00:00
|
|
|
mesh.Y = Y;
|
|
|
|
aliveTime.HardSet(0);
|
|
|
|
this.Color = Color.Red;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void InterpolatePosition(float delta) {
|
|
|
|
aliveTime.InterpolatePosition(delta);
|
|
|
|
float prog = (aliveTime.Value / LifeTime);
|
|
|
|
if (prog > 1) prog = 1;
|
|
|
|
this.Color = Color.FromArgb((int)(byte.MaxValue * (1f - prog)), this.Color);
|
|
|
|
base.InterpolatePosition(delta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|