Add project files.

This commit is contained in:
2025-12-16 08:51:34 -05:00
parent ed4d50a5bd
commit f7e3fe0a47
140 changed files with 2946 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
using AlienAttack.MonoGame.Things.Bullets;
using AlienAttack.MonoGame.Things.Weapons;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace AlienAttack.MonoGame.Things.Enemies;
internal class RedEnemy : MoveableSprite
{
//Enemy01_Green_Frame_1_png_processed
protected int Health { get; set; } = 10;
public RedEnemy(int x, int y) : base(x, y)
{
BoundBox = new Rectangle(0, 0, 64, 64);
YVelocity = 2;
//ActiveWeapons.Add(new Minigun());
//ActiveWeapons.Add(new FastMinigun());
}
public override void Draw(SpriteDrawArgs args)
{
Texture2D texture = args.Content.Load<Texture2D>(@$"Sprites\Enemy01_Red_Frame_1_png_processed");
SpriteEffects spriteEffects = SpriteEffects.None;
args.SpriteBatch.Draw(texture, Position, null, DrawColor, 0, new Vector2(0, 0), 1, spriteEffects, 1);
base.Draw(args);
}
public override void Update(SpriteUpdateContext context)
{
//YPosition += 2;
if (Health <= 0)
{
IsDead = true;
context.SpawnSprite(new Explosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
return;
}
if (YPosition > context.ViewTransform.ScreenHeight)
{
IsDead = true;
return;
}
//CheckMove(context);
CheckFire(context);
base.Update(context);
}
private void CheckFire(SpriteUpdateContext context)
{
//foreach (IWeapon weapon in ActiveWeapons)
//{
// weapon.UpdateFireThreshold();
//}
//foreach (IWeapon weapon in ActiveWeapons)
//{
// weapon.TryFire(this, context);
//}
}
public override void OnCollision(SpriteCollisionContext context)
{
if (context.Sprite is Bullet bullet && bullet.Owner is Player)
{
Health -= bullet.Damage;
}
}
}