Added sound effects and music.
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
using AlienAttack.MonoGame.Things.Items;
|
||||
using AlienAttack.MonoGame.Things.Weapons;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Enemies;
|
||||
|
||||
@@ -43,7 +45,7 @@ internal class GreenEnemy : EnemyShip
|
||||
if (Health <= 0)
|
||||
{
|
||||
IsDead = true;
|
||||
context.SpawnSprite(new Explosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
|
||||
SpawnExplosion(context);
|
||||
|
||||
switch (context.Random.Next(0, 5))
|
||||
{
|
||||
@@ -94,6 +96,16 @@ internal class GreenEnemy : EnemyShip
|
||||
base.Update(context);
|
||||
}
|
||||
|
||||
private void SpawnExplosion(SpriteUpdateContext context)
|
||||
{
|
||||
context.SpawnSprite(new Explosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
|
||||
|
||||
int number = context.Random.Next(1, 7);
|
||||
|
||||
SoundEffect soundEffect = context.Content.Load<SoundEffect>(@$"Sfx\Explosions\EXPLDsgn_Explosion Impact_0{number}_SFRMS_SCIWPNS");
|
||||
soundEffect.Play(0.95f, (float)(context.Random.NextDouble() * 0.1 - 0.05), 0);
|
||||
}
|
||||
|
||||
private void CheckFire(SpriteUpdateContext context)
|
||||
{
|
||||
//foreach (IWeapon weapon in ActiveWeapons)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Enemies;
|
||||
@@ -53,7 +54,7 @@ internal class RedEnemy : EnemyShip
|
||||
if (Health <= 0)
|
||||
{
|
||||
IsDead = true;
|
||||
context.SpawnSprite(new Explosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
|
||||
SpawnExplosion(context);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,6 +69,16 @@ internal class RedEnemy : EnemyShip
|
||||
base.Update(context);
|
||||
}
|
||||
|
||||
private void SpawnExplosion(SpriteUpdateContext context)
|
||||
{
|
||||
context.SpawnSprite(new Explosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
|
||||
|
||||
int number = context.Random.Next(1, 7);
|
||||
|
||||
SoundEffect soundEffect = context.Content.Load<SoundEffect>(@$"Sfx\Explosions\EXPLDsgn_Explosion Impact_0{number}_SFRMS_SCIWPNS");
|
||||
soundEffect.Play(0.95f, (float)(context.Random.NextDouble() * 0.1 - 0.05), 0);
|
||||
}
|
||||
|
||||
private void TryFire(SpriteUpdateContext context)
|
||||
{
|
||||
if (CurrentFireThreshold > 0)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using AlienAttack.MonoGame.Things.Bullets;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace AlienAttack.MonoGame.Things.Enemies;
|
||||
@@ -45,7 +46,7 @@ internal class TealEnemy : EnemyShip
|
||||
if (Health <= 0)
|
||||
{
|
||||
IsDead = true;
|
||||
context.SpawnSprite(new Explosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
|
||||
SpawnExplosion(context);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,6 +62,16 @@ internal class TealEnemy : EnemyShip
|
||||
base.Update(context);
|
||||
}
|
||||
|
||||
private void SpawnExplosion(SpriteUpdateContext context)
|
||||
{
|
||||
context.SpawnSprite(new Explosion((int)XPosition, (int)YPosition, XVelocity, YVelocity));
|
||||
|
||||
int number = context.Random.Next(1, 7);
|
||||
|
||||
SoundEffect soundEffect = context.Content.Load<SoundEffect>(@$"Sfx\Explosions\EXPLDsgn_Explosion Impact_0{number}_SFRMS_SCIWPNS");
|
||||
soundEffect.Play(0.95f, (float)(context.Random.NextDouble() * 0.1 - 0.05), 0);
|
||||
}
|
||||
|
||||
private void TryFire(SpriteUpdateContext context)
|
||||
{
|
||||
if (CurrentFireThreshold > 0)
|
||||
|
||||
Reference in New Issue
Block a user