From f5dd6c868d6782375ed61be1663693916864e271 Mon Sep 17 00:00:00 2001 From: Wafa Sadri Date: Mon, 12 May 2014 12:59:43 +0200 Subject: [PATCH] Music klasser erstellt und eingebaut. --- inf3.csproj | 1 + {music => sounds}/splashscreen.ogg | Bin src/Gui/Gui.cs | 4 ++++ src/Gui/Splashscreen.cs | 3 ++- src/Music.cs | 30 +++++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) rename {music => sounds}/splashscreen.ogg (100%) create mode 100644 src/Music.cs diff --git a/inf3.csproj b/inf3.csproj index a690624..f575cd9 100644 --- a/inf3.csproj +++ b/inf3.csproj @@ -81,6 +81,7 @@ + diff --git a/music/splashscreen.ogg b/sounds/splashscreen.ogg similarity index 100% rename from music/splashscreen.ogg rename to sounds/splashscreen.ogg diff --git a/src/Gui/Gui.cs b/src/Gui/Gui.cs index cb2140a..a9b08fe 100644 --- a/src/Gui/Gui.cs +++ b/src/Gui/Gui.cs @@ -16,6 +16,8 @@ namespace WorldOfPeacecraft private ChatPanel ChatPanel; private OnlinePlayerList OnlinePlayerList; + private Music m = new Music(); + public Gui () { //AllocConsole(); @@ -62,6 +64,8 @@ namespace WorldOfPeacecraft this.Controls.Add (ChatPanel); this.ResumeLayout(); + + m.Playmusic ("overworld"); } protected override void OnClosing (System.ComponentModel.CancelEventArgs e) diff --git a/src/Gui/Splashscreen.cs b/src/Gui/Splashscreen.cs index 86f21c9..3d87009 100644 --- a/src/Gui/Splashscreen.cs +++ b/src/Gui/Splashscreen.cs @@ -9,11 +9,12 @@ namespace WorldOfPeacecraft { private string ImagesFolder = "textures/"; private Image Logo; + private Music m = new Music(); public SplashScreen () { Logo = Image.FromFile (ImagesFolder + "splashscreen.png"); - //TODO: Play "splashscreen.ogg" + m.Playmusic ("splashscreen"); } protected override void OnPaint (PaintEventArgs e) diff --git a/src/Music.cs b/src/Music.cs new file mode 100644 index 0000000..7a84c87 --- /dev/null +++ b/src/Music.cs @@ -0,0 +1,30 @@ +using System; +using System.Media; + +namespace WorldOfPeacecraft +{ + public class Music + { + string musicpath = "./music/"; + string soundpath = "./sounds/"; + SoundPlayer overworldplayer = new SoundPlayer(musicpath + "overworld.wav"); + SoundPlayer minigameplayer = new SoundPlayer(musicpath + "minigame.wav"); + SoundPlayer splashscreenplayer = new SoundPlayer (soundpath + "splashscreen.wav"); + SoundPlayer walkplayer = new SoundPlayer(soundpath + "step.wav"); + public Music () + { + + } + public void Playmusic (string sound){ + if (sound == "overworld") + overworldplayer.PlayLooping (); + if (sound == "minigame") + minigameplayer.PlayLooping (); + if (sound == "splashscreen") + splashscreenplayer.PlaySync (); + if (sound == "walk") + walkplayer.Play (); + } + } +} +