示例#1
0
        public void PlaySoundWav(string sRegion, string sRoom, string sBed)
        {
            int         num         = 0;
            string      text        = "";
            ArrayList   arrayList   = new ArrayList();
            SoundPlayer soundPlayer = new SoundPlayer();

            foreach (SoundTempInfo soundTempInfo in this.SoundTmpArray)
            {
                switch (soundTempInfo.iSound_type_id)
                {
                case 1:
                    try
                    {
                        text = this.SoundArray.GetValue(int.Parse(soundTempInfo.iSound_id.ToString())).sound_path;
                    }
                    catch
                    {
                        text = "";
                    }
                    if (text.Length > 0)
                    {
                        arrayList.Add(text);
                    }
                    try
                    {
                        text = this.SoundArray.GetValue(sRegion).sound_path;
                    }
                    catch
                    {
                        text = "";
                    }
                    if (text.Length > 0)
                    {
                        arrayList.Add(text);
                    }
                    break;

                case 2:
                    try
                    {
                        text = this.SoundArray.GetValue(int.Parse(soundTempInfo.iSound_id.ToString())).sound_path;
                    }
                    catch
                    {
                        text = "";
                    }
                    if (text.Length > 0)
                    {
                        arrayList.Add(text);
                    }
                    num = sRoom.Length;
                    if (soundTempInfo.iNread > 0)
                    {
                        if (soundTempInfo.iNread <= num)
                        {
                            sRoom = sRoom.Substring(num - soundTempInfo.iNread, soundTempInfo.iNread);
                        }
                    }
                    num = sRoom.Length;
                    for (int i = 0; i < num; i++)
                    {
                        string s_sound_code = sRoom.Substring(i, 1);
                        try
                        {
                            text = this.SoundArray.GetValue(s_sound_code).sound_path;
                        }
                        catch
                        {
                            text = "";
                        }
                        if (text.Length > 0)
                        {
                            arrayList.Add(text);
                        }
                    }
                    break;

                case 3:
                    if (sBed == "00")
                    {
                        try
                        {
                            text = this.SoundArray.GetValue(sBed).sound_path;
                        }
                        catch
                        {
                            text = "";
                        }
                        if (text.Length > 0)
                        {
                            arrayList.Add(text);
                        }
                    }
                    else
                    {
                        try
                        {
                            text = this.SoundArray.GetValue(int.Parse(soundTempInfo.iSound_id.ToString())).sound_path;
                        }
                        catch
                        {
                            text = "";
                        }
                        if (text.Length > 0)
                        {
                            arrayList.Add(text);
                        }
                        num = sBed.Length;
                        if (soundTempInfo.iNread > 0)
                        {
                            if (soundTempInfo.iNread <= num)
                            {
                                sBed = sBed.Substring(num - soundTempInfo.iNread, soundTempInfo.iNread);
                            }
                        }
                        num = sBed.Length;
                        for (int i = 0; i < num; i++)
                        {
                            string s_sound_code = sBed.Substring(i, 1);
                            try
                            {
                                text = this.SoundArray.GetValue(s_sound_code).sound_path;
                            }
                            catch
                            {
                                text = "";
                            }
                            if (text.Length > 0)
                            {
                                arrayList.Add(text);
                            }
                        }
                    }
                    break;

                case 4:
                    if (soundTempInfo.iSound_id.ToString() != "")
                    {
                        try
                        {
                            text = this.SoundArray.GetValue(int.Parse(soundTempInfo.iSound_id.ToString())).sound_path;
                        }
                        catch
                        {
                            text = "";
                        }
                        if (text.Length > 0)
                        {
                            arrayList.Add(text);
                        }
                    }
                    break;
                }
            }
            for (int j = 0; j < arrayList.Count; j++)
            {
                try
                {
                    int soundLength = SoundInfo.GetSoundLength(arrayList[j].ToString());
                    soundPlayer.SoundLocation = arrayList[j].ToString();
                    soundPlayer.Play();
                    Thread.Sleep(soundLength);
                }
                catch
                {
                }
            }
        }