Example #1
0
 private void OpenWindow(object sender, EventArgs e)
 {
     Thread.Sleep(2000);
     WarzoneIntro.Play();
     _spP1.Play();
     new Task(ShowTitleAndSound).Start();
 }
Example #2
0
        private void ShowTitleAndSound()
        {
            var pos = 0;

            do
            {
                Thread.Sleep(50);
                Dispatcher.BeginInvoke((Action) delegate { pos = WarzoneIntro.Position.Seconds; });
            } while (pos < 5);

            _spP1.Stop();
            _spP2.Play();

            do
            {
                Thread.Sleep(50);
                Dispatcher.BeginInvoke((Action) delegate { pos = WarzoneIntro.Position.Seconds; });
            } while (pos < 10);

            _spP2.Stop();
            Dispatcher.BeginInvoke((Action) delegate { WarzoneIntro.Pause(); });
            _spP3.PlaySync(); //播放完语音再出title
            Dispatcher.BeginInvoke((Action) delegate { WarzoneIntro.Play(); });
            var i = 0.01;

            _spP3Bg.PlayLooping();
            //_spP3Bg.PlayLooping();


            do
            {
                var i1 = i;
                Dispatcher.BeginInvoke((Action) delegate { WarzoneTitle.Opacity = i1; });
                i *= 2;
                Thread.Sleep(80);
                if (!(i > 1))
                {
                    continue;
                }
                Dispatcher.BeginInvoke((Action) delegate { WarzoneTitle.Opacity = 1; });
                break;
            } while (i < 1);

            void Cleanup()
            {
                _spP1.Stop();
                _spP1.Dispose();
                _spP2.Stop();
                _spP2.Dispose();
                _spP3.Stop();
                _spP3.Dispose();
                _spP3Bg.Stop();
                _spP3Bg.Dispose();
            }

            while (!_isIntroClosing)
            {
                for (var h = 1; h <= 100; h++)
                {
                    var h1 = h;
                    Dispatcher.BeginInvoke((Action) delegate { PressStart.Opacity = h1 * 0.01; });
                    if (_isIntroClosing)
                    {
                        Cleanup();
                        return;
                    }

                    Thread.Sleep(10);
                }

                for (var h = 100 - 1; h >= 0; h--)
                {
                    var h1 = h;
                    Dispatcher.BeginInvoke((Action) delegate { PressStart.Opacity = h1 * 0.01; });
                    if (_isIntroClosing)
                    {
                        Cleanup();
                        return;
                    }

                    Thread.Sleep(10);
                }
            }

            Cleanup();
        }