Initial music impl

This commit is contained in:
2021-04-23 20:28:06 +02:00
parent 44f0f9e399
commit 1aa7a57d91
19 changed files with 171 additions and 7 deletions
+28
View File
@@ -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;
}
}
}
+1
View File
@@ -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()
+33
View File
@@ -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());
}
}
}
}