Ejemplo n.º 1
1
 /// <summary>
 /// OnJitterBufferDataAvailable
 /// </summary>
 /// <param name="packet"></param>
 private void OnJitterBufferDataAvailable(Object sender, WinSound.RTPPacket rtp)
 {
     if (Player != null)
     {
         //Nach Linear umwandeln
         Byte[] linearBytes = WinSound.Utils.MuLawToLinear(rtp.Data, BitsPerSample, Channels);
         //Abspielen
         Player.PlayData(linearBytes, false);
     }
 }
Ejemplo n.º 2
1
 /// <summary>
 /// OnJitterBufferDataAvailable
 /// </summary>
 /// <param name="rtp"></param>
 private void OnJitterBufferDataAvailable(Object sender, WinSound.RTPPacket rtp)
 {
     try
     {
         if (IsServerRunning)
         {
             if (m_IsFormMain)
             {
                 //RTP Packet in Bytes umwandeln
                 Byte[] rtpBytes = rtp.ToBytes();
                 //Absenden
                 m_Server.Send(m_PrototolClient.ToBytes(rtpBytes));
             }
         }
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
 }
Ejemplo n.º 3
0
        private void Initialize()
        {
            _samplesPerSecond = AppConfiguration.AudioSamplesPerSecond;
            _bitsPerSample    = (short)AppConfiguration.AudioBitsPerSample;
            _channels         = (short)AppConfiguration.AudioChannels;
            _dataBufferSize   = 1280;

            string waveOutDeviceName = WinSound.GetWaveOutDeviceNames().Count > 0 ? WinSound.GetWaveOutDeviceNames()[0] : null;

            if (waveOutDeviceName != null)
            {
                _player = new WinSoundPlayer();
                _player.Open(waveOutDeviceName, _samplesPerSecond, _bitsPerSample, _channels, _dataBufferSize, _soundBufferCount);
            }
            else
            {
                MessageBoxHelper.ShowBoxExclamation("本机未找到播放设备!");
            }

            string waveInDeviceName = WinSound.GetWaveInDeviceNames().Count > 0 ? WinSound.GetWaveInDeviceNames()[0] : null;

            if (waveInDeviceName != null)
            {
                _recorder = new WinSoundRecord();
                _recorder.DataRecorded += Recorder_DataRecorded;
                _recorder.Open(waveInDeviceName, _samplesPerSecond, _bitsPerSample, _channels, _dataBufferSize, _soundBufferCount);
            }
            else
            {
                MessageBoxHelper.ShowBoxExclamation("本机未找到录音设备!");
            }
            this.AudioAdapterHandler.StartRemoteAudio(_samplesPerSecond, _bitsPerSample, _channels);

            this._isRun = true;
        }
Ejemplo n.º 4
0
        private void Initialize()
        {
            int samplesPerSecond = int.Parse(AppConfiguration.AudioSamplesPerSecond);
            int bitsPerSample    = int.Parse(AppConfiguration.AudioBitsPerSample);
            int channels         = int.Parse(AppConfiguration.AudioChannels);

            string waveOutDeviceName = WinSound.GetWaveOutDeviceNames().Count > 0 ? WinSound.GetWaveOutDeviceNames()[0] : null;

            if (waveOutDeviceName != null)
            {
                _player = new WinSoundPlayer();
                _player.Open(waveOutDeviceName, samplesPerSecond, bitsPerSample, channels, 1280, SoundBufferCount);
            }
            else
            {
                MessageBox.Show("本机未找到播放设备!", "提示", 0, MessageBoxIcon.Exclamation);
            }

            string waveInDeviceName = WinSound.GetWaveInDeviceNames().Count > 0 ? WinSound.GetWaveInDeviceNames()[0] : null;

            if (waveInDeviceName != null)
            {
                _recorder = new WinSoundRecord();
                _recorder.DataRecorded += Recorder_DataRecorded;
                _recorder.Open(waveInDeviceName, samplesPerSecond, bitsPerSample, channels, 1280, SoundBufferCount);
            }
            else
            {
                MessageBox.Show("本机未找到录音设备!", "提示", 0, MessageBoxIcon.Exclamation);
            }

            OpenRemoteAudio(samplesPerSecond, bitsPerSample, channels);

            _isRun = true;
        }
Ejemplo n.º 5
0
    public static void PlayWinSound()
    {
        WinSound soundSource = GameObject.FindObjectOfType <WinSound>();

        soundSource.GetComponent <AudioSource>().volume = soundEffectVolume * 0.2f;
        soundSource.GetComponent <AudioSource>().Play();
    }
        private void FillRecievers()
        {
            var names = WinSound.GetRecordingNames();

            foreach (var item in names.Select(name => new ComboBoxItem
            {
                Content = name,
            }))
            {
                item.Selected += SelecterRecieverChanged;
                Recievers.Add(item);
            }

            OnPropertyChanged("Recievers");
        }
Ejemplo n.º 7
0
        private void OpenAudio(int samplesPerSecond, int bitsPerSample, int channels)
        {
            int inDeviceOpen  = 0;
            int outDeviceOpen = 0;

            try
            {
                string waveInDeviceName = WinSound.GetWaveInDeviceNames().Count > 0 ? WinSound.GetWaveInDeviceNames()[0] : null;
                if (waveInDeviceName != null)
                {
                    _Recorder = new WinSoundRecord();
                    _Recorder.DataRecorded += Recorder_DataRecorded;
                    _Recorder.Open(waveInDeviceName, samplesPerSecond, bitsPerSample, channels, 1280, 8);
                }
                else
                {
                    inDeviceOpen = 1;
                }
            }
            catch { }

            try
            {
                string waveOutDeviceName = WinSound.GetWaveOutDeviceNames().Count > 0 ? WinSound.GetWaveOutDeviceNames()[0] : null;
                if (waveOutDeviceName != null)
                {
                    _Player = new WinSoundPlayer();
                    _Player.Open(waveOutDeviceName, samplesPerSecond, bitsPerSample, channels, 1280, 8);
                }
                else
                {
                    outDeviceOpen = 1;
                }
            }
            catch { }

            SendAsyncToServer(MessageHead.C_AUDIO_DEVICE_OPENSTATE,
                              new AudioDeviceStatesPack()
            {
                PlayerEnable = outDeviceOpen == 0 ? true : false,
                RecordEnable = inDeviceOpen == 0 ? true : false
            });
        }
Ejemplo n.º 8
0
    private void win()
    {
        Debug.Log(Name + ": YOU WIN!" + "Elapsed: " + numTicksElapsed);
        if (WinSound != null)
        {
            WinSound.Play();
        }

        ShowWinAnimation(true);

        ShowWetGround(true);

        CenterObjectWin();

        //winBox.SetActive (true);
        //winBox.GetComponent<Renderer>().enabled = true;

        state = SpellState.Win;
        endSpell();
    }
 public void PlayWinSoundAudio()
 {
     WinSound.Play();
 }
Ejemplo n.º 10
0
    void OnTriggerEnter(Collider collision)
    {
        // Debug.Log(collision.gameObject.name);
        if (collision.gameObject.name == "Coin(Clone)")
        {
            Destroy(collision.gameObject);
            Instantiate(coinsound, UnityChanPosition, Quaternion.identity);
            coins_number++;

            Coin_save++;
            RealGold.GetComponent <Text>().text = Convert.ToString(Coin_save);
        }
        if (collision.gameObject.name == "MobileMaleFree1") //character boy
        {
            if (Time.timeScale == 1)
            {
                dialog.SetActive(true);
                Time.timeScale = 0;
                Debug.Log("8787878787777");
            }
        }
        else if (collision.gameObject.name == "Boxshelf" && SceneManager.GetActiveScene().name == "SceneMap")
        {
            PlayerPrefs.SetString("step", "1");

            SceneManager.LoadScene("SceneMap2");
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            this.transform.position = new Vector3(-11.77f, UnityChanPosition.y, -27.7f);
            this.transform.rotation = Quaternion.Euler(0f, 96.5f, 0f);
            MainCamera.GetComponent <Transform>().rotation    = this.transform.rotation;
            MainCamera.GetComponent <Transform>().eulerAngles = new Vector3(20.0f, MainCamera.GetComponent <Transform>().eulerAngles.y, MainCamera.GetComponent <Transform>().eulerAngles.z);

            UnityChanPosition  = this.GetComponent <Transform>().position;
            CameraFollowVector = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (collision.gameObject.name == "Boxshelf2" && SceneManager.GetActiveScene().name == "SceneMap")
        {
            PlayerPrefs.SetString("step", "1");

            SceneManager.LoadScene("SceneMap2");
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            this.transform.position = new Vector3(-13.5f, UnityChanPosition.y, 105.66f);
            this.transform.rotation = Quaternion.Euler(0f, 71f, 0f);
            MainCamera.GetComponent <Transform>().rotation    = this.transform.rotation;
            MainCamera.GetComponent <Transform>().eulerAngles = new Vector3(20.0f, MainCamera.GetComponent <Transform>().eulerAngles.y, MainCamera.GetComponent <Transform>().eulerAngles.z);

            UnityChanPosition  = this.GetComponent <Transform>().position;
            CameraFollowVector = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (collision.gameObject.name == "Boxshelf" && SceneManager.GetActiveScene().name == "SceneMap2")
        {
            PlayerPrefs.SetString("step", "1");
            SceneManager.LoadScene("SceneMap");
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            this.transform.position = new Vector3(-11.77f, UnityChanPosition.y, -27.7f);
            this.transform.rotation = Quaternion.Euler(0f, 96.5f, 0f);
            MainCamera.GetComponent <Transform>().rotation    = this.transform.rotation;
            MainCamera.GetComponent <Transform>().eulerAngles = new Vector3(20.0f, MainCamera.GetComponent <Transform>().eulerAngles.y, MainCamera.GetComponent <Transform>().eulerAngles.z);

            UnityChanPosition  = this.GetComponent <Transform>().position;
            CameraFollowVector = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (collision.gameObject.name == "Boxshelf2" && SceneManager.GetActiveScene().name == "SceneMap2")
        {
            PlayerPrefs.SetString("step", "1");
            SceneManager.LoadScene("SceneMap");
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            this.transform.position = new Vector3(-20.72f, UnityChanPosition.y, 109.82f);
            this.transform.rotation = Quaternion.Euler(0f, 144.77f, 0f);
            MainCamera.GetComponent <Transform>().rotation    = this.transform.rotation;
            MainCamera.GetComponent <Transform>().eulerAngles = new Vector3(20.0f, MainCamera.GetComponent <Transform>().eulerAngles.y, MainCamera.GetComponent <Transform>().eulerAngles.z);

            UnityChanPosition  = this.GetComponent <Transform>().position;
            CameraFollowVector = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (collision.gameObject.name == "goal1" || collision.gameObject.name == "goal2" || collision.gameObject.name == "goal3")
        {
            Success.SetActive(true);
            GetComponent <Animator>().Play("WIN00");
            WinSound.GetComponent <AudioSource>().Play();
            GameControl.GetComponent <AudioSource>().Stop();
            Time.timeScale = 0;
            CoinText.GetComponent <Text>().text = Convert.ToString(coins_number);

            double time = Time.realtimeSinceStartup - timeInit;
            if (time >= 60)
            {
                Debug.Log("Time: " + Math.Floor(time / 60) + "min" + Math.Floor(time % 60) + "sec");
                TimeText.GetComponent <Text>().text = Math.Floor(time / 60) + "min" + Math.Floor(time % 60) + "sec";
            }
            else
            {
                Debug.Log("Time: " + Math.Floor(time) + "sec");
                TimeText.GetComponent <Text>().text = Math.Floor(time) + "sec";
            }
        }
        else if (fireCollideDelay == -1 && (collision.gameObject.name == "Fire" || collision.gameObject.name == "Fire(Clone)"))
        {
            fireCollideDelay = fireImmuneFrame;
            GameObject.Find("JoystickImage").GetComponent <Image>().rectTransform.anchoredPosition = Vector3.zero;
            Debug.Log("on Fire!");
            if (hpcnt != -1)
            {
                hp[hpcnt--].gameObject.SetActive(false);
                Hpeffect.SetActive(true);
                this.Invoke("finished", 0.3f);
                FireAttackSound.GetComponent <AudioSource>().Play();
                GetComponent <Animator>().Play("DAMAGED00");
            }

            Vector3 firePosition = collision.gameObject.GetComponent <Transform>().position;
            Vector3 nextPosition = Vector3.LerpUnclamped(firePosition, this.transform.position, fireBounceDistance);
            //nextPosition.y = new Vector3(nextPosition.x, UnityChanPosition.y, nextPosition.z);
            nextPosition.y = UnityChanPosition.y;
            RaycastHit hitInfo;
            if (Physics.Linecast(this.transform.position, nextPosition, out hitInfo))
            {
                nextPosition = Vector3.LerpUnclamped(hitInfo.point, this.transform.position, fireWallMedium);
            }
            //this.transform.position = Vector3.LerpUnclamped(firePosition, this.transform.position, 2.5f);
            if (hpcnt == -1)
            {
                GetComponent <Animator>().Play("DAMAGED01");
                LoseSound.GetComponent <AudioSource>().Play();
                PlayerPrefs.SetString("step", "0");
                GameObject.Find("goal1").GetComponent <BoxCollider>().isTrigger = false;
                GameObject.Find("goal2").GetComponent <BoxCollider>().isTrigger = false;
                GameObject.Find("goal3").GetComponent <BoxCollider>().isTrigger = false;
                //string scene = SceneManager.GetActiveScene().name;
                GameObject.Destroy(GameObject.Find("Camera2"));
                GameObject.Destroy(GameObject.Find("VirtualJoystick"));
                GameObject.Destroy(GameObject.Find("VirtualJoystick (1)"));
                GameObject.Destroy(GameObject.Find("Coin"));
                GameObject.Destroy(GameObject.Find("FB"));
                GameObject.Destroy(GameObject.Find("unitychan"));
                GameObject.Destroy(GameObject.Find("Setting"));
                GameObject.Destroy(GameObject.Find("Pause"));
                GameObject.Destroy(GameObject.Find("GameController"));
                GameObject.Destroy(GameObject.Find("Cube"));
                GameObject.Destroy(GameObject.Find("Cube (1)"));
                SceneManager.LoadScene("SceneMenu");

                restart = true;
                hp[0].gameObject.SetActive(true);
                hp[1].gameObject.SetActive(true);
                hp[2].gameObject.SetActive(true);
                hpcnt          = 2;
                isStageStarted = false;
            }

            //this.transform.position = new Vector3(this.transform.position.x, UnityChanPosition.y, this.transform.position.z);
            this.transform.position = nextPosition;
            UnityChanPosition       = this.GetComponent <Transform>().position;
            CameraFollowVector      = new Vector3(UnityChanPosition.x, 3.2f, UnityChanPosition.z);
            MainCamera.GetComponent <Transform>().position = CameraFollowVector;
            MainCamera.GetComponent <Transform>().Translate(Vector3.back * 5);
        }
        else if (!isStageStarted && collision.gameObject.name == "Stage1")
        {
            isStageStarted = true;
            Debug.Log("Stage 1 Start!!");
            coins_number = 0;
            GameControl.GetComponent <AudioSource>().clip = audios[1];
            GameControl.GetComponent <AudioSource>().Play();
            GameObject.Find("goal1").GetComponent <BoxCollider>().isTrigger = true;
            GameObject.Find("goal2").GetComponent <BoxCollider>().isTrigger = true;
            GameObject.Find("goal3").GetComponent <BoxCollider>().isTrigger = true;
            Vector3    fire1Position = new Vector3(46.77003f, -1.98f, 117.75f);
            GameObject fire1         = Instantiate(GameObject.Find("Fire"), fire1Position, GameObject.Find("Fire").GetComponent <Transform>().rotation);
            fire1.GetComponent <FireSpread>().spreadTimeSec = 5;
            fire1.GetComponent <FireSpread>().gapPixel      = 3;
            fire1.GetComponent <FireSpread>().setTime(Time.realtimeSinceStartup);
            fire1.GetComponent <FireSpread>().isTemplate = false;
            fire1.GetComponent <FireSpread>().isActive   = true;

            Vector3    fire2Position = new Vector3(-11.7f, -21.98f, 102.1f);
            GameObject fire2         = Instantiate(GameObject.Find("Fire"), fire2Position, GameObject.Find("Fire").GetComponent <Transform>().rotation);
            fire2.GetComponent <FireSpread>().spreadTimeSec = 5;
            fire2.GetComponent <FireSpread>().gapPixel      = 3;
            fire2.GetComponent <FireSpread>().setTime(Time.realtimeSinceStartup);
            fire2.GetComponent <FireSpread>().isTemplate = false;
            fire2.GetComponent <FireSpread>().isActive   = false;
            //GameObject.Find("Stage1").SetActive(false);
            timeInit = Time.realtimeSinceStartup;
        }
    }