Пример #1
0
 //Fade in boss music
 void fadeIn()
 {
     if (audio2Volume < 1f)
     {
         audio2Volume += 0.4f * Time.deltaTime;
         audioListener.GetComponent <AudioSource>().volume = audio2Volume;
     }
 }
Пример #2
0
        protected AudioSource PlaySound(AudioClip clip, float volume, float pitch)
        {
            //apply global sound config

            volume *= Xft.GlobalConfig.SoundVolume;

            if (clip != null)
            {
                if (m_Listener == null)
                {
                    m_Listener = GameObject.FindObjectOfType(typeof(AudioListener)) as AudioListener;

                    if (m_Listener == null)
                    {
                        Camera cam = Camera.main;
                        if (cam == null)
                        {
                            cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
                        }
                        if (cam != null)
                        {
                            m_Listener = cam.gameObject.AddComponent <AudioListener>();
                        }
                    }
                }

                if (m_Listener != null)
                {
                    AudioSource source = m_Listener.GetComponent <AudioSource>();
                    if (source == null)
                    {
                        source = m_Listener.gameObject.AddComponent <AudioSource>();
                    }
                    source.pitch = pitch;

                    source.loop = m_owner.IsSoundLoop;

                    if (!m_owner.IsSoundLoop)
                    {
                        source.PlayOneShot(clip, volume);
                    }
                    else
                    {
                        source.clip   = clip;
                        source.volume = volume;
                        source.Play();
                    }

                    //Debug.LogWarning(GameTools.GetPath(m_owner.gameObject.transform));



                    return(source);
                }
            }
            return(null);
        }
Пример #3
0
    /// <summary>
    /// Play the specified audio clip with the specified volume.
    /// </summary>

    static public AudioSource PlaySound(AudioClip clip, float volume)
    {
        if (clip != null)
        {
            if (mListener == null)
            {
                mListener = GameObject.FindObjectOfType(typeof(AudioListener)) as AudioListener;

                if (mListener == null)
                {
                    Camera cam = Camera.main;
                    if (cam == null)
                    {
                        cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
                    }
                    if (cam != null)
                    {
                        mListener = cam.gameObject.AddComponent <AudioListener>();
                    }
                }
            }

            if (mListener != null)
            {
                AudioSource source = mListener.GetComponent <AudioSource>();
                if (source == null)
                {
                    source = mListener.gameObject.AddComponent <AudioSource>();
                }
                source.PlayOneShot(clip, volume);
                return(source);
            }
        }
        return(null);
    }
        /**
         * Updates the current remote audio listener. We need to attach a component to the game object
         * marked as the remote audio listener. It is possible to swap audio listeners at runtime.
         * We disable the attached component on the object that is no longer active. Either parameter
         * can be null.
         */
        public void UpdateAudioListener(AudioListener previouslistener, AudioListener newlistener)
        {
            CastRemoteDisplayAudioInterceptor previousInterceptor =
                previouslistener == null ? null :
                previouslistener.GetComponent <CastRemoteDisplayAudioInterceptor>();
            CastRemoteDisplayAudioInterceptor newInterceptor =
                newlistener == null ? null :
                newlistener.GetComponent <CastRemoteDisplayAudioInterceptor>();

            // If we have a valid listener that doesn't have an interceptor yet, add it.
            if (newInterceptor == null && newlistener != null)
            {
                newInterceptor = newlistener.gameObject.AddComponent <CastRemoteDisplayAudioInterceptor>();
            }

            if (previousInterceptor != null && previousInterceptor != newInterceptor)
            {
                previousInterceptor.enabled = false;
            }

            if (newInterceptor != null)
            {
                newInterceptor.SetCastRemoteDisplayExtensionManager(this);
                newInterceptor.enabled = true;
            }
        }
Пример #5
0
 public static AudioSource PlaySound(AudioClip clip, float volume, float pitch)
 {
     volume *= soundVolume;
     if ((clip != null) && (volume > 0.01f))
     {
         if (mListener == null)
         {
             mListener = UnityEngine.Object.FindObjectOfType(typeof(AudioListener)) as AudioListener;
             if (mListener == null)
             {
                 Camera main = Camera.main;
                 if (main == null)
                 {
                     main = UnityEngine.Object.FindObjectOfType(typeof(Camera)) as Camera;
                 }
                 if (main != null)
                 {
                     mListener = main.gameObject.AddComponent <AudioListener>();
                 }
             }
         }
         if (((mListener != null) && mListener.enabled) && GetActive(mListener.gameObject))
         {
             AudioSource audio = mListener.GetComponent <AudioSource>();
             if (audio == null)
             {
                 audio = mListener.gameObject.AddComponent <AudioSource>();
             }
             audio.pitch = pitch;
             audio.PlayOneShot(clip, volume);
             return(audio);
         }
     }
     return(null);
 }
Пример #6
0
    /// <summary>
    /// Play the specified audio clip with the specified volume and pitch.
    /// </summary>

    static public AudioSource PlaySound(AudioClip clip, float volume, float pitch)
    {
        //add by Alex 20150423
        if (!SG.CoreEntry.cfg_bEaxToggle)
        {
            return(null);
        }
        volume *= soundVolume;

        if (clip != null && volume > 0.01f)
        {
            if (mListener == null || !NGUITools.GetActive(mListener))
            {
                AudioListener[] listeners = GameObject.FindObjectsOfType(typeof(AudioListener)) as AudioListener[];

                if (listeners != null)
                {
                    for (int i = 0; i < listeners.Length; ++i)
                    {
                        if (NGUITools.GetActive(listeners[i]))
                        {
                            mListener = listeners[i];
                            break;
                        }
                    }
                    //by lzp
                    if (listeners.Length == 0)
                    {
                        mListener = null;
                    }
                }
                if (mListener == null)
                {
                    Camera cam = Camera.main;
                    if (cam == null)
                    {
                        cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
                    }
                    if (cam != null)
                    {
                        mListener = cam.gameObject.AddComponent <AudioListener>();
                    }
                }
            }

            if (mListener != null && mListener.enabled && NGUITools.GetActive(mListener.gameObject))
            {
                AudioSource source = mListener.GetComponent <AudioSource>();
                if (source == null)
                {
                    source = mListener.gameObject.AddComponent <AudioSource>();
                }
                source.pitch = pitch;
                source.PlayOneShot(clip, volume);
                return(source);
            }
        }
        return(null);
    }
Пример #7
0
    /// <summary>
    /// Play the specified audio clip with the specified volume and pitch.
    /// </summary>

    static public AudioSource PlaySound(AudioClip clip, float volume, float pitch)
    {
        float time = Time.time;

        if (mLastClip == clip && mLastTimestamp + 0.1f > time)
        {
            return(null);
        }

        mLastClip      = clip;
        mLastTimestamp = time;
        volume        *= soundVolume;

        if (clip != null && volume > 0.01f)
        {
            if (mListener == null || !mListener.gameObject.activeInHierarchy)
            {
                AudioListener[] listeners = GameObject.FindObjectsOfType(typeof(AudioListener)) as AudioListener[];

                if (listeners != null)
                {
                    for (int i = 0; i < listeners.Length; ++i)
                    {
                        if (listeners[i].gameObject.activeInHierarchy)
                        {
                            mListener = listeners[i];
                            break;
                        }
                    }
                }

                if (mListener == null)
                {
                    Camera cam = Camera.main;
                    if (cam == null)
                    {
                        cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
                    }
                    if (cam != null)
                    {
                        mListener = cam.gameObject.AddComponent <AudioListener>();
                    }
                }
            }

            if (mListener != null && mListener.enabled && mListener.gameObject.activeInHierarchy)
            {
                AudioSource source = mListener.GetComponent <AudioSource>();
                if (source == null)
                {
                    source = mListener.gameObject.AddComponent <AudioSource>();
                }
                source.PlayOneShot(clip, volume);
                return(source);
            }
        }
        return(null);
    }
Пример #8
0
    /// <summary>
    /// Play the specified audio clip with the specified volume and pitch.
    /// </summary>

    static public AudioSource PlaySound(AudioClip clip, float volume, float pitch)
    {
        volume *= soundVolume;

        if (clip != null && volume > 0.01f)
        {
            if (mListener == null || !NGUITools.GetActive(mListener))
            {
                AudioListener[] listeners = GameObject.FindObjectsOfType(typeof(AudioListener)) as AudioListener[];

                if (listeners != null)
                {
                    for (int i = 0; i < listeners.Length; ++i)
                    {
                        if (NGUITools.GetActive(listeners[i]))
                        {
                            mListener = listeners[i];
                            break;
                        }
                    }
                }

                if (mListener == null)
                {
                    Camera cam = Camera.main;
                    if (cam == null)
                    {
                        cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
                    }
                    if (cam != null)
                    {
                        mListener = cam.gameObject.AddComponent <AudioListener>();
                    }
                }
            }

            if (mListener != null && mListener.enabled && NGUITools.GetActive(mListener.gameObject))
            {
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
                AudioSource source = mListener.audio;
#else
                AudioSource source = mListener.GetComponent <AudioSource>();
#endif
                if (source == null)
                {
                    source = mListener.gameObject.AddComponent <AudioSource>();
                }
#if !UNITY_FLASH
                source.priority = 50;
                source.pitch    = pitch;
#endif
                source.PlayOneShot(clip, volume);
                return(source);
            }
        }
        return(null);
    }
Пример #9
0
    IEnumerator Fade()
    {
        fade.SetBool("fade", true);
        yield return(new WaitForSeconds(1.5f));

        SceneManager.UnloadSceneAsync("SplashScreen");
        SceneManager.LoadScene("Menu");
        Cam.depth = -100;
        AudioL.GetComponent <AudioListener>().enabled = (false);
    }
Пример #10
0
    public static AudioSource PlaySound(AudioClip clip, float volume, float pitch)
    {
        float time = Time.time;

        if ((UnityEngine.Object)mLastClip == (UnityEngine.Object)clip && mLastTimestamp + 0.1f > time)
        {
            return(null);
        }
        mLastClip      = clip;
        mLastTimestamp = time;
        volume        *= soundVolume;
        if ((UnityEngine.Object)clip != null && volume > 0.01f)
        {
            if (mListener == null || !GetActive(mListener))
            {
                AudioListener[] array = UnityEngine.Object.FindObjectsOfType(typeof(AudioListener)) as AudioListener[];
                if (array != null)
                {
                    for (int i = 0; i < array.Length; i++)
                    {
                        if (GetActive(array[i]))
                        {
                            mListener = array[i];
                            break;
                        }
                    }
                }
                if (mListener == null)
                {
                    Camera camera = Camera.main;
                    if (camera == null)
                    {
                        camera = (UnityEngine.Object.FindObjectOfType(typeof(Camera)) as Camera);
                    }
                    if (camera != null)
                    {
                        mListener = camera.gameObject.AddComponent <AudioListener>();
                    }
                }
            }
            if (mListener != null && mListener.enabled && GetActive(mListener.gameObject))
            {
                AudioSource val = mListener.GetComponent <AudioSource>();
                if ((UnityEngine.Object)val == null)
                {
                    val = mListener.gameObject.AddComponent <AudioSource>();
                }
                val.priority = 50;
                val.pitch    = pitch;
                val.PlayOneShot(clip, volume);
                return(val);
            }
        }
        return(null);
    }
Пример #11
0
    void Start()
    {
        Debug.Log("entered start");
        //GetComponent<MeshRenderer>().material.color = color;
        if (isLocalPlayer)
        {
            /*   Debug.Log("entered islocalplayer");
             * for (int i = 0; i < 3; i++)
             * {
             *     transform.GetChild(i).gameObject.SetActive(false);
             * }
             * transform.GetChild(charindex).gameObject.SetActive(true);
             *
             * charobject = charobject.transform.GetChild(charindex).gameObject;*/
            // Debug.Log("name");
            //Debug.Log(charobject.name); // blir rätt djur atm


            /*joystick = charobject.GetComponentInChildren<PlayerController>().joystick;
             * _rigidbody = charobject.GetComponentInChildren<PlayerController>()._rigidbody;
             * anim = charobject.GetComponentInChildren<PlayerController>().anim;
             * myJoyCanvas = charobject.GetComponentInChildren<PlayerController>().myJoyCanvas;
             * myButtonCanvas = charobject.GetComponentInChildren<PlayerController>().myButtonCanvas;
             * AL = charobject.GetComponentInChildren<PlayerController>().AL;
             * BS = charobject.GetComponentInChildren<PlayerController>().BS;*/

            joystick = joystick.GetComponent <Joystick>();
            //_rigidbody = _rigidbody.GetComponent<Rigidbody>();
            anim           = anim.GetComponent <Animator>();
            myJoyCanvas    = myJoyCanvas.GetComponent <Canvas>();
            myButtonCanvas = myButtonCanvas.GetComponent <Canvas>();
            AL             = AL.GetComponent <AudioListener>();


            //AL = charobject.GetComponent<AudioListener>();
            AL.enabled = true;
            Debug.Log("joyname");
            Debug.Log(myJoyCanvas.gameObject.name); // blir rätt djur atm

            myJoyCanvas.gameObject.SetActive(true);
            myButtonCanvas.gameObject.SetActive(true);

            /*
             * //camera setup
             * Camera.main.transform.position = transform.position - transform.forward * 10 + transform.up * 3;
             * Camera.main.transform.LookAt(transform.position);
             * Camera.main.transform.parent = transform;*/
            //enable canvas element for right player
        }
    }
Пример #12
0
        private BattleSFXAudioSource GetSFXAudioSource()
        {
            BattleSFXAudioSource source = m_Listener.GetComponent <BattleSFXAudioSource>();

            if (source == null)
            {
                source = m_Listener.gameObject.AddComponent <BattleSFXAudioSource>();
                source.Init(audioMixerGroups);
            }
            return(source);
        }
Пример #13
0
 public static AudioSource PlaySound(AudioClip clip, float volume, float pitch)
 {
     volume *= soundVolume;
     if (clip != null && volume > 0.01f)
     {
         if (mListener == null || !GetActive(mListener))
         {
             AudioListener[] array = UnityEngine.Object.FindObjectsOfType(typeof(AudioListener)) as AudioListener[];
             if (array != null)
             {
                 for (int i = 0; i < array.Length; i++)
                 {
                     if (GetActive(array[i]))
                     {
                         mListener = array[i];
                         break;
                     }
                 }
             }
             if (mListener == null)
             {
                 Camera camera = Camera.main;
                 if (camera == null)
                 {
                     camera = (UnityEngine.Object.FindObjectOfType(typeof(Camera)) as Camera);
                 }
                 if (camera != null)
                 {
                     mListener = camera.gameObject.AddComponent <AudioListener>();
                 }
             }
         }
         if (mListener != null && mListener.enabled && GetActive(mListener.gameObject))
         {
             AudioSource audioSource = mListener.GetComponent <AudioSource>();
             if (audioSource == null)
             {
                 audioSource = mListener.gameObject.AddComponent <AudioSource>();
             }
             audioSource.pitch = pitch;
             audioSource.PlayOneShot(clip, volume);
             return(audioSource);
         }
     }
     return(null);
 }
Пример #14
0
        protected override void Awake()
        {
            base.Awake();
            AudioListener audioListener = FindObjectOfType <AudioListener>();

            if (audioListener != null)
            {
                this.ac = audioListener.GetComponent <AudioOutCapture>();
                if (this.ac == null)
                {
                    this.ac = audioListener.gameObject.AddComponent <AudioOutCapture>();
                }
            }
            else if (this.Logger.IsErrorEnabled)
            {
                this.Logger.LogError("AudioListener component is required");
            }
        }
Пример #15
0
    /// <summary>
    /// Play the specified audio clip with the specified volume and pitch.
    /// </summary>

    static public AudioSource PlaySound(AudioClip clip, float volume, float pitch)
    {
        // 配置项名字写反了 实际上意思是关闭音效
        if (PlayerPreferenceData.SystemSoundEffect == 0)
        {
            return(null);
        }

        volume *= soundVolume;

        if (clip != null && volume > 0.01f)
        {
            if (mListener == null)
            {
                mListener = GameObject.FindObjectOfType(typeof(AudioListener)) as AudioListener;

                if (mListener == null)
                {
                    Camera cam = Camera.main;
                    if (cam == null)
                    {
                        cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
                    }
                    if (cam != null)
                    {
                        mListener = cam.gameObject.AddComponent <AudioListener>();
                    }
                }
            }

            if (mListener != null && mListener.enabled && NGUITools.GetActive(mListener.gameObject))
            {
                AudioSource source = mListener.GetComponent <AudioSource>();
                if (source == null)
                {
                    source = mListener.gameObject.AddComponent <AudioSource>();
                }
                source.pitch = pitch;
                source.PlayOneShot(clip, volume);
                return(source);
            }
        }
        return(null);
    }
Пример #16
0
        public void InitAudioSource()
        {
            if (audio == null)
            {
                Camera        cam       = GetComponent <Camera>();
                AudioListener mListener = cam.GetComponent <AudioListener>();

                if (cam != null && mListener == null)
                {
                    mListener = cam.gameObject.AddComponent <AudioListener>();
                }

                AudioSource source = mListener.GetComponent <AudioSource>();
                if (source == null)
                {
                    source = mListener.gameObject.AddComponent <AudioSource>();
                }
            }
        }
Пример #17
0
	/// <summary>
	/// Play the specified audio clip with the specified volume and pitch.
	/// </summary>

	static public AudioSource PlaySound (AudioClip clip, float volume, float pitch)
	{
		volume *= soundVolume;

		if (clip != null && volume > 0.01f)
		{
			if (mListener == null || !NGUITools.GetActive(mListener))
			{
				AudioListener[] listeners = GameObject.FindObjectsOfType(typeof(AudioListener)) as AudioListener[];

				if (listeners != null)
				{
					for (int i = 0; i < listeners.Length; ++i)
					{
						if (NGUITools.GetActive(listeners[i]))
						{
							mListener = listeners[i];
							break;
						}
					}
				}

				if (mListener == null)
				{
					Camera cam = Camera.main;
					if (cam == null) cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
					if (cam != null) mListener = cam.gameObject.AddComponent<AudioListener>();
				}
			}

			if (mListener != null && mListener.enabled && NGUITools.GetActive(mListener.gameObject))
			{
				AudioSource source = mListener.GetComponent<AudioSource>();
				if (source == null) source = mListener.gameObject.AddComponent<AudioSource>();
				source.pitch = pitch;
				source.PlayOneShot(clip, volume);
				return source;
			}
		}
		return null;
	}
Пример #18
0
    public bool Init()
    {
        Camera cam = Camera.main;

        if (cam == null)
        {
            cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
        }
        AudioListener mListener = cam.gameObject.GetComponent <AudioListener>();

        if (mListener == null)
        {
            if (cam != null)
            {
                mListener = cam.gameObject.AddComponent <AudioListener>();
            }
        }
        //#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
        //        BGAudio = mListener.audio;
        //#else
        LoopAudio = mListener.GetComponent <AudioSource>();
        //#endif
        if (LoopAudio == null)
        {
            LoopAudio = mListener.gameObject.AddComponent <AudioSource>();
        }
        LoopAudio_1    = mListener.gameObject.AddComponent <AudioSource>();
        LoopAudio_Gift = mListener.gameObject.AddComponent <AudioSource>();
        InitLogic.StartInit();
        SceneMain.Instance.StartInnerCoroutine(Initaudio(null));
        LoadAudioValue();
        SetBGMusicVolue(m_BgValue);
        SetMusicVolue(m_Value);
        //int bg = Random.Range(4, 7);
        int bg = 1;

        GlobalAudioMgr.Instance.PlayerBGMusic(Audio.EffectBGType.EffectBGSound2);

        //GlobalAudioMgr.Instance.PlayerBGMusic(GlobalAudioMgr.BGMusic.BgMusic0);
        return(true);
    }
Пример #19
0
    /// <summary>
    /// Play the specified audio clip with the specified volume and pitch.
    /// PlaySound was copied from NGUI
    /// </summary>
    static public AudioSource PlaySound(AudioClip clip, float volume = 1f, float pitch = 1f)
    {
        volume *= 1f;

        if (clip != null && volume > 0.01f)
        {
            if (mListener == null)
            {
                mListener = GameObject.FindObjectOfType(typeof(AudioListener)) as AudioListener;

                if (mListener == null)
                {
                    Camera cam = Camera.main;
                    if (cam == null)
                    {
                        cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
                    }
                    if (cam != null)
                    {
                        mListener = cam.gameObject.AddComponent <AudioListener>();
                    }
                }
            }

            if (System.DateTime.Now > PlayerTouch.timeLastClipEnds && // wait for last clip to play through
                mListener != null && mListener.enabled && mListener.gameObject.activeInHierarchy)
            {
                PlayerTouch.timeLastClipEnds = System.DateTime.Now.AddSeconds(clip.length);
                AudioSource source = mListener.GetComponent <AudioSource>();
                if (source == null)
                {
                    source = mListener.gameObject.AddComponent <AudioSource>();
                }
                source.pitch = pitch;
                source.PlayOneShot(clip, volume);
                return(source);
            }
        }
        return(null);
    }
Пример #20
0
    /// <summary>
    /// Play the specified audio clip with the specified volume and pitch.
    /// </summary>

    static public AudioSource PlaySound(AudioClip clip, float volume, float pitch)
    {
        volume *= soundVolume;

        if (clip != null && volume > 0.01f)
        {
            if (mListener == null)
            {
                mListener = GameObject.FindObjectOfType(typeof(AudioListener)) as AudioListener;

                if (mListener == null)
                {
                    Camera cam = Camera.main;
                    if (cam == null)
                    {
                        cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
                    }
                    if (cam != null)
                    {
                        mListener = cam.gameObject.AddComponent <AudioListener>();
                    }
                }
            }

            if (mListener != null && mListener.enabled && NGUITools.GetActive(mListener.gameObject))
            {
                AudioSource source = mListener.GetComponent <AudioSource>();
                if (source == null)
                {
                    source = mListener.gameObject.AddComponent <AudioSource>();
                }
                source.pitch = pitch;
                source.PlayOneShot(clip, volume);
                return(source);
            }
        }
        return(null);
    }
Пример #21
0
        private void Init()
        {
            if (mListener == null || !mListener.gameObject.activeSelf)
            {
                AudioListener[] listeners = GameObject.FindObjectsOfType(typeof(AudioListener)) as AudioListener[];

                if (listeners != null)
                {
                    for (int i = 0; i < listeners.Length; ++i)
                    {
                        if (listeners[i].gameObject.activeSelf)
                        {
                            mListener = listeners[i];
                            break;
                        }
                    }
                }

                if (mListener == null)
                {
                    Camera cam = Camera.main;
                    if (cam == null)
                    {
                        cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
                    }
                    if (cam != null)
                    {
                        mListener = cam.gameObject.AddComponent <AudioListener>();
                    }
                }

                AudioSource source = mListener.GetComponent <AudioSource>();
                if (source == null)
                {
                    mListener.gameObject.AddComponent <AudioSource>();
                }
            }
        }
Пример #22
0
 /// <summary>
 /// Play an AudioClip.
 /// </summary>
 /// <param name="clip">Clip.</param>
 /// <param name="volume">Volume.</param>
 public static void PlaySound(AudioClip clip, float volume)
 {
     if (clip == null)
     {
         return;
     }
     if (audioSource == null)
     {
         AudioListener listener = GameObject.FindObjectOfType <AudioListener> ();
         if (listener != null)
         {
             audioSource = listener.GetComponent <AudioSource> ();
             if (audioSource == null)
             {
                 audioSource = listener.gameObject.AddComponent <AudioSource> ();
             }
         }
     }
     if (audioSource != null)
     {
         audioSource.PlayOneShot(clip, volume);
     }
 }
Пример #23
0
        private bool SetOrSwitchAudioListener(AudioListener audioListener, bool extraChecks)
        {
            if (audioListener == null)
            {
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.LogError("audioListener passed is null or is being destroyed");
                }
                return(false);
            }
            if (extraChecks)
            {
                if (audioListener.gameObject.activeInHierarchy)
                {
                    if (this.Logger.IsErrorEnabled)
                    {
                        this.Logger.LogError("The GameObject to which the audioListener is attached is not active in hierarchy");
                    }
                    return(false);
                }
                if (!audioListener.enabled)
                {
                    if (this.Logger.IsErrorEnabled)
                    {
                        this.Logger.LogError("audioListener passed is disabled");
                    }
                    return(false);
                }
            }
            AudioOutCapture audioOutCapture = audioListener.GetComponent <AudioOutCapture>();

            if (audioOutCapture == null)
            {
                audioOutCapture = audioListener.gameObject.AddComponent <AudioOutCapture>();
            }
            return(this.SetOrSwitchAudioOutCapture(audioOutCapture, false));
        }
Пример #24
0
    // Update is called once per frame
    void Update()
    {
        if (!PlayerPrefs.HasKey(musicVolumeKey))
        {
            PlayerPrefs.SetFloat(musicVolumeKey, defaultMusicVolume);
        }
        battleMusic.volume = PlayerPrefs.GetFloat(musicVolumeKey);

        if (newGame)
        {
            ResetSettings();
        }

        //Refresh Enemies
        enemies = GetAllEnemies();

        //Refresh Players
        players = GetAllPlayers();

        //Set livePlayers to 0 so the count will be accurate
        livePlayers = 0;

        //loop through all players
        for (int player = 0; player < players.Count; player++)
        {
            //check if the player exists
            if (players[player] != null)
            {
                //incrememnt the numbewr of live players
                livePlayers++;
            }
        }

        //check if any players are alive
        switch (numOfPlayers)
        {
        case 1:
            if (livePlayers == 0 && player1Lives == 0)
            {
                PlayerPrefs.SetInt("PlayerOneScore", player1Score);
                UpdateScores();
                DisplayGameOver();
            }
            break;

        case 2:
            if (livePlayers == 0 && player1Lives == 0 && player2Lives == 0)
            {
                PlayerPrefs.SetInt("PlayerOneScore", player1Score);
                PlayerPrefs.SetInt("PlayerTwoScore", player2Score);
                UpdateScores();
                DisplayGameOver();
            }
            break;

        default:
            break;
        }


        //set liveEnemies to 0 so the count will be accurate
        liveEnemies = 0;

        //loop through all enemies
        for (int enemy = 0; enemy < enemies.Count; enemy++)
        {
            //check if the enemy exists
            if (enemies[enemy] != null)
            {
                //incrmement live enemies
                liveEnemies++;
            }
        }

        SpawnEnemies();

        UpdatePlayerExistsStatus();

        if (players.Count < numOfPlayers)
        {
            switch (numOfPlayers)
            {
            case 1:
                if (!playerOneExists && player1Lives > 0)
                {
                    SpawnPlayer(1);
                }
                break;

            case 2:
                if (!playerOneExists && player1Lives > 0)
                {
                    SpawnPlayer(1);
                }

                if (!playerTwoExists && player2Lives > 0)
                {
                    SpawnPlayer(2);
                }
                break;
            }
        }

        AudioSource source = audio.GetComponent <AudioSource>();

        if (source != null)
        {
            if (PlayerPrefs.HasKey("Volume"))
            {
                source.volume = PlayerPrefs.GetFloat("Volume");
            }
        }

        SetupCameras();

        foreach (GameObject player in players)
        {
            TankData          playerTankData          = player.GetComponent <TankData>();
            PowerupController playerPowerupController = player.GetComponent <PowerupController>();

            if (playerTankData != null)
            {
                if (playerTankData.type == TankData.TankType.Player_1)
                {
                    playerOne     = player;
                    playerOneData = playerTankData;

                    if (playerPowerupController != null)
                    {
                        playerOnePowerupController = playerPowerupController;
                    }
                }
                else if (playerTankData.type == TankData.TankType.Player_2)
                {
                    playerTwo     = player;
                    playerTwoData = playerTankData;

                    if (playerPowerupController != null)
                    {
                        playerTwoPowerupController = playerPowerupController;
                    }
                }
            }
        }

        UpdateUI();
    }
    // This function is called when the "Start" button is pressed.
    public void StartVideoRecording()
    {
        if (isRecording)
        {
            return;
        }

        // Select the cameras and audio listener we're going to record.
        // We can record video from multiple cameras, but there is always just a
        // single audio listener we capture.
        if (mainCamera != null && (videoSourceState == VideoSource.Main_Camera ||
                                   videoSourceState == VideoSource.Both_Cameras))
        {
            // Record from the main camera and main listener.
            vrCap = (iVidCapProVideo)mainCamera.GetComponent <iVidCapProVideo>();
            if (mainListener != null)
            {
                arCap = (iVidCapProAudio)mainListener.GetComponent <iVidCapProAudio>();
            }
            // Enable video capture from this camera.
            vrCap.enabled = true;
        }

        if (secondaryCamera != null && (videoSourceState == VideoSource.Secondary_Camera ||
                                        videoSourceState == VideoSource.Both_Cameras))
        {
            // Record from the secondary camera.  First, turn it on.
            secondaryCamera.enabled = true;
            vrCap = (iVidCapProVideo)secondaryCamera.GetComponent <iVidCapProVideo>();
            // Use the secondary audio listener if we're recording solely from the secondary camera.
            if (secondaryListener != null && videoSourceState == VideoSource.Secondary_Camera)
            {
                arCap = (iVidCapProAudio)secondaryListener.GetComponent <iVidCapProAudio>();
                if (mainListener != null)
                {
                    // Now turn off the main audio listener.  We want to use the secondary listener.
                    // We keep the main camera enabled because it is used to show the user's view.
                    mainListener.enabled = false;
                }
                secondaryListener.enabled = true;
            }
            // Enable video capture from this camera.
            vrCap.enabled = true;
        }


        isRecording = true;

        vrController.SetDebug(showDebug);

        // Set the desired video dimensions.
        //vidWidth  = videoWidths[videoSizeState];
        //vidHeight = videoHeights[videoSizeState];
        vidWidth  = (Screen.width * videoSizeMultiplier[(int)videoSizeState]) / videoSizeDivider[(int)videoSizeState];
        vidHeight = (Screen.height * videoSizeMultiplier[(int)videoSizeState]) / videoSizeDivider[(int)videoSizeState];

        // Testing full HD recording...
        //vidWidth = 1920;
        //vidHeight = 1080;

        // Testing tiny recording...
        //vidWidth = 128;
        //vidHeight =128;

        // Testing unsupported frame size.
        //vidWidth = 2048;
        //vidHeight = 1536;

        // Temporary hack - Limit video size to max allowed size for iPad3/4.
        // Preserve aspect ratio.
        if (vidWidth == 2048)
        {
            vidWidth  = 1440;
            vidHeight = 1080;
        }
        else if (vidHeight == 2048)
        {
            vidHeight = 1440;
            vidWidth  = 1080;
        }

        // Do we want to record the video from a custom rendertexture instead
        // of a camera?
        if (customRenderTexture != null && videoSourceState == VideoSource.Custom_RenderTexture)
        {
            // Set the rendertexture and override the UI specified frame size.
            vrController.SetCustomRenderTexture(customRenderTexture);
            vidWidth  = customRenderTexture.width;
            vidHeight = customRenderTexture.height;
            if (mainListener != null)
            {
                arCap = (iVidCapProAudio)mainListener.GetComponent <iVidCapProAudio>();
            }
        }
        else
        {
            // Be sure to reset custom rendertexture when we're not using it.
            vrController.SetCustomRenderTexture(null);
        }

        // Enable audio capture.
        if (arCap != null)
        {
            vrController.saveAudio = arCap;
            arCap.enabled          = true;
        }


        // Register a delegate in case an error occurs during the recording session.
        vrController.RegisterSessionErrorDelegate(HandleSessionError);

        // Register a delegate to be called when the video is complete.
        vrController.RegisterSessionCompleteDelegate(HandleSessionComplete);

        // Configure video quality settings. This method call is optional.
        // You would only use it if you want to set the video compression settings
        // to non-default values.
        vrController.ConfigureVideoSettings(bitsPerSecond, keyframeInterval);

        // Configure gamma setting. This method call is optional.
        // You would only use it if you want to tweak the gamma setting for the
        // output video.  Because gamma adjustment is computationally expensive,
        // do not invoke this function unless you really need it.
        if (gammaCorrection <= 0.9f || gammaCorrection >= 1.1f)
        {
            vrController.ConfigureGammaSetting(gammaCorrection);
        }
        else
        {
            vrController.ConfigureGammaSetting(-1.0f);
        }

        // Has audio recording from the scene been requested from the GUI?
        iVidCapPro.CaptureAudio audioSetting = iVidCapPro.CaptureAudio.No_Audio;
        if (arCap != null && (audioSourceState == AudioSource.Scene ||
                              audioSourceState == AudioSource.All))
        {
            audioSetting = iVidCapPro.CaptureAudio.Audio;
            // audioSetting = iVidCapPro.CaptureAudio.Audio_Plus_Mic;
        }

        // Tell video recorder to begin a recording session and start recording.
        iVidCapPro.SessionStatusCode status = vrController.BeginRecordingSession(
            "SampleVideo",                                         // file name; only relevant if saving to Documents
            vidWidth, vidHeight,                                   // frame size
            captureFramerate,                                      // frame rate; NOT USED when captureType is Unlocked
            audioSetting,                                          // do we want to record audio
            captureType                                            // type of capture (see docs for details)
            );

        if (status == iVidCapPro.SessionStatusCode.OK)
        {
            // Display a message to tell the user recording is in progress.
            ShowMessage("Recording...", 9999.0f);
        }
        else
        {
            ShowMessage("Recording session failed!  Reason: " + status, 15.0f);
        }
    }
Пример #26
0
    // Use this for initialization
    void Start()
    {
        //自分が操作するオブジェクトに限定する
        if (isLocalPlayer)
        {
            //自分のプレイヤーの名前変更
            //name = GameObject.Find("CharactorInfo").GetComponent<CharactorInfo>().GetPlayerName();
            //name = "Player";

            //自分を操作するぷにコンに自分自身を伝える。
            PunipuniController punipuni = GameObject.Find("PuniconCamera/Punicon").GetComponent <PunipuniController>();
            punipuni.SetPlayer(this.gameObject);

            //ローディングイメージのアクティブを切る
            if (GameObject.Find("OnlineCanvas/LoadingImage") != null)
            {
                GameObject.Find("OnlineCanvas/LoadingImage").SetActive(false);
            }

            //PlayerCameraを使うため、Scene Cameraを非アクティブ化
            GameObject cam = GameObject.Find("Scene Camera");
            if (null != cam)
            {
                cam.SetActive(false);
            }

            //Camera,AudioListenerの各コンポーネントをアクティブ化
            PlayerCamera.GetComponent <Camera>().enabled         = true;
            audioListener.GetComponent <AudioListener>().enabled = true;

            //LocalPlayerのAnimatorパラメータを自動的に送る
            GetComponent <NetworkAnimator>().SetParameterAutoSend(0, true);

            //カメラの取得等があるため、ここでPostureControllerのスクリプトをOnにしてStartメソッド呼び出し。
            GetComponent <OfflinePostureController>().enabled = true;

            //ミッションマネージャに自分がスポーンした事を知らせる。
            GameObject.Find("NetworkMissionManager").GetComponent <NetworkMissionManager>().SetPlayer(this.gameObject);


            netConnector = GameObject.Find("NetConnector").GetComponent <NetConnector>();
            if (null != netConnector)
            {
                netConnector.SetLocalPlayer(gameObject);
            }

            charaInfo = GameObject.Find("CharactorInfo").GetComponent <CharactorInfo>();

            if (null != charaInfo)
            {
                // SendName(charaInfo.GetPlayerName());
                //playerName.SetNameText(charaInfo.GetPlayerName());
                useChara = charaInfo.GetCharaSelectData();
            }

            skyBg.gameObject.SetActive(true);
            //接続時のローディングイメージを有効
//            GameObject.Find("OnlineCanvas/LoadingImage").SetActive(false);

            netConnector.createPlayer = true;
        }
        else
        {
            //自分以外の移動スクリプトを切る
            GetComponent <OfflinePostureController>().enabled    = false;
            PlayerCamera.GetComponent <Camera>().enabled         = false;
            audioListener.GetComponent <AudioListener>().enabled = false;
            skyBg.gameObject.SetActive(false);
        }
    }
Пример #27
0
 void Update()
 {
     main.GetComponent <AudioSource>().volume = s;
 }