public Unit(Tile t, DMI.SpriteFamily family, float moveHz, float animHz) : base(t, true) { Sprite = new ImageSprite(family, moveHz, animHz); Movement = new TimerPeriodic(moveHz); _tmrAIUpdate = new TimerPeriodic(s_f32AIUpdateHz); _tmrAIUpdate.Trigger += delay => { if (AI != null) AI.Update(); }; Moved += prev => Sprite.Position = Tile.PositionRender; MutatedHealth += prev => { if (Dead) IFF = null; }; // Snap the initial position to our location. Sprite.PositionSnap = t.PositionRender; }
public Projectile(Tile t, ImageSprite img, Vector2 vel, bool collide = true) : base(t) { TileInitial = t; Collide = collide; Velocity = vel; Rotation = (img.Family.Directions.Length == 1) ? 0 : (float)Math.Atan2(vel.Y, vel.X); Sprite = img; Position = t.Position; Sprite.PositionSnap = Position * Tile.TILE_SIZE; // Remove initial tile filtering once moved Moved += prev => TileInitial = null; }