2021-03-09 23:21:52 +01:00
|
|
|
using System;
|
|
|
|
using Microsoft.Xna.Framework;
|
2021-03-18 20:09:38 +01:00
|
|
|
using Microsoft.Xna.Framework.Audio;
|
2021-03-09 23:21:52 +01:00
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
using MLEM.Misc;
|
2021-03-18 20:09:38 +01:00
|
|
|
using MLEM.Startup;
|
2021-03-09 23:21:52 +01:00
|
|
|
using MLEM.Textures;
|
|
|
|
|
|
|
|
namespace GreatSpringGameJam {
|
|
|
|
public class Gnome : Entity {
|
|
|
|
|
|
|
|
public Gnome(Map map, Vector2 position) : base(map, position) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void Update(GameTime time) {
|
2021-03-18 20:09:38 +01:00
|
|
|
if (GameImpl.Instance.Player.Bounds.Intersects(new RectangleF(this.Position, Vector2.One))) {
|
|
|
|
MlemGame.LoadContent<SoundEffect>("Sounds/GnomeCollect").Play();
|
2021-03-09 23:21:52 +01:00
|
|
|
this.Map.RemoveEntity(this);
|
2021-03-18 20:09:38 +01:00
|
|
|
}
|
2021-03-09 23:21:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void Draw(GameTime time, SpriteBatch batch) {
|
|
|
|
base.Draw(time, batch);
|
|
|
|
var tex = StuffTexture[1, 1];
|
|
|
|
var offset = new Vector2(0, MathF.Sin((float) time.TotalGameTime.TotalSeconds * 2) * 0.15F);
|
|
|
|
var rotation = MathF.Sin((float) time.TotalGameTime.TotalSeconds * 1.5F) * 0.25F;
|
|
|
|
batch.Draw(tex, this.Position * this.Map.TileSize + tex.Size.ToVector2() / 2 + offset * this.Map.TileSize, Color.White, rotation, tex.Size.ToVector2() / 2, 1, SpriteEffects.None, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|