Take and replenish health and ammo

This commit is contained in:
2021-04-19 23:37:40 +02:00
parent 671ed50a33
commit d69c05db1f
7 changed files with 48 additions and 5 deletions
Binary file not shown.
+2
View File
@@ -56,6 +56,8 @@ namespace EvilSatellites.Objects
var player = (Player)obj; var player = (Player)obj;
if (player.Vacuuming) if (player.Vacuuming)
{ {
player.CurrentWeapon.RemainingAmmo += rnd.Next(player.CurrentWeapon.MaxAmmo);
Destroy();
return; return;
} }
player.TakeDamage(25); player.TakeDamage(25);
+14
View File
@@ -103,6 +103,10 @@ namespace EvilSatellites.Objects
sfxTurn.Update(gameTime); sfxTurn.Update(gameTime);
sfxElevator.Update(gameTime); sfxElevator.Update(gameTime);
sfxVacuum.Update(gameTime); sfxVacuum.Update(gameTime);
if (Health < 100)
{
IncreaseHealth(0.01f);
}
if (Movement.Length() != 0) if (Movement.Length() != 0)
{ {
if (Movement.X > 0) if (Movement.X > 0)
@@ -201,6 +205,16 @@ namespace EvilSatellites.Objects
Screen.Manager.Sound.PlayOneshot(dmgSound); Screen.Manager.Sound.PlayOneshot(dmgSound);
} }
public void IncreaseHealth(float amount)
{
Health += amount;
if (Health > 25 && IsDamaged)
{
IsDamaged = false;
sfxDamage.Pause();
}
}
public void PlayTap() public void PlayTap()
{ {
sfxTaps.Play(); sfxTaps.Play();
+10 -1
View File
@@ -179,7 +179,16 @@ namespace EvilSatellites.Screens
Tolk.Output("Satellites"); Tolk.Output("Satellites");
} }
} }
if (Input.IsJustPressed(Keys.H))
{
_player.PlayTap();
Tolk.Output(_player.Health.ToString() + " health", true);
}
if (Input.IsJustPressed(Keys.X))
{
_player.PlayTap();
Tolk.Output(_player.CurrentWeapon.RemainingAmmo.ToString() + " rounds", true);
}
if (Input.IsJustPressed(Keys.O)) if (Input.IsJustPressed(Keys.O))
{ {
DavyKager.Tolk.Output(Objects.Count.ToString()); DavyKager.Tolk.Output(Objects.Count.ToString());
+12
View File
@@ -17,6 +17,7 @@ namespace EvilSatellites.Weapons
public ISoundEffect sfxSpindown; public ISoundEffect sfxSpindown;
public ISoundEffect sfxSpinup; public ISoundEffect sfxSpinup;
public ISoundEffect sfxSpinning; public ISoundEffect sfxSpinning;
public ISoundEffect sfxEmpty;
public GameScreen Screen; public GameScreen Screen;
public LaserMG(IGameObject wielder, GameScreen screen) public LaserMG(IGameObject wielder, GameScreen screen)
{ {
@@ -37,6 +38,8 @@ namespace EvilSatellites.Weapons
sfxSpinning = Screen.Manager.Sound.Load(@"sfx/weapons/LaserMG/spinning.wav", false); sfxSpinning = Screen.Manager.Sound.Load(@"sfx/weapons/LaserMG/spinning.wav", false);
sfxSpinning.Loop = true; sfxSpinning.Loop = true;
sfxShoot = new AudioAsset(Screen.Manager.Sound, @"sfx/weapons/LaserMG/fire", 1, 4); sfxShoot = new AudioAsset(Screen.Manager.Sound, @"sfx/weapons/LaserMG/fire", 1, 4);
sfxEmpty = Screen.Manager.Sound.Load(@"sfx/weapons/LaserMG/empty.wav", false);
sfxEmpty.ConnectToEffect(Screen.Manager.EnvironmentEffect);
sfxReload.ConnectToEffect(Screen.Manager.EnvironmentEffect); sfxReload.ConnectToEffect(Screen.Manager.EnvironmentEffect);
sfxShoot.AddEffect(Screen.Manager.EnvironmentEffect); sfxShoot.AddEffect(Screen.Manager.EnvironmentEffect);
sfxSpindown.ConnectToEffect(Screen.Manager.EnvironmentEffect); sfxSpindown.ConnectToEffect(Screen.Manager.EnvironmentEffect);
@@ -83,11 +86,20 @@ namespace EvilSatellites.Weapons
if (State == WeaponState.Firing) if (State == WeaponState.Firing)
{ {
if (TimerEnd - TimerStart > FireRate) if (TimerEnd - TimerStart > FireRate)
{
if (RemainingAmmo > 0)
{ {
sfxShoot.Play(); sfxShoot.Play();
RemainingAmmo--;
TimerStart = TimerEnd; TimerStart = TimerEnd;
Projectile proj = new Projectile(Screen, _wielder.Position, _wielder.Rotation, _wielder); Projectile proj = new Projectile(Screen, _wielder.Position, _wielder.Rotation, _wielder);
Screen.AddObject(proj); Screen.AddObject(proj);
} else
{
sfxEmpty.Reset();
sfxEmpty.Play();
TimerStart = TimerEnd;
}
} }
} }
if (State == WeaponState.Stopping) if (State == WeaponState.Stopping)
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8f8abd1efdf4645a55976cea45a1537b59bf312d27729442e2b1c52106777de4
size 103016
+3
View File
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8f8abd1efdf4645a55976cea45a1537b59bf312d27729442e2b1c52106777de4
size 103016