Exemple #1
0
        public Channel.Channel PlaySound(Sound.Sound snd, bool paused)
        {
            IntPtr ChannelHandle = IntPtr.Zero;

            Error.Code ReturnCode = PlaySound(this.DangerousGetHandle(), Channel.Index.Free, snd.DangerousGetHandle(), paused, ref ChannelHandle);
            Error.Errors.ThrowError(ReturnCode);

            return(new Channel.Channel(ChannelHandle));
        }
Exemple #2
0
        private void PlaySound(Sound.Sound snd, bool paused, Channel.Channel chn)
        {
            //FIXME The handle is changed most of the time on some system.
            //Only use the other metods to be safe.

            IntPtr channel = chn.DangerousGetHandle();

            Error.Code ReturnCode = PlaySound(this.DangerousGetHandle(), Channel.Index.Reuse, snd.DangerousGetHandle(), paused, ref channel);
            Error.Errors.ThrowError(ReturnCode);

            //This can't really happend.
            //Check just in case...
            if (chn.DangerousGetHandle() == channel)
            {
                throw new Exception("Channel handle got changed by Fmod.");
            }
        }
 private static void LoadSounds(Table table, CFStorage storage, int fileVersion)
 {
     for (var i = 0; i < table.Data.NumSounds; i++)
     {
         var soundName = $"Sound{i}";
         storage.TryGetStream(soundName, out var soundStream);
         if (soundStream == null)
         {
             Logger.Warn("Could not find stream {0}, skipping.", soundName);
             continue;
         }
         var soundData = soundStream.GetData();
         using (var stream = new MemoryStream(soundData))
             using (var reader = new BinaryReader(stream)) {
                 var sound = new Sound.Sound(reader, soundName, fileVersion);
                 table.Sounds[sound.Name.ToLower()] = sound;
             }
     }
 }
 public void AddSound(Sound.Sound sound)
 {
     _sounds[sound.Name.ToLower()] = sound;
 }
Exemple #5
0
        /// <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;
        }
        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();
                }
            }
        }
Exemple #7
0
 /// <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();
     }
 }
Exemple #8
0
 public Channel.Channel PlaySound(Sound.Sound snd)
 {
     return(this.PlaySound(snd, false));
 }
Exemple #9
0
 /*/// <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();
 }