예제 #1
0
    public void Fire()
    {
        if (Time.time > nextAtk)
        {
            nextAtk = Time.time + atkRate;
            camShake.Shake(camShakeAmt, camShakeLength);
            AudioSrc.Play();

            for (int i = 0; i < targets.Count; i++)
            {
                if (targets.Count > 0)
                {
                    if (targets[i].tag == "Player" || targets[i].tag == "Enemy")
                    {
                        if (targets[i].GetComponent <Character>().isDead == false)
                        {
                            targets[i].GetComponent <Character>().TakeDamage(Damage);
                        }
                    }
                    if (targets[i].GetComponent <Rigidbody2D>() != null)
                    {
                        targets[i].GetComponent <Rigidbody2D>().AddForce(vecTovecToTrg.normalized * concQuote * -500.0f);
                    }
                }
            }
        }
    }
예제 #2
0
 public override void PlayAudio()
 {
     if (AudioSrc == null)
     {
         this.InitAudioSrc();
     }
     AudioSrc.Play();
 }
예제 #3
0
 public void Fire()
 {
     if (Time.time > nextAtk)
     {
         makeProjectile(emitPoint.transform.position, gameObject);
         nextAtk = Time.time + atkRate;
         camShake.Shake(camShakeAmt, camShakeLength);
         AudioSrc.Play();
     }
 }
    public void PlayOneShot(AudioClip soundClip, float volumeScale = 1f)
    {
        if (!CanPlay())
        {
            return;
        }

        if (sound.delayUntilNextPlay > 0f)
        {
            lastTimePlayed = Time.time;
        }

        //TODO: remove this hack "* AudioListener.volume" when Unity fixes their PlayOneShot audio source bug.
        AudioSrc.PlayOneShot(soundClip, volumeScale * AudioListener.volume);
    }
예제 #5
0
    private void Update()
    {
        hand1Tracked = hand1Controller.isTracked;
        hand2Tracked = hand2Controller.isTracked;
        if (playing)
        {
            if (GameManager.GM.hand1Tracked && GameManager.GM.hand2Tracked)
            {
                lastTracked = Time.time;
                if (paused)
                {
                    paused = false;
                    pauseScreen.SetActive(false);
                    cart.GetComponent <Rigidbody>().isKinematic = false;
                    InteractionManager.enabled = true;
                    foreach (AudioSource AudioSrc in audioSources)
                    {
                        AudioSrc.Play();
                    }
                }
            }

            if (Time.time > lastTracked + pauseDelay)
            {
                paused = true;
                pauseScreen.SetActive(true);
                cart.GetComponent <Rigidbody>().isKinematic = true;
                InteractionManager.enabled = false;
                foreach (AudioSource AudioSrc in audioSources)
                {
                    AudioSrc.Pause();
                }
            }

            if (paused)
            {
                pauseScreen.transform.GetChild(0).gameObject.SetActive(hand1Tracked);
                pauseScreen.transform.GetChild(1).gameObject.SetActive(hand2Tracked);
            }
        }
    }
예제 #6
0
    // Use this for initialization
    public static IEnumerator  LoadResources()
    {
        if (!bInitialized)
        {
            yield break;
        }

        GLOBALS.Logger.Write("AudioManager:Loading audio resources");

        // Sounds
        {
            GLOBALS.Logger.Write("AudioManager:Loading Sounds");

            ResourceRequest pResourceRequest = Resources.LoadAsync("Sounds");

            while (!pResourceRequest.isDone)
            {
                yield return(pResourceRequest);
            }

            Sounds_Scriptable pSoundsResources = pResourceRequest.asset as Sounds_Scriptable;

            foreach (string sAudioClip in pSoundsResources.vSoundsClip)
            {
                if (sAudioClip == null)
                {
                    Debug.Log("music loading failed");
                    continue;
                }

                GLOBALS.Logger.Write("AudioManager:Loading " + sAudioClip);

                ResourceRequest pResourceRequestAsset = Resources.LoadAsync <AudioClip>(sAudioClip);

                while (!pResourceRequestAsset.isDone)
                {
                    yield return(pResourceRequestAsset);
                }

                AudioClip pAudioClip = pResourceRequestAsset.asset as AudioClip;

                AudioSource pAudioSource = pAudioContainer.AddComponent <AudioSource>();
                pAudioSource.clip = pAudioClip;

                AudioSrc pAudioSrc = new AudioSrc();
                pAudioSrc.pSource = pAudioSource;
                pAudioSrc.sName   = pAudioClip.name;

                vSounds.Add(pAudioSrc);

                yield return(null);

//				Debug.Log( " Loaded  " + pAudioClip.name );
            }

            if (vSounds == null || vSounds.Count == 0)
            {
                Debug.LogWarning("Error loading sounds");
            }

            GLOBALS.Logger.Write("AudioManager:Sounds loaded");
        }

        // Musics
        {
            GLOBALS.Logger.Write("AudioManager:Loading Musics");

            ResourceRequest pResourceRequest = Resources.LoadAsync("Musics");

            while (!pResourceRequest.isDone)
            {
                yield return(pResourceRequest);
            }

            Musics_Scriptable pMusicsResources = pResourceRequest.asset as Musics_Scriptable;

            foreach (string sAudioClip in pMusicsResources.vMusicsClip)
            {
                if (sAudioClip == null)
                {
                    Debug.Log("music loading failed");
                    continue;
                }

                GLOBALS.Logger.Write("AudioManager:Loading " + sAudioClip);

                ResourceRequest pResourceRequestAsset = Resources.LoadAsync <AudioClip>(sAudioClip);

                while (!pResourceRequestAsset.isDone)
                {
                    yield return(pResourceRequestAsset);
                }

                AudioClip pAudioClip = pResourceRequestAsset.asset as AudioClip;

                AudioSource pAudioSource = pAudioContainer.AddComponent <AudioSource>();
                pAudioSource.clip = pAudioClip;

                AudioSrc pAudioSrc = new AudioSrc();
                pAudioSrc.pSource = pAudioSource;
                pAudioSrc.sName   = pAudioClip.name;

                vMusics.Add(pAudioSrc);

                yield return(null);

//				Debug.Log( " Loaded  " + pAudioClip.name );
            }

            if (vMusics == null || vMusics.Count == 0)
            {
                Debug.LogWarning("Error loading musics");
            }

            GLOBALS.Logger.Write("AudioManager:Musics loaded");
        }

        Debug.Log("loaded");
        bLoaded = true;
    }
예제 #7
0
        //To Start the Recording.
        private void startRecordingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IWMEncProfile SelProfile;
            IWMEncSource  AudioSrc;

            try
            {
                if (DesktopEncoder != null)
                {
                    if (DesktopEncoder.RunState == WMENC_ENCODER_STATE.WMENC_ENCODER_PAUSED)
                    {
                        DesktopEncoder.Start();
                        return;
                    }
                }
                DesktopEncoderAppln = new WMEncoderApp();
                DesktopEncoder      = DesktopEncoderAppln.Encoder;
                IWMEncSourceGroupCollection SrcGroupCollection = DesktopEncoder.SourceGroupCollection;
                IWMEncSourceGroup           SrcGroup           = SrcGroupCollection.Add("SG_1");
                IWMEncVideoSource2          VideoSrc           = (IWMEncVideoSource2)SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
                //Set Audio Source.
                if (addAudio.Checked)
                {
                    AudioSrc = SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
                    if (txtAudioFile.Text.Trim() != "")
                    {
                        if (File.Exists(txtAudioFile.Text.Trim()))
                        {
                            AudioSrc.SetInput(txtAudioFile.Text.Trim(), "", "");
                        }
                        else
                        {
                            AudioSrc.SetInput("Default_Audio_Device", "Device", "");
                        }
                    }
                    else
                    {
                        AudioSrc.SetInput("Default_Audio_Device", "Device", "");
                    }
                }
                //Set Video Source:Desktop.
                VideoSrc.SetInput("ScreenCapture1", "ScreenCap", "");
                IWMEncProfileCollection ProfileCollection = DesktopEncoder.ProfileCollection;
                ProfileCollection = DesktopEncoder.ProfileCollection;
                int lLength = ProfileCollection.Count;
                //Set Profile.
                if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")
                {
                    IWMEncBroadcast broadcast = DesktopEncoder.Broadcast;
                    broadcast.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, Convert.ToInt32(txtPortNbr.Text.Trim()));
                    for (int i = 0; i <= lLength - 1; i++)
                    {
                        SelProfile = ProfileCollection.Item(i);
                        if (SelProfile.Name == "Windows Media Video 8 for Local Area Network (768 Kbps)")
                        {
                            SrcGroup.set_Profile((IWMEncProfile)SelProfile);
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i <= lLength - 1; i++)
                    {
                        SelProfile = ProfileCollection.Item(i);
                        if (SelProfile.Name == "Screen Video/Audio High (CBR)")
                        {
                            SrcGroup.set_Profile((IWMEncProfile)SelProfile);
                            break;
                        }
                    }
                }
                //Local File to Store Recording temporarily.
                IWMEncFile inputFile = DesktopEncoder.File;
                inputFile.LocalFileName = "C:\\TempRecording.wmv";
                DesktopEncoder.PrepareToEncode(true);
                DesktopEncoder.Start();
                tmrRcCounter.Enabled = true;
                recordStarttime      = DateTime.Now;
                if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")
                {
                    //Start Timer to Count Viewers connected to Broadcast.
                    tmrViewerCount.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }