Updated weapon logic. Fixed player CheckMove logic.
This commit is contained in:
@@ -19,6 +19,10 @@ public abstract class Mine : MoveableSprite
|
||||
protected float RotationSpeed { get; set; } = 1.5f;
|
||||
protected double DistanceToPlayer { get; set; } = double.MaxValue;
|
||||
|
||||
private MineState State { get; set; } = MineState.Drifting;
|
||||
private Vector2? CurrentTarget { get; set; }
|
||||
|
||||
|
||||
public Mine(int x, int y) : base(x, y)
|
||||
{
|
||||
Origin = new(30, 33);
|
||||
@@ -77,6 +81,19 @@ public abstract class Mine : MoveableSprite
|
||||
}
|
||||
|
||||
Rotation = MathHelper.WrapAngle(Rotation + RotationSpeed * context.DeltaTime);
|
||||
|
||||
switch (State)
|
||||
{
|
||||
case MineState:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void Charge(Vector2 target)
|
||||
{
|
||||
State = MineState.Charging;
|
||||
CurrentTarget = target;
|
||||
}
|
||||
|
||||
private void UpdateDistanceToPlayer(SpriteUpdateContext context)
|
||||
|
||||
7
AlientAttack.MonoGame/Things/Enemies/Mines/MineState.cs
Normal file
7
AlientAttack.MonoGame/Things/Enemies/Mines/MineState.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace AlienAttack.MonoGame.Things.Enemies.Mines;
|
||||
|
||||
public enum MineState
|
||||
{
|
||||
Drifting,
|
||||
Charging
|
||||
}
|
||||
@@ -20,7 +20,25 @@ public class GreenShipTypeA : ShipTypeA
|
||||
{
|
||||
BoundBox = new Rectangle(0, 0, 64, 64);
|
||||
YVelocity = 1;
|
||||
ActiveWeapons.Add(new Minigun());
|
||||
|
||||
WeaponDef weaponDef = new()
|
||||
{
|
||||
Name = "Weapon 1",
|
||||
Bullet = BulletDefinitions.MinigunSmall,
|
||||
Pattern = ShotPatterns.ReverseDouble,
|
||||
FireSfxKey = ""
|
||||
};
|
||||
|
||||
WeaponState weasponState = new()
|
||||
{
|
||||
FireThreshold = 20,
|
||||
SpeedMultiplier = 1f,
|
||||
DamageBonus = 0
|
||||
};
|
||||
|
||||
ConfigurableWeapon configurableWeapon = new(weaponDef, weasponState);
|
||||
|
||||
ActiveWeapons.Add(configurableWeapon);
|
||||
//ActiveWeapons.Add(new FastMinigun());
|
||||
}
|
||||
|
||||
@@ -36,21 +54,34 @@ public class GreenShipTypeA : ShipTypeA
|
||||
|
||||
protected override void TryFire(SpriteUpdateContext context)
|
||||
{
|
||||
if (CurrentFireThreshold > 0)
|
||||
//if (CurrentFireThreshold > 0)
|
||||
//{
|
||||
// CurrentFireThreshold--;
|
||||
//}
|
||||
|
||||
//if (CurrentFireThreshold == 0 && context.Random.Next(0, 100) == 1)
|
||||
//{
|
||||
// float originX = XPosition + (BoundBox.Width / 2) - (7 / 2);
|
||||
|
||||
// context.SpawnSprite(new MinigunBulletSmall(originX - 9, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
// context.SpawnSprite(new MinigunBulletSmall(originX + 14, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
|
||||
// CurrentFireThreshold = FireThreshold;
|
||||
|
||||
// context.AudioManager.PlayEnemyFire();
|
||||
//}
|
||||
|
||||
foreach (IWeapon weapon in ActiveWeapons)
|
||||
{
|
||||
CurrentFireThreshold--;
|
||||
weapon.UpdateFireThreshold();
|
||||
}
|
||||
|
||||
if (CurrentFireThreshold == 0 && context.Random.Next(0, 100) == 1)
|
||||
if (context.Random.Next(0, 100) != 1)
|
||||
return;
|
||||
|
||||
foreach (IWeapon weapon in ActiveWeapons)
|
||||
{
|
||||
float originX = XPosition + (BoundBox.Width / 2) - (7 / 2);
|
||||
|
||||
context.SpawnSprite(new MinigunBulletSmall(originX - 9, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
context.SpawnSprite(new MinigunBulletSmall(originX + 14, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
|
||||
CurrentFireThreshold = FireThreshold;
|
||||
|
||||
context.AudioManager.PlayEnemyFire();
|
||||
weapon.TryFire(this, context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using AlienAttack.MonoGame.Things.Weapons;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Enemies.Ships.TypeA;
|
||||
|
||||
@@ -9,11 +11,31 @@ public class RedShipTypeA : ShipTypeA
|
||||
protected int FireThreshold => 20;
|
||||
protected int CurrentFireThreshold { get; set; } = 20;
|
||||
protected override int Health { get; set; } = 5;
|
||||
protected ICollection<IWeapon> ActiveWeapons = [];
|
||||
|
||||
public RedShipTypeA(int x, int y) : base(x, y)
|
||||
{
|
||||
BoundBox = new Rectangle(0, 0, 64, 64);
|
||||
YVelocity = 1.5f;
|
||||
|
||||
WeaponDef weaponDef = new()
|
||||
{
|
||||
Name = "Weapon 1",
|
||||
Bullet = BulletDefinitions.MinigunSmall,
|
||||
Pattern = ShotPatterns.ReverseTripleSpread,
|
||||
FireSfxKey = ""
|
||||
};
|
||||
|
||||
WeaponState weasponState = new()
|
||||
{
|
||||
FireThreshold = 20,
|
||||
SpeedMultiplier = 1f,
|
||||
DamageBonus = 0
|
||||
};
|
||||
|
||||
ConfigurableWeapon configurableWeapon = new(weaponDef, weasponState);
|
||||
|
||||
ActiveWeapons.Add(configurableWeapon);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteDrawArgs args)
|
||||
@@ -53,22 +75,35 @@ public class RedShipTypeA : ShipTypeA
|
||||
|
||||
protected override void TryFire(SpriteUpdateContext context)
|
||||
{
|
||||
if (CurrentFireThreshold > 0)
|
||||
//if (CurrentFireThreshold > 0)
|
||||
//{
|
||||
// CurrentFireThreshold--;
|
||||
//}
|
||||
|
||||
//if (CurrentFireThreshold == 0 && context.Random.Next(0, 50) == 1)
|
||||
//{
|
||||
// float originX = XPosition + (BoundBox.Width / 2) - (7 / 2);
|
||||
|
||||
// context.SpawnSprite(new MinigunBulletSmall(originX - 9, YPosition + BoundBox.Height - 12, -1, 2 + YVelocity, this));
|
||||
// context.SpawnSprite(new MinigunBulletSmall(originX + 3, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
// context.SpawnSprite(new MinigunBulletSmall(originX + 14, YPosition + BoundBox.Height - 12, 1, 2 + YVelocity, this));
|
||||
|
||||
// CurrentFireThreshold = FireThreshold;
|
||||
|
||||
// context.AudioManager.PlayEnemyFire();
|
||||
//}
|
||||
|
||||
foreach (IWeapon weapon in ActiveWeapons)
|
||||
{
|
||||
CurrentFireThreshold--;
|
||||
weapon.UpdateFireThreshold();
|
||||
}
|
||||
|
||||
if (CurrentFireThreshold == 0 && context.Random.Next(0, 50) == 1)
|
||||
if (context.Random.Next(0, 50) != 1)
|
||||
return;
|
||||
|
||||
foreach (IWeapon weapon in ActiveWeapons)
|
||||
{
|
||||
float originX = XPosition + (BoundBox.Width / 2) - (7 / 2);
|
||||
|
||||
context.SpawnSprite(new MinigunBulletSmall(originX - 9, YPosition + BoundBox.Height - 12, -1, 2 + YVelocity, this));
|
||||
context.SpawnSprite(new MinigunBulletSmall(originX + 3, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
context.SpawnSprite(new MinigunBulletSmall(originX + 14, YPosition + BoundBox.Height - 12, 1, 2 + YVelocity, this));
|
||||
|
||||
CurrentFireThreshold = FireThreshold;
|
||||
|
||||
context.AudioManager.PlayEnemyFire();
|
||||
weapon.TryFire(this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using AlienAttack.MonoGame.Things.Weapons;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Enemies.Ships.TypeA;
|
||||
|
||||
@@ -9,12 +11,32 @@ public class TealShipTypeA : ShipTypeA
|
||||
protected int FireThreshold => 20;
|
||||
protected int CurrentFireThreshold { get; set; } = 20;
|
||||
protected override int Health { get; set; } = 5;
|
||||
protected ICollection<IWeapon> ActiveWeapons = [];
|
||||
|
||||
public TealShipTypeA(int x, int y) : base(x, y)
|
||||
{
|
||||
BoundBox = new Rectangle(0, 0, 64, 64);
|
||||
YVelocity = 1;
|
||||
XVelocity = 3;
|
||||
|
||||
WeaponDef weaponDef = new()
|
||||
{
|
||||
Name = "Weapon 1",
|
||||
Bullet = BulletDefinitions.ProtonLarge,
|
||||
Pattern = ShotPatterns.ReverseTripleSpread,
|
||||
FireSfxKey = ""
|
||||
};
|
||||
|
||||
WeaponState weasponState = new()
|
||||
{
|
||||
FireThreshold = 20,
|
||||
SpeedMultiplier = 1f,
|
||||
DamageBonus = 0
|
||||
};
|
||||
|
||||
ConfigurableWeapon configurableWeapon = new(weaponDef, weasponState);
|
||||
|
||||
ActiveWeapons.Add(configurableWeapon);
|
||||
}
|
||||
|
||||
public override void Draw(SpriteDrawArgs args)
|
||||
@@ -45,25 +67,38 @@ public class TealShipTypeA : ShipTypeA
|
||||
|
||||
protected override void TryFire(SpriteUpdateContext context)
|
||||
{
|
||||
if (CurrentFireThreshold > 0)
|
||||
//if (CurrentFireThreshold > 0)
|
||||
//{
|
||||
// CurrentFireThreshold--;
|
||||
//}
|
||||
|
||||
//if (CurrentFireThreshold == 0 && context.Random.Next(0, 50) == 1)
|
||||
//{
|
||||
// float originX = XPosition + (BoundBox.Width / 2) - (7 / 2);
|
||||
|
||||
// //context.SpawnSprite(new MinigunBulletSmall(originX - 9, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
// //context.SpawnSprite(new MinigunBulletSmall(originX + 14, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
|
||||
// context.SpawnSprite(new MinigunBulletSmall(originX - 9, YPosition + BoundBox.Height - 12, -1, 2 + YVelocity, this));
|
||||
// context.SpawnSprite(new MinigunBulletSmall(originX + 3, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
// context.SpawnSprite(new MinigunBulletSmall(originX + 14, YPosition + BoundBox.Height - 12, 1, 2 + YVelocity, this));
|
||||
|
||||
// CurrentFireThreshold = FireThreshold;
|
||||
|
||||
// context.AudioManager.PlayEnemyFire();
|
||||
//}
|
||||
|
||||
foreach (IWeapon weapon in ActiveWeapons)
|
||||
{
|
||||
CurrentFireThreshold--;
|
||||
weapon.UpdateFireThreshold();
|
||||
}
|
||||
|
||||
if (CurrentFireThreshold == 0 && context.Random.Next(0, 50) == 1)
|
||||
if (context.Random.Next(0, 50) != 1)
|
||||
return;
|
||||
|
||||
foreach (IWeapon weapon in ActiveWeapons)
|
||||
{
|
||||
float originX = XPosition + (BoundBox.Width / 2) - (7 / 2);
|
||||
|
||||
//context.SpawnSprite(new MinigunBulletSmall(originX - 9, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
//context.SpawnSprite(new MinigunBulletSmall(originX + 14, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
|
||||
context.SpawnSprite(new MinigunBulletSmall(originX - 9, YPosition + BoundBox.Height - 12, -1, 2 + YVelocity, this));
|
||||
context.SpawnSprite(new MinigunBulletSmall(originX + 3, YPosition + BoundBox.Height - 12, 0, 2 + YVelocity, this));
|
||||
context.SpawnSprite(new MinigunBulletSmall(originX + 14, YPosition + BoundBox.Height - 12, 1, 2 + YVelocity, this));
|
||||
|
||||
CurrentFireThreshold = FireThreshold;
|
||||
|
||||
context.AudioManager.PlayEnemyFire();
|
||||
weapon.TryFire(this, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user