Added configurable weapons.
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
using AlienAttack.MonoGame.Things.Items;
|
||||
using AlienAttack.MonoGame.Things.Muzzles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class Bullet(float x, float y, float xVel, float yVel, Sprite owner) : Sprite(x, y)
|
||||
public class Bullet(float x, float y, float xVel, float yVel, Sprite owner) : Sprite(x, y)
|
||||
{
|
||||
protected float XVelocity = xVel;
|
||||
protected float YVelocity = yVel;
|
||||
@@ -32,7 +35,9 @@ internal class Bullet(float x, float y, float xVel, float yVel, Sprite owner) :
|
||||
|
||||
public override void OnCollision(SpriteCollisionContext context)
|
||||
{
|
||||
if (context.Sprite is Bullet || context.Sprite == Owner || context.Sprite is Item)
|
||||
Sprite sprite = context.Sprite;
|
||||
|
||||
if (sprite is Bullet || sprite == Owner || sprite is Item || sprite is Explosion)
|
||||
return;
|
||||
|
||||
IsDead = true;
|
||||
|
||||
11
AlientAttack.MonoGame/Things/Bullets/BulletDef.cs
Normal file
11
AlientAttack.MonoGame/Things/Bullets/BulletDef.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
public sealed class BulletDef
|
||||
{
|
||||
public required BulletKind Kind { get; init; }
|
||||
public required int Width { get; init; }
|
||||
public required int Height { get; init; }
|
||||
public required Func<float, float, float, float, Sprite, Bullet> Create { get; init; }
|
||||
}
|
||||
100
AlientAttack.MonoGame/Things/Bullets/BulletDefinitions.cs
Normal file
100
AlientAttack.MonoGame/Things/Bullets/BulletDefinitions.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
public static class BulletDefinitions
|
||||
{
|
||||
public static readonly BulletDef LaserSmall = new()
|
||||
{
|
||||
Kind = BulletKind.LaserSmall,
|
||||
Width = LaserBulletSmall.Width,
|
||||
Height = LaserBulletSmall.Height,
|
||||
Create = (x, y, vx, vy, o) => new LaserBulletSmall(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef LaserMedium = new()
|
||||
{
|
||||
Kind = BulletKind.LaserMedium,
|
||||
Width = LaserBulletMedium.Width,
|
||||
Height = LaserBulletMedium.Height,
|
||||
Create = (x, y, vx, vy, o) => new LaserBulletMedium(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef LaserLarge = new()
|
||||
{
|
||||
Kind = BulletKind.LaserLarge,
|
||||
Width = LaserBulletLarge.Width,
|
||||
Height = LaserBulletLarge.Height,
|
||||
Create = (x, y, vx, vy, o) => new LaserBulletLarge(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef MinigunSmall = new()
|
||||
{
|
||||
Kind = BulletKind.MinigunSmall,
|
||||
Width = MinigunBulletSmall.Width,
|
||||
Height = MinigunBulletSmall.Height,
|
||||
Create = (x, y, vx, vy, o) => new MinigunBulletSmall(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef MinigunMedium = new()
|
||||
{
|
||||
Kind = BulletKind.MinigunMedium,
|
||||
Width = MinigunBulletMedium.Width,
|
||||
Height = MinigunBulletMedium.Height,
|
||||
Create = (x, y, vx, vy, o) => new MinigunBulletMedium(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef MinigunLarge = new()
|
||||
{
|
||||
Kind = BulletKind.MinigunLarge,
|
||||
Width = MinigunBulletLarge.Width,
|
||||
Height = MinigunBulletLarge.Height,
|
||||
Create = (x, y, vx, vy, o) => new MinigunBulletLarge(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef PlasmaSmall = new()
|
||||
{
|
||||
Kind = BulletKind.PlasmaSmall,
|
||||
Width = PlasmaBulletSmall.Width,
|
||||
Height = PlasmaBulletSmall.Height,
|
||||
Create = (x, y, vx, vy, o) => new PlasmaBulletSmall(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef PlasmaMedium = new()
|
||||
{
|
||||
Kind = BulletKind.PlasmaMedium,
|
||||
Width = PlasmaBulletMedium.Width,
|
||||
Height = PlasmaBulletMedium.Height,
|
||||
Create = (x, y, vx, vy, o) => new PlasmaBulletMedium(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef PlasmaLarge = new()
|
||||
{
|
||||
Kind = BulletKind.PlasmaLarge,
|
||||
Width = PlasmaBulletLarge.Width,
|
||||
Height = PlasmaBulletLarge.Height,
|
||||
Create = (x, y, vx, vy, o) => new PlasmaBulletLarge(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef ProtonSmall = new()
|
||||
{
|
||||
Kind = BulletKind.ProtonSmall,
|
||||
Width = ProtonBulletSmall.Width,
|
||||
Height = ProtonBulletSmall.Height,
|
||||
Create = (x, y, vx, vy, o) => new ProtonBulletSmall(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef ProtonMedium = new()
|
||||
{
|
||||
Kind = BulletKind.ProtonMedium,
|
||||
Width = ProtonBulletMedium.Width,
|
||||
Height = ProtonBulletMedium.Height,
|
||||
Create = (x, y, vx, vy, o) => new ProtonBulletMedium(x, y, vx, vy, o),
|
||||
};
|
||||
|
||||
public static readonly BulletDef ProtonLarge = new()
|
||||
{
|
||||
Kind = BulletKind.ProtonLarge,
|
||||
Width = ProtonBulletLarge.Width,
|
||||
Height = ProtonBulletLarge.Height,
|
||||
Create = (x, y, vx, vy, o) => new ProtonBulletLarge(x, y, vx, vy, o),
|
||||
};
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class LaserBulletLarge : Bullet
|
||||
public class LaserBulletLarge : Bullet
|
||||
{
|
||||
public const int Width = 8;
|
||||
public const int Height = 28;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class LaserBulletMedium : Bullet
|
||||
public class LaserBulletMedium : Bullet
|
||||
{
|
||||
public const int Width = 7;
|
||||
public const int Height = 21;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class LaserBulletSmall : Bullet
|
||||
public class LaserBulletSmall : Bullet
|
||||
{
|
||||
public const int Width = 6;
|
||||
public const int Height = 18;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class MinigunBulletLarge : Bullet
|
||||
public class MinigunBulletLarge : Bullet
|
||||
{
|
||||
public const int Width = 9;
|
||||
public const int Height = 27;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class MinigunBulletMedium : Bullet
|
||||
public class MinigunBulletMedium : Bullet
|
||||
{
|
||||
public const int Width = 11;
|
||||
public const int Height = 21;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class MinigunBulletSmall : Bullet
|
||||
public class MinigunBulletSmall : Bullet
|
||||
{
|
||||
public const int Width = 11;
|
||||
public const int Height = 21;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class PlasmaBulletLarge : Bullet
|
||||
public class PlasmaBulletLarge : Bullet
|
||||
{
|
||||
public const int Width = 9;
|
||||
public const int Height = 31;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class PlasmaBulletMedium : Bullet
|
||||
public class PlasmaBulletMedium : Bullet
|
||||
{
|
||||
public const int Width = 8;
|
||||
public const int Height = 26;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class PlasmaBulletSmall : Bullet
|
||||
public class PlasmaBulletSmall : Bullet
|
||||
{
|
||||
public const int Width = 7;
|
||||
public const int Height = 24;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class ProtonBulletLarge : Bullet
|
||||
public class ProtonBulletLarge : Bullet
|
||||
{
|
||||
public const int Width = 13;
|
||||
public const int Height = 13;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class ProtonBulletMedium : Bullet
|
||||
public class ProtonBulletMedium : Bullet
|
||||
{
|
||||
public const int Width = 10;
|
||||
public const int Height = 10;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Bullets;
|
||||
|
||||
internal class ProtonBulletSmall : Bullet
|
||||
public class ProtonBulletSmall : Bullet
|
||||
{
|
||||
public const int Width = 6;
|
||||
public const int Height = 6;
|
||||
|
||||
Reference in New Issue
Block a user