コード例 #1
0
 public void ServerThreadStart()
 {
     try
     {
         Server server = new Server();
         server.SaveFilenameOverride = savefilename;
         server.exit = exit;
         DummyNetServer netServer = new DummyNetServer();
         netServer.SetPlatform(new GamePlatformNative());
         netServer.SetNetwork(dummyNetwork);
         server.mainSockets    = new NetServer[3];
         server.mainSockets[0] = netServer;
         for (; ;)
         {
             server.Process();
             Thread.Sleep(1);
             platform.singlePlayerServerLoaded = true;
             if (exit != null && exit.GetExit())
             {
                 server.Stop(); break;
             }
             if (platform.singlepLayerServerExit)
             {
                 server.Exit();
             }
         }
         exit.SetExit(false);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
     }
 }
コード例 #2
0
            private void DoPlay()
            {
                int source = OpenTK.Audio.OpenAL.AL.GenSource();
                int state;
                //using ()
                {
                    //Trace.WriteLine("Testing WaveReader({0}).ReadToEnd()", filename);

                    int buffer = OpenTK.Audio.OpenAL.AL.GenBuffer();

                    OpenTK.Audio.OpenAL.AL.BufferData(buffer, GetSoundFormat(sample.Channels, sample.BitsPerSample), sample.Pcm, sample.Pcm.Length, sample.Rate);
                    //audiofiles[filename]=buffer;

                    OpenTK.Audio.OpenAL.AL.DistanceModel(OpenTK.Audio.OpenAL.ALDistanceModel.InverseDistance);
                    OpenTK.Audio.OpenAL.AL.Source(source, OpenTK.Audio.OpenAL.ALSourcef.RolloffFactor, 0.3f);
                    OpenTK.Audio.OpenAL.AL.Source(source, OpenTK.Audio.OpenAL.ALSourcef.ReferenceDistance, 1);
                    OpenTK.Audio.OpenAL.AL.Source(source, OpenTK.Audio.OpenAL.ALSourcef.MaxDistance, (int)(64 * 1));
                    OpenTK.Audio.OpenAL.AL.Source(source, OpenTK.Audio.OpenAL.ALSourcei.Buffer, buffer);
                    OpenTK.Audio.OpenAL.AL.SourcePlay(source);

                    // Query the source to find out when it stops playing.
                    for (; ;)
                    {
                        OpenTK.Audio.OpenAL.AL.GetSource(source, OpenTK.Audio.OpenAL.ALGetSourcei.SourceState, out state);
                        if ((!loop) && (OpenTK.Audio.OpenAL.ALSourceState)state != OpenTK.Audio.OpenAL.ALSourceState.Playing)
                        {
                            break;
                        }
                        if (stop)
                        {
                            break;
                        }
                        if (gameexit.GetExit())
                        {
                            break;
                        }
                        if (loop)
                        {
                            if (state == (int)OpenTK.Audio.OpenAL.ALSourceState.Playing && (!shouldplay))
                            {
                                OpenTK.Audio.OpenAL.AL.SourcePause(source);
                            }
                            if (state != (int)OpenTK.Audio.OpenAL.ALSourceState.Playing && (shouldplay))
                            {
                                if (restart)
                                {
                                    OpenTK.Audio.OpenAL.AL.SourceRewind(source);
                                    restart = false;
                                }
                                OpenTK.Audio.OpenAL.AL.SourcePlay(source);
                            }
                        }

                        OpenTK.Audio.OpenAL.AL.Source(source, OpenTK.Audio.OpenAL.ALSource3f.Position, position.X, position.Y, position.Z);

                        /*
                         * if (stop)
                         * {
                         * AL.SourcePause(source);
                         * resume = false;
                         * }
                         * if (resume)
                         * {
                         * AL.SourcePlay(source);
                         * resume = false;
                         * }
                         */
                        Thread.Sleep(1);
                    }
                    Finished = true;
                    OpenTK.Audio.OpenAL.AL.SourceStop(source);
                    OpenTK.Audio.OpenAL.AL.DeleteSource(source);
                    OpenTK.Audio.OpenAL.AL.DeleteBuffer(buffer);
                }
            }