/// <summary> /// Ladet das Level, erstellt die Spielfigur /// </summary> /// <param name="levelXmlPath">XML Pfad des gewünschten Levels</param> /// <param name="difficulty">Schwierigkeitsgrad</param> /// <returns>Prüfung ob das Level geladen werden konnte</returns> public bool Load(string levelXmlPath = "data/levels/jungle/level.xml", JumpAndRun.Difficulty difficulty = JumpAndRun.Difficulty.Normal) { if (String.IsNullOrEmpty(levelXmlPath)) { return false; } GameStatus = GameStatus.Loading; //string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); //dir = dir + LevelXmlPath; // Level Objekt deserialisieren und laden FileStream stream; //stream = new FileStream(dir, FileMode.Open); stream = new FileStream(levelXmlPath, FileMode.Open); XmlSerializer serializer = new XmlSerializer(typeof(Level)); level = (Level)serializer.Deserialize(stream); stream.Close(); level.Deserialize(); if (!level.Load(difficulty)) { return false; } level.Visibility(false); // Spieler Player.Scale = 0.7f; Player.Attach = true; Player.Gains = 0; Player.Penalties = 0; Sound.Sound sound = new Sound.Sound("data/sound/menu/Bing.mp3"); sound.Play(); // Levelende abfangen level.LevelFinishedEvent += new Level.LevelFinished(LevelHasFinished); GameStatus = GameStatus.LoadingComplete; return true; }
/// <summary> /// Spielt einen Sound ab. /// </summary> private void PlaySound() { if (Model.Sound.Length > 0) { //SoundCollision.FilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + Model.Sound; SoundCollision = new Sound.Sound(Model.Sound); if (Model.SoundVolume > 0) SoundCollision.Volume = Model.SoundVolume; SoundCollision.Play(); } }
private void HandleEntered() { state = State.Inside; if (EnteredEvent != null) { EnteredEvent(this); // Sound abspielen if (!SoundOnEnter.Equals("")) { Sound.Sound sound = new Sound.Sound(SoundOnEnter); sound.Play(); } } }
/*/// <summary> /// Hinzufügen eines XML Datei eines Levelsegmentes /// </summary> /// <param name="path"></param> public void AddXmlPath(string path) { SegmentsXmlPath.Add(path); }*/ /// <summary> /// Hintergrundmusik abspielen /// </summary> public void playBackgroundMusic() { switch (difficulty) { case JumpAndRun.Difficulty.Easy: //BgSound.FilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + BackgroundMusicEasy; BgSound = new Sound.Sound(BackgroundMusicEasy); BgSound.Volume = BackgroundMusicEasyVolume; break; case JumpAndRun.Difficulty.Normal: //BgSound.FilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + BackgroundMusicMedium; BgSound = new Sound.Sound(BackgroundMusicMedium); BgSound.Volume = BackgroundMusicMediumVolume; break; case JumpAndRun.Difficulty.Difficult: //BgSound.FilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + BackgroundMusicHard; BgSound = new Sound.Sound(BackgroundMusicHard); BgSound.Volume = BackgroundMusicHardVolume; break; default: //BgSound.FilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + BackgroundMusicHard; BgSound = new Sound.Sound(BackgroundMusicHard); BgSound.Volume = BackgroundMusicHardVolume; break; } BgSound.Loop = true; BgSound.Play(); }