Initial music impl
This commit is contained in:
@@ -32,13 +32,13 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="CppSharp.Runtime">
|
||||
<HintPath>..\..\synthy\Synthy\bin\Debug\netstandard2.1\CppSharp.Runtime.dll</HintPath>
|
||||
<HintPath>..\..\synthy\Synthy\bin\Release\netstandard2.1\CppSharp.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Synthizer.Net">
|
||||
<HintPath>..\..\synthy\Synthy\bin\Debug\netstandard2.1\Synthizer.Net.dll</HintPath>
|
||||
<HintPath>..\..\synthy\Synthy\bin\Release\netstandard2.1\Synthizer.Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Synthy">
|
||||
<HintPath>..\..\synthy\Synthy\bin\Debug\netstandard2.1\Synthy.dll</HintPath>
|
||||
<HintPath>..\..\synthy\Synthy\bin\Release\netstandard2.1\Synthy.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace EvilSatellites
|
||||
{
|
||||
public static class GameStats
|
||||
{
|
||||
public static int ShotsFired;
|
||||
public static int SatellitesShot;
|
||||
public static int DebrisCollected;
|
||||
public static int SatelliteCollisions;
|
||||
public static int DebrisCollisions;
|
||||
public static double TotalPlayTime;
|
||||
public static void Reset()
|
||||
{
|
||||
ShotsFired = 0;
|
||||
SatellitesShot = 0;
|
||||
DebrisCollected = 0;
|
||||
SatelliteCollisions = 0;
|
||||
DebrisCollisions = 0;
|
||||
TotalPlayTime = 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SynthySound;
|
||||
|
||||
namespace EvilSatellites
|
||||
{
|
||||
public class MusicManager
|
||||
{
|
||||
public ISoundEffect Song;
|
||||
public float _Volume;
|
||||
public float Volume {
|
||||
get => _Volume;
|
||||
set
|
||||
{
|
||||
if (IsPlaying)
|
||||
{
|
||||
Song.Volume = Volume;
|
||||
}
|
||||
_Volume = Volume;
|
||||
}
|
||||
}
|
||||
public bool IsPlaying;
|
||||
public Synthy Engine;
|
||||
public MusicManager(Synthy engine)
|
||||
{
|
||||
Engine = engine;
|
||||
_Volume = 0.2f;
|
||||
IsPlaying = false;
|
||||
}
|
||||
|
||||
public void Play(string path)
|
||||
{
|
||||
if (IsPlaying)
|
||||
{
|
||||
Song.Stop();
|
||||
Song.Destroy();
|
||||
}
|
||||
Song = Engine.Load(@"sfx/music/" + path + ".mp3", false, true);
|
||||
|
||||
Song.Play();
|
||||
Song.Volume = _Volume;
|
||||
Song.Loop = true;
|
||||
IsPlaying = true;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (IsPlaying)
|
||||
{
|
||||
Song.Stop();
|
||||
Song.Destroy();
|
||||
IsPlaying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,10 +58,12 @@ namespace EvilSatellites.Objects
|
||||
{
|
||||
player.CurrentWeapon.Reload(rnd.Next(player.CurrentWeapon.MaxAmmo/4));
|
||||
Destroy();
|
||||
GameStats.DebrisCollected++;
|
||||
return;
|
||||
}
|
||||
player.TakeDamage(25);
|
||||
Destroy();
|
||||
GameStats.SatelliteCollisions++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,8 +207,8 @@ namespace EvilSatellites.Objects
|
||||
{
|
||||
Destroy();
|
||||
Screen.Manager.Sound.PlayOneshot(@"sfx/physics/crashes/1.wav");
|
||||
System.Threading.Thread.Sleep(2000);
|
||||
Environment.Exit(0);
|
||||
var scr = (GameScreen)Screen;
|
||||
scr.EndGame();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ namespace EvilSatellites.Objects
|
||||
Screen.Manager.Sound.PlayOneshot(@"sfx/satellite/"+SatelliteID.ToString()+"/explode.wav", new System.Numerics.Vector3(Position.X, Position.Y, Position.Z));
|
||||
SpawnDebris();
|
||||
Destroy();
|
||||
GameStats.SatellitesShot++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -122,5 +122,9 @@ namespace EvilSatellites
|
||||
}
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
RadarNoise.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,5 +43,10 @@ namespace EvilSatellites
|
||||
Spawn();
|
||||
}
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,14 @@ namespace EvilSatellites
|
||||
private IScreen _CurrentScreen;
|
||||
private Game _Game;
|
||||
private bool _Running = false;
|
||||
public Synthy Sound = new Synthy();
|
||||
|
||||
public Synthy Sound;
|
||||
public MusicManager Music;
|
||||
public FDNReverb EnvironmentEffect;
|
||||
public AudioListener Listener = new AudioListener();
|
||||
public ScreenManager(Game instance): base(instance)
|
||||
{
|
||||
Sound = new Synthy();
|
||||
Music = new MusicManager(Sound);
|
||||
EnvironmentEffect = Sound.CreateReverb();
|
||||
EnvironmentEffect.Delay = 0.03;
|
||||
EnvironmentEffect.Wet = 30;
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace EvilSatellites.Screens
|
||||
private Player _player;
|
||||
private Radar ObjectRadar;
|
||||
private SatelliteSpawner Spawner;
|
||||
private bool GameOver = false;
|
||||
public void Activate()
|
||||
{
|
||||
State = ScreenState.Active;
|
||||
@@ -33,6 +34,8 @@ namespace EvilSatellites.Screens
|
||||
ObjectRadar = new Radar(_player, this);
|
||||
Spawner = new SatelliteSpawner(this);
|
||||
Spawner.Spawn();
|
||||
GameStats.Reset();
|
||||
Manager.Music.Play("game1");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -44,6 +47,19 @@ namespace EvilSatellites.Screens
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
if (GameOver == true)
|
||||
{
|
||||
foreach (var obj in Objects)
|
||||
{
|
||||
obj.Destroy();
|
||||
}
|
||||
ObjectRadar.Destroy();
|
||||
Spawner.Destroy();
|
||||
// TODO: figure out why cleanup doesn't work
|
||||
// Manager.Sound.Cleanup();
|
||||
HandleGameOver(gameTime);
|
||||
|
||||
}
|
||||
foreach (var obj in Removable)
|
||||
{
|
||||
Objects.Remove(obj);
|
||||
@@ -241,5 +257,17 @@ namespace EvilSatellites.Screens
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public void HandleGameOver(GameTime time)
|
||||
{
|
||||
GameStats.TotalPlayTime = time.TotalGameTime.TotalSeconds;
|
||||
Manager.RemoveScreen(this);
|
||||
Manager.AddScreen(new StatsScreen());
|
||||
}
|
||||
|
||||
public void EndGame()
|
||||
{
|
||||
GameOver = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace EvilSatellites.Screens
|
||||
Tolk.Output(MenuOptions.Description, false);
|
||||
Tolk.Output(MenuOptions.Entries[CursorPosition].Name);
|
||||
Manager.Sound.PlayOneshot(@"sfx/ui/menuOpen.wav");
|
||||
Manager.Music.Play("menu1");
|
||||
}
|
||||
|
||||
public virtual void Deactivate()
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using EvilSatellites.Screens;
|
||||
using EvilSatellites.Menu;
|
||||
|
||||
namespace EvilSatellites.Screens
|
||||
{
|
||||
public class StatsScreen : MenuScreen
|
||||
{
|
||||
public override void Activate()
|
||||
{
|
||||
MenuOptions = new MenuContainer("Statistics", "Statistics for current game");
|
||||
MenuOptions.Add(new MenuEntry("Shots fired: " + GameStats.ShotsFired.ToString(), "Amount of shots fired during this game."))
|
||||
.Add(new MenuEntry("Satellites shot: " + GameStats.SatellitesShot.ToString(), "Amount of satellites shot during this game."))
|
||||
.Add(new MenuEntry("Debris collected: " + GameStats.DebrisCollected.ToString(), "Amount of debris collected during this game."))
|
||||
.Add(new MenuEntry("Satellite collisions: " + GameStats.SatelliteCollisions.ToString(), "How many satellites you crashed into"))
|
||||
.Add(new MenuEntry("Total play time: " + GameStats.TotalPlayTime.ToString(), "How much time you spent on this run"))
|
||||
.Add(new MenuEntry("OK", "Go back to main menu"));
|
||||
}
|
||||
|
||||
public override void SelectItem()
|
||||
{
|
||||
if (CursorPosition == MenuOptions.Entries.Count-1)
|
||||
{
|
||||
Manager.RemoveScreen(this);
|
||||
Manager.AddScreen(new MainMenuScreen());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,7 @@ namespace EvilSatellites.Weapons
|
||||
TimerStart = TimerEnd;
|
||||
Projectile proj = new Projectile(Screen, _wielder.Position, _wielder.Rotation, _wielder);
|
||||
Screen.AddObject(proj);
|
||||
GameStats.ShotsFired++;
|
||||
} else
|
||||
{
|
||||
sfxEmpty.Reset();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user