Stop() private method

private Stop ( ) : void
return void
コード例 #1
0
ファイル: MusicSingleton.cs プロジェクト: TeamTacoCat/DAWG
	void OnLevelWasLoaded(){

		source = GetComponent<AudioSource> ();

		if (GameManager.curScene == "MainMenu") {

			if (source.isPlaying ) {
			
				source.Stop ();
			
			}
			source.clip = songs [0];
			source.Play ();
		
		}else if(GameManager.curScene == "LevelLayout" || GameManager.curScene == "SinglePlayerLevel"){

			//if (source.clip != songs [1]) {
			
			source.Stop ();
			source.clip = songs [Random.Range(1, 3)];
			source.Play ();
			
			//}

		}

	}
コード例 #2
0
 private void StartSuccessSequence()
 {
     state = State.Transcending;
     audioSource.Stop();
     audioSource.PlayOneShot(success);
     successParticles.Play();
     Invoke("LoadNextLevel", levelLoadDelay); // parameterise time
 }
コード例 #3
0
    public float playVoiceOver(string voFile)
    {
        if (!voAudio)
        {
            return(0.0f);
        }
        voAudio.Stop();

        // TODO: Play this VO line now.
        // voAudio.PlayOneShot(...)
        return(5.0f);   // FIXME: Needs to return voAudio.clip.length instead.
    }
コード例 #4
0
ファイル: AudioCrossFader.cs プロジェクト: paulkelly/GGJ2016
        public static IEnumerator FadeAudio(AudioSource source, float targetVolume, float fadeTime)
        {
            if (source != null)
            {
                float time = 0;
                float startVolume = source.volume;
                float percComplete = 0;

                while (time < fadeTime)
                {
                    time += Mathf.Min(1/30f, Time.unscaledDeltaTime);

                    percComplete = time / fadeTime;
                    source.volume = Mathf.Lerp(startVolume, targetVolume, percComplete);

                    yield return null;
                }

                source.volume = targetVolume;

                if (targetVolume == 0)
                {
                    source.Stop();
                }
            }
        }
コード例 #5
0
ファイル: Bowling.cs プロジェクト: cambo2015/VirtuallyDone
    void sfx(bool coolBool,bool baddieHit)
    {
        AudioSource[] aSources = GetComponents <AudioSource>();//fix get array out of range[??]
        sound_Ball_roll = aSources[0];
        //knockedOver = aSources [1];
        Debug.Log ("length = " + aSources.Length);

        if(coolBool == true){
            sound_Ball_roll.Play();

            Debug.Log ("play sfx");
        }

        if( coolBool == false) {
            sound_Ball_roll.Stop();

            Debug.Log("stopped sfx");
        }

        if(baddieHit == true){
            //knockedOver.Play();
            Debug.Log ("knocked over played");

        }
        if(baddieHit == false){
            //knockedOver.Stop();

        }
    }
コード例 #6
0
ファイル: _StaticFunction.cs プロジェクト: lpointet/runblobby
    // Fonction utilisée pour diminuer le volume d'un son progressivement
    public static IEnumerator AudioFadeOut(AudioSource audio, float volumeMin = 0, float delay = 1)
    {
        if (audio == null || volumeMin > 1)
            yield break;

        if (volumeMin < 0)
            volumeMin = 0;

        if (delay == 0) {
            audio.volume = volumeMin;
            yield break;
        }

        while (audio.volume > volumeMin) {
            audio.volume -= TimeManager.deltaTime / delay;
            yield return null;
        }

        if (audio.volume < volumeMin) // On s'assure de ne pas aller plus bas que le volumeMin demandé
            audio.volume = volumeMin;

        if (audio.isPlaying) {
            audio.Stop (); // On stoppe le son lorsqu'on est au min demandé
        }
    }
コード例 #7
0
ファイル: MainTestPlayer.cs プロジェクト: dshpet/SpaceBeat
    //
    // Functions
    //
    // Use this for initialization
    void Awake()
    {
        lastTime = 0;

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

        analyzer = new MusicAnalyzer(
        audio.clip,
        sampleSize,
        soundFeed,
        beatSubbands,
        beatSensitivity,
        thresholdSize,
        thresholdMultiplier
          );

        while (!analyzer.Analyze())
          ; // make fancy rotation animation

        // debug
        var beats = analyzer.Beats;
        var detectedBeats = analyzer.m_soundParser.DetectedBeats;
        var thresholds = analyzer.Thresholds;

        audio.Play();
    }
コード例 #8
0
 IEnumerator StopSound(float time2wait, AudioSource rumble, float fadeTime)
 {
     yield return new WaitForSeconds(time2wait);
     rumble.DOFade(0, fadeTime).SetEase(soundCurve);
     yield return new WaitForSeconds(fadeTime);
     rumble.Stop();
 }
コード例 #9
0
    /* ----------------------------------------
     * At Start, set up movie texture and audio clip,
     * playing the video if required.
     */
    void Start()
    {
        // Assign AudioSource component to 'audio' variable
        audio = GetComponent<AudioSource> ();

        if (!video)
            // IF there is no Movie Texure assigned to 'video', THEN use the Movie Texture assigned to the material's main texture
            video = GetComponent<Renderer>().material.mainTexture as MovieTexture;

        if (!audioClip)
            // IF there is no Audio Clip assigned to 'audioClip', THEN use the audio clip assigned to object's Audio Source component
            audioClip = audio.clip;

        video.Stop ();

        audio.Stop ();

        // Assign 'loop' boolean value to Movie Texture's 'Loop' option
        video.loop = loop;

        // Assign 'loop' boolean value to Audio Source 'Loop' option
        audio.loop = loop;

        if(playFromStart)
            // IF 'playFromStart' is selected, THEN call ControlMovie function
            ControlMovie();
    }
コード例 #10
0
        protected IEnumerator<YieldInstruction> DoCrossFade(float duration)
        {
            if (fadeOutAudio != null)
            {
                fadeOutAudio.Stop();
                Destroy(fadeOutAudio);
                fadeOutAudio = null;
            }

            fadeOutAudio = (AudioSource)UnityEngine.Object.Instantiate(audio1);

            float startTime = Time.time;
            float endTime = startTime + duration;
            while (Time.time < endTime)
            {
                float ratio = (Time.time - startTime) / duration;
                audio1.volume = GameSettings.MUSIC_VOLUME * (1.0f - ratio);
                fadeOutAudio.volume = GameSettings.MUSIC_VOLUME * (ratio);
                yield return null;
            }
            audio1.volume = GameSettings.MUSIC_VOLUME;
            fadeOutAudio.Stop();
            Destroy(fadeOutAudio);
            fadeOutAudio = null;
        }
コード例 #11
0
ファイル: Soundtrack.cs プロジェクト: OrangeeZ/Crandell
 private void OnBossDie( BossDeadStateInfo.Died obj )
 {
     fxSound = GetComponent<AudioSource>();
     fxSound.Stop();
     fxSound.clip = endgameSoundtrack;
     fxSound.Play();
 }
コード例 #12
0
ファイル: MuonDetector.cs プロジェクト: Majiir/MuMechLib
    protected override void onFlightStart()
    {
        ping = gameObject.AddComponent<AudioSource>();
        WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MuonDetector/ping.wav");
        if ((ping != null) && (www != null))
        {
            ping.clip = www.GetAudioClip(false);
            ping.volume = 0;
            ping.Stop();
        }

        disk = transform.Find("model/disk");
        if (disk != null)
        {
            MIN_PING_DIST = 150000;
            MIN_PING_TIME = 0.2;
            MAX_PING_TIME = 15;

            led = transform.Find("model/led");
            originalLensShader = led.renderer.material.shader;
            pingLight = led.gameObject.AddComponent<Light>();
            pingLight.type = LightType.Point;
            pingLight.renderMode = LightRenderMode.ForcePixel;
            pingLight.shadows = LightShadows.None;
            pingLight.range = 1;
            pingLight.enabled = false;
        }

        RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
    }
コード例 #13
0
ファイル: DieWater.cs プロジェクト: kkiniaes/Fire-On-Ice
	void PlayRandomAudio(AudioClip[] clips, AudioSource audioS){
		if(!audioS.isPlaying && gm.playerList.Count > 2){
			audioS.Stop ();
			audioS.clip = clips [Random.Range (0, clips.Length-1)];
			audioS.Play ();
		}
	}
コード例 #14
0
    public AudioPlayer(AudioObject audio)
    {
        if (audio == null || audio.parent == null)
        {
            removable = true;
            return;
        }
        this.finished = false;
        this.removable = false;
        this.paused = false;
        this.audio = audio;

        // create audio source with clip
        audioGO = (GameObject)GameObject.Instantiate(AudioManager.instance.audioSourcePrefab);
        //Debug.Log(audio.parent);
        audioGO.transform.parent = audio.parent.transform;
        audioGO.transform.localPosition = Vector3.zero;

        SoundSystemManager.HandleAudioSource(audioGO);

        audioAS = audioGO.GetComponent<AudioSource>();
        audioAS.Stop();
        audioAS.clip = audio.clip;
        audioAS.volume = audio.volume;
        audioAS.loop = audio.loop;
        if (audio.maxDistance.HasValue)
            audioAS.maxDistance = audio.maxDistance.Value;
        if (audio.minDistance.HasValue)
            audioAS.minDistance = audio.minDistance.Value;

        playAtTime = Time.time + audio.delay;
        audioAS.PlayDelayed(audio.delay);
    }
コード例 #15
0
ファイル: WinCondition.cs プロジェクト: paleonluna/PotF
	IEnumerator FadeOutAudioSource(AudioSource x) { //call from elsewhere
		while (x.volume > 0.0f) {					//where x is sound track file
			x.volume -= 0.1f;
			yield return new WaitForSeconds(0.3f);
		}
		x.Stop ();
	}
コード例 #16
0
	public void StopClip(AudioSource asComp) {
		if (asComp != null) {
			asComp.Stop();
			m_playingClips.Remove(asComp);
			GameObject.Destroy(asComp.gameObject);
		}
	}
コード例 #17
0
        public void setupAudio()
        {
            bleepAudio = gameObject.AddComponent<AudioSource>();
            bleepAudio.volume = GameSettings.SHIP_VOLUME;
            bleepAudio.clip = GameDatabase.Instance.GetAudioClip("NANA/Wildfire/Sounds/BleepSound");
            bleepAudio.loop = false;
            bleepAudio.dopplerLevel = 0;
            bleepAudio.Stop();

            bleeeepAudio = gameObject.AddComponent<AudioSource>();
            bleeeepAudio.volume = GameSettings.SHIP_VOLUME;
            bleeeepAudio.clip = GameDatabase.Instance.GetAudioClip("NANA/Wildfire/Sounds/BleeeepSound");
            bleeeepAudio.loop = false;
            bleeeepAudio.dopplerLevel = 0;
            bleeeepAudio.Stop();

            sprinklerAudio = gameObject.AddComponent<AudioSource>();
            sprinklerAudio.volume = GameSettings.SHIP_VOLUME / 3;
            sprinklerAudio.clip = GameDatabase.Instance.GetAudioClip("NANA/Wildfire/Sounds/WaterSound");
            sprinklerAudio.loop = true;
            sprinklerAudio.Stop();

            sparklerAudio = gameObject.AddComponent<AudioSource>();
            sparklerAudio.volume = GameSettings.SHIP_VOLUME / 3;
            sparklerAudio.clip = GameDatabase.Instance.GetAudioClip("NANA/Wildfire/Sounds/SparklerSound");
            sparklerAudio.loop = true;
            sparklerAudio.Stop();

            spoolupAudio = gameObject.AddComponent<AudioSource>();
            spoolupAudio.volume = GameSettings.SHIP_VOLUME / 3;
            spoolupAudio.clip = GameDatabase.Instance.GetAudioClip("NANA/Wildfire/Sounds/SpoolupSound");
            spoolupAudio.loop = false;
            spoolupAudio.Stop();
        }
コード例 #18
0
ファイル: SoundControll.cs プロジェクト: Madzzzz/Pilot-Rep
 void Start()
 {
     source = GetComponent<AudioSource>();
     source.Stop();
     source.Play();
     source.loop = true;
 }
コード例 #19
0
 //Created this so I could manually stop playback to avoid having two music or ambiance clips playing at once. I assume the singleton was supposed to prevent that from happening, but since I was having a problem with lines 20 through 22, I used this as a workaround.
 public void Stop(string audioItem)
 {
     if (audioItem == "sfx") 								//This stops playback of the audio clip attatched to all game objects with the "SoundEffect" tag
     {
         GameObject[] existingSfx = GameObject.FindGameObjectsWithTag ("SoundEffect");
         foreach (GameObject sfxObject in existingSfx)
         {
             source = sfxObject.GetComponent<AudioSource> ();
             source.Stop ();
         }
     }
     if (audioItem == "ambiance") 							//This stops playback of the audio clip attatched to all game objects with the "Ambiance" tag
     {
         GameObject[] existingAmbiance = GameObject.FindGameObjectsWithTag ("Ambiance");
         foreach (GameObject ambianceObject in existingAmbiance)
         {
             source = ambianceObject.GetComponent<AudioSource> ();
             source.Stop ();
         }
     }
     if (audioItem == "music") 								//This stops playback of the audio clip attatched to all game objects with the "Music" tag
     {
         GameObject[] existingMusic = GameObject.FindGameObjectsWithTag ("Music");
         foreach (GameObject musicObject in existingMusic)
         {
             source = musicObject.GetComponent<AudioSource> ();
             source.Stop ();
         }
     }
 }
コード例 #20
0
ファイル: GameStatePlaying.cs プロジェクト: rangermann/ggj16
	protected override void OnEnter (object onEnterParams = null)
	{

		//GameController.Instance.StartCoroutine (playEngineSound (0));
	    audio = GameObject.Find ("background_music").GetComponent<AudioSource> ();
		audio.Stop ();
		audio.loop = false;
		part = 0;

		// reset camera
		TransformLevelCamera = GameController.Instance.TransformLevelCamera;
		GameController.Instance.ResetCamera ();

		// spawn player
		SpawnPlayer ();

		// start level generation
		int seed = 1337; // TODO: use seed from onEnterParams
		GameController.Instance.LevelGenerator.CleanUp ();
		GameController.Instance.LevelGenerator.StartGenerating (seed);

		GameController.Instance.Background.Reset ();
		GameController.Instance.Background.Start ();

		GameController.Instance.RoundStartTime = Time.time;
		GameController.Instance.CurrentlyPlaying = true;
	}
コード例 #21
0
 void Start()
 {
     source = gameObject.GetComponent<AudioSource>();
     source.Stop ();
     source.time = 100;
     source.Play ();
 }
コード例 #22
0
    IEnumerator CrossFade(AudioSource active, AudioSource old)
    {
        active.volume = 0;

        float t = 0;

        bool lerping = true;

        active.Play();

        while (lerping)
        {

            active.volume = t;
            old.volume = 1 - t;
            t += Time.deltaTime / fadeDuration;

            if (t >= 1)
                lerping = false;

            yield return null;
        }

        old.Stop();
    }
コード例 #23
0
 public static void PlayECSoundEffect(EnemyChildSFX _sfx, AudioSource _Source)
 {
     if (m_EnemyChildTracks == null)
         return;
     _Source.Stop();
     _Source.clip = m_EnemyChildTracks[(int) _sfx];
     _Source.Play();
 }
コード例 #24
0
        // Use this for initialization
        void Start()
        {
            m_Audiosource = GetComponent<AudioSource>();
            m_Animator = GetComponent<Animator>();
            m_MoveStateNameHash = Animator.StringToHash(m_MoveStateName);

            m_Audiosource.Stop();
        }
コード例 #25
0
ファイル: Intro.cs プロジェクト: yihengz/First-Flight
 IEnumerator fadeOutBackground(AudioSource fadeOutMusic, float time)
 {
     for (int i = 0; i < 100; i++) {
         fadeOutMusic.volume -= 0.02f;
         yield return new WaitForSeconds(time/100);
     }
     fadeOutMusic.Stop ();
 }
コード例 #26
0
	// Play a sound while stopping a currently playing one from a given audio
	// source with an option to play a one shot of the sound.
	public static void PlaySound(AudioSource audioSource, AudioClip sfx, bool oneShot = false)
	{
		audioSource.Stop ();
		audioSource.clip = sfx;
		if(oneShot)
			audioSource.PlayOneShot(sfx);
		else audioSource.Play();
	}
コード例 #27
0
ファイル: GameController.cs プロジェクト: vigneshhbk/Defender
 void fadeOut(AudioSource audioSource)
 {
     audioSource.volume = audioSource.volume - 0.01f;
     if(audioSource.volume < 0){
         isBGMPlaying = false;
         audioSource.Stop();
     }
 }
コード例 #28
0
	void Start () {
		StatManager.isSquareAcquired = false;
		StatManager.isDiamondAcquired = false;
		StatManager.isTriangleAcquired = false;
		backgroundMusic = GameObject.Find("BackgroundMusic").GetComponent<AudioSource>();
		backgroundMusic.Stop();
		StartCoroutine(textRead(17));
	}
コード例 #29
0
	IEnumerator fadeOut (AudioSource source, float fadeOutSpeed){
		while (source.volume > 0) {
			source.volume -= fadeOutSpeed * Time.deltaTime;
			yield return null;
		}
		source.Stop ();
		yield break;
	}
コード例 #30
0
ファイル: Aiming.cs プロジェクト: Jickelsen/Draw-NMS15
 void Start()
 {
     audio = GetComponent<AudioSource>();
     audio.Stop();
     audio.pitch = 1f;
     _targetDirection = AimVector();
     _gameManager = GameManager.instance;
 }
コード例 #31
0
 private IEnumerator FadeOut(AudioSource audio)
 {
     while (audio.volume > 0f) {
         audio.volume -= 0.3f * Time.deltaTime;
         yield return new WaitForSeconds (0.05f);
     }
     audio.Stop ();
 }
コード例 #32
0
ファイル: UIController.cs プロジェクト: pcast01/GalagaRemake
 public void OnPointerDown(PointerEventData ped)
 {
     audio.PlayOneShot(click);
     if (gameObject.name == "Start UI")
     {
         music = GameObject.Find("Music Player").GetComponent<AudioSource>();
         music.Stop();
     }
 }
コード例 #33
0
 static public int Stop(IntPtr l)
 {
     try {
         UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l);
         self.Stop();
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #34
0
 static public int Stop(IntPtr l)
 {
     try{
         UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l);
         self.Stop();
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #35
0
        public static IEnumerator FadeOut(UnityEngine.AudioSource audioSource, float fadeTime)
        {
            float startVolume = audioSource.volume;

            while (audioSource.volume > 0)
            {
                audioSource.volume -= startVolume * Time.deltaTime / fadeTime;

                yield return(null);
            }

            audioSource.Stop();
            audioSource.volume = startVolume;
        }
コード例 #36
0
 static int Stop(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.AudioSource obj = (UnityEngine.AudioSource)ToLua.CheckObject <UnityEngine.AudioSource>(L, 1);
         obj.Stop();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #37
0
    // Update is called once per frame


    public override void mytimer()
    {
        handposition = hand.transform.localPosition;
        if (hoverbutton.buttom_name == "null" || hoverbutton.buttom_name == gameObject.name)
        {
            if (isHandOver())
            {
                timecount = timestart - (int)Time.time;
                if (hand_animator.isActiveAndEnabled)
                {
                    hand_animator.Play("Base Layer.hand");
                }
                if (music_name.text != musicname.text)
                {
                    buttonimgwhenhover();
                    //button_image.sprite = button_image_hover;// Resources.Load ("04/04_music_hover", typeof(Sprite)) as Sprite;
                    //musicname.color = Color.black;
                }
                hoverbutton.buttom_name = gameObject.name;
                //music_init ();
                bgaudio.Pause();
                if (!tmpaudio.isPlaying)
                {
                    tmpaudio.Play();
                }
                tmpaudio.UnPause();
                if (timecount == 0)
                {
                    decide_music();
                    timestart = 0;
                    timecount = timelong;
                }
            }
            else
            {
                if (music_name.text != musicname.text)
                {
                    buttonimgwhenoff();
                }

                hand_animator.Play("Base Layer.none");
                hoverbutton.buttom_name = "null";
                tmpaudio.Stop();
                bgaudio.UnPause();
                timestart = (int)Time.time + timelong;
            }
        }
    }
コード例 #38
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
        if (colorReader != null)
        {
            using (var frame = colorReader.AcquireLatestFrame())
            {
                if (frame != null)
                {
                    frame.CopyConvertedFrameDataToArray(pixels, ColorImageFormat.Rgba);
                    texture.LoadRawTextureData(pixels);
                    texture.Apply();
                }
            }
        }
        //HD face frame, update points and allignement
        if (bodyReader != null)
        {
            using (var frame = bodyReader.AcquireLatestFrame())
            {
                if (frame != null)
                {
                    frame.GetAndRefreshBodyData(bodies);
                    Body body = GetActiveBody();


                    if (body != null)
                    {
                        textboxUp.text = stringTransformation + System.Environment.NewLine + System.Environment.NewLine + stringPowerLevel + System.Environment.NewLine
                                         + System.Environment.NewLine + stringKamehameha;
                        textboxDown.text = stringIndication;


                        // Detect the hand (left or right) that is closest to the sensor.
                        var handRight  = body.Joints[JointType.HandRight].Position;
                        var handLeft   = body.Joints[JointType.HandLeft].Position;
                        var elbowLeft  = body.Joints[JointType.ElbowLeft].Position;
                        var elbowRight = body.Joints[JointType.ElbowRight].Position;
                        var hipLeft    = body.Joints[JointType.HipLeft].Position;
                        var hipRight   = body.Joints[JointType.HipRight].Position;
                        var spineBase  = body.Joints[JointType.SpineBase].Position;
                        var spineMid   = body.Joints[JointType.SpineMid].Position;
                        var head       = body.Joints[JointType.Head].Position;


                        var closer = handRight.Z < handLeft.Z ? handRight : handLeft;


                        // Map the 2D position to the Unity space.
                        var worldRight      = map3dPointTo2d(handRight);
                        var worldLeft       = map3dPointTo2d(handLeft);
                        var worldElbowRight = map3dPointTo2d(elbowRight);
                        var worldElbowLeft  = map3dPointTo2d(elbowLeft);
                        var worldLeftHip    = map3dPointTo2d(hipLeft);
                        var worldRightHip   = map3dPointTo2d(hipRight);
                        var worldFrontHead  = map3dPointTo2d(head);
                        var worldCloser     = map3dPointTo2d(closer);
                        var worldSpineBase  = map3dPointTo2d(spineBase);
                        var worldSpineMid   = map3dPointTo2d(spineMid);


                        var midHand             = (worldRight + worldLeft) / 2;
                        var center              = quad.GetComponent <Renderer>().bounds.center;
                        var currentBallPosition = midHand;


                        ellapsedTime = Time.time - startTime;
                        if (timeChecker && ellapsedTime > 5.18f)
                        {
                            Renderer rend = videoTransformation.GetComponent <Renderer>();
                            rend.enabled = false;
                        }

                        if (timeChecker && ellapsedTime > 5.2f)
                        {
                            Renderer rend = videoTransformation.GetComponent <Renderer>();
                            if (transformCounter == 0)
                            {
                                vpYellow.Stop();
                                vpYellowLoop.Play();
                                rend.enabled = true;
                                powerUp1.Play();
                                stringTransformation = "Super Saiyan";
                                saiyanChargeSound.Play();
                            }
                            else if (transformCounter == 1)
                            {
                                vpDeepYellow.Stop();
                                vpDeepYellowLoop.Play();
                                rend.enabled = true;
                                powerUp2.Play();
                                stringTransformation = "Super Saiyan 2";
                                saiyanChargeSound2.Play();
                            }
                            else if (transformCounter == 2)
                            {
                                vpBlue.Stop();
                                vpBlueLoop.Play();
                                rend.enabled = true;
                                powerUp3.Play();
                                stringTransformation = "Super Saiyan God";
                                saiyanChargeSound3.Play();
                            }

                            timeChecker = false;
                        }

                        //Charge Energie if hands are close to each other and below middle of body
                        float distanceShoulders = Mathf.Abs(worldElbowRight.x - worldElbowLeft.x);
                        float distanceHands     = Mathf.Abs(worldRight.x - worldLeft.x);
                        float ratioHandShoulder = distanceHands / distanceShoulders;
                        if ((worldRight.x < worldLeftHip.x && worldLeft.x < worldLeftHip.x ||
                             worldRight.x > worldRightHip.x && worldLeft.x > worldRightHip.x) &&
                            !inAnimationKameha && powerLevel >= 400 && ratioHandShoulder < 0.75f)
                        {
                            if (loadingSide == 0 && worldRight.x < worldLeftHip.x && worldLeft.x < worldLeftHip.x)
                            {
                                loadingSide = 1;
                            }
                            else if (loadingSide == 0 && worldRight.x > worldRightHip.x && worldLeft.x > worldRightHip.x)
                            {
                                loadingSide = 2;
                            }
                            else if (loadingSide == 1 && worldRight.x < worldLeftHip.x && worldLeft.x < worldLeftHip.x ||
                                     loadingSide == 2 && worldRight.x > worldRightHip.x && worldLeft.x > worldRightHip.x)
                            {
                                kamehameha += 1;
                                if (!alreadyPlayingKameha)
                                {
                                    kamehaCharge.Play();
                                    alreadyPlayingKameha = true;
                                }
                                kamehaCharge.UnPause();
                                stringKamehameha = "Kamehameha: " + kamehameha;
                            }
                            else if (loadingSide == 2 && worldRight.x < worldLeftHip.x && worldLeft.x < worldLeftHip.x ||
                                     loadingSide == 1 && worldRight.x > worldRightHip.x && worldLeft.x > worldRightHip.x)
                            {
                                loadingSide          = 0;
                                inAnimationKameha    = true;
                                alreadyPlayingKameha = false;
                                startTime            = Time.time;
                                kamehaCharge.Stop();
                                kamehaShot.Play();
                                vpKamehameha.Play();
                            }
                            chargeKamehameha = true;
                        }
                        else
                        {
                            chargeKamehameha = false;
                            kamehaCharge.Pause();
                        }

                        if (inAnimationKameha && Time.time - startTime > 0.4f && !kamehaBuffer)
                        {
                            Renderer render = videoKamehameha.GetComponent <Renderer>();
                            render.enabled = true;

                            if (kamehameha == 0)
                            {
                                kamehameha = 0;
                                vpKamehameha.Stop();
                                kamehaShot.Stop();
                                kamehaBuffer   = true;
                                kamehaBreak    = Time.time;
                                render.enabled = false;
                            }
                            else
                            {
                                kamehameha--;
                                stringKamehameha = "Kamehameha: " + kamehameha;
                            }
                        }

                        if (kamehaBuffer && Time.time - kamehaBreak > 3f)
                        {
                            kamehaBuffer      = false;
                            inAnimationKameha = false;
                        }

                        if (ratioHandShoulder < 0.6 && !timeChecker)
                        {
                            if (powerLevel < 400)
                            {
                                if (!alreadyPlaying)
                                {
                                    alreadyPlaying = true;
                                    chargeSound.Play();
                                }
                                if (!timeChecker)
                                {
                                    chargeSound.UnPause();
                                }
                                powerLevel++;
                                if (powerLevel == 400)
                                {
                                    stringIndication = "Indication:" + System.Environment.NewLine + System.Environment.NewLine
                                                       + "Tiens tes mains à une coté de ton corps pour charger le 'Kaméhaméha'" + System.Environment.NewLine + System.Environment.NewLine
                                                       + "Amène-les à l'autre côté pour l'activer";
                                }
                                stringPowerLevel = "Power Level: " + powerLevel;
                                if (powerLevel % 100 == 0 && powerLevel < 400)
                                {
                                    Renderer rend = videoTransformation.GetComponent <Renderer>();
                                    if (powerLevel == 100)
                                    {
                                        chargeSound.Stop();
                                        vpYellow.Play();
                                        rend.enabled = true;
                                    }
                                    else if (powerLevel == 200)
                                    {
                                        saiyanChargeSound.Stop();
                                        vpDeepYellow.Play();
                                        rend.enabled = true;
                                        transformCounter++;
                                    }
                                    else if (powerLevel == 300)
                                    {
                                        saiyanChargeSound2.Stop();
                                        vpBlue.Play();
                                        rend.enabled = true;
                                        transformCounter++;
                                    }

                                    transformSound.Play();
                                    startTime   = Time.time;
                                    timeChecker = true;
                                }
                            }
                            //hands close and kamehameha position
                            else
                            {
                                if (chargeKamehameha && !inAnimationKameha)
                                {
                                    vpBlueLoop.Stop();
                                    saiyanChargeSound3.Pause();
                                }
                            }
                        }

                        videoTransformation.transform.position = new Vector3(worldFrontHead.x, -worldSpineMid.y, 0);

                        //kamehameha
                        if (inAnimationKameha)
                        {
                            //right
                            double xDiffRight     = worldRight.x - worldElbowRight.x;
                            double yDiffRight     = worldRight.y - worldElbowRight.y;
                            float  angleRadRight  = (float)Math.Atan2(yDiffRight, xDiffRight);
                            float  angleDegRight  = (float)(Math.Atan2(yDiffRight, xDiffRight) / Math.PI * 180);
                            float  widthKamehamha = 12;

                            //left
                            double xDiffLeft    = worldLeft.x - worldElbowLeft.x;
                            double yDiffLeft    = worldLeft.y - worldElbowLeft.y;
                            float  angleRadLeft = (float)Math.Atan2(yDiffLeft, xDiffLeft);
                            float  angleDegLeft = (float)(Math.Atan2(yDiffLeft, xDiffLeft) / Math.PI * 180);

                            if (angleDegLeft < 0)
                            {
                                angleDegLeft += 360;
                            }
                            if (angleDegRight < 0)
                            {
                                angleDegRight += 360;
                            }

                            float angleDeg = (angleDegLeft + angleDegRight) / 2;
                            if (Math.Abs(angleDegLeft - angleDegRight) > 180)
                            {
                                angleDeg -= 180;
                            }
                            float angleRad = (float)(angleDeg * Math.PI / 180);

                            float xMovement = (float)(Math.Cos(-angleRad) * widthKamehamha / 2);
                            float yMovement = (float)(Math.Sin(-angleRad) * widthKamehamha / 2);
                            videoKamehameha.transform.rotation   = Quaternion.Euler(0, 0, -angleDeg + 180);
                            videoKamehameha.transform.position   = new Vector3(midHand.x + xMovement, -midHand.y + yMovement, 0);
                            videoKamehameha.transform.localScale = new Vector3(widthKamehamha, 4.5f, 1);
                        }
                    }
                }
            }
        }
    }
コード例 #39
0
ファイル: Audio.cs プロジェクト: abhavgarg/Ratatoskr_final
 public void StopMusic()
 {
     src.Stop();
 }
コード例 #40
0
    void Update()
    {
        if (_Reader != null)
        {
            var frame = _Reader.AcquireLatestFrame();
            if (frame != null)
            {
                frame.CopyFrameDataToArray(_Data);
                twoDArray = new ushort[424, 512];
                for (int x = 0; x < 424; x++)
                {
                    for (int y = 0; y < 512; y++)
                    {
                        twoDArray [x, y] = _Data [x * 512 + y];
                    }
                }

                int j    = 0;
                int jGap = 100;
                while (j < 512)
                {
                    if (j > 380)
                    {
                        jGap = 512 - j;
                    }
                    for (int a = 0; a < 424; a += 100)
                    {
                        if (a > 280)
                        {
                            averageOut(a, 424, j, j + jGap, twoDArray);
                        }
                        else
                        {
                            averageOut(a, a + 100, j, j + jGap, twoDArray);
                        }
                    }
                    j = j + jGap;
                }
                //int aCount = 0;

                /*
                 * for (int z=50; z<512; z+=100){
                 *      for (int i=50; i<424; i+=100){
                 *              int vol=(int)twoDArray [i, z] / 2000;
                 *              if (vol > 1)
                 *                      vol = 1;
                 *
                 *              audioSource.volume = 1;
                 *              audioSource.PlayOneShot (audioClip [aCount]);
                 *              aCount++;
                 *      }
                 *      Thread.Sleep (1);
                 *      aCount = 0;
                 * }
                 */

                float vol   = (float)(twoDArray [200, 150] / 5);
                float pitch = 0;
                if (vol > 1)
                {
                    vol = 1;
                }
                //pitch = vol * 6 - 3;

                //	if (vol < 0.5)
                //		vol = 0;
                //		Debug.Log (vol);
                //		Debug.Log ("left");
                //float vol = (float)intensityCalc_S(200,150,twoDArray[200,150]);
                //Debug.Log (vol);


                if (!audioL.isPlaying)
                {
                    audioL.volume = vol;
                    //audioL.pitch = pitch;
                    audioL.Play();
                    audioL.time = 13.21f;
                }

                if (audioL.time > 14.20f)
                {
                    audioL.Stop();
                }


                vol = (float)(twoDArray [200, 300] / 5);
                if (vol > 1)
                {
                    vol = 1;
                }
                //pitch = vol * 6 - 3;
                //	if (vol < 0.5)
                //		vol = 0;
                //		Debug.Log (vol);
                //		Debug.Log ("mid");
                //vol = (float)intensityCalc_S(200,300,twoDArray[200,300]);
                //Debug.Log (vol);


                if (!audioM.isPlaying)
                {
                    audioM.volume = vol;
                    //audioL.pitch = pitch;
                    audioM.Play();
                    audioM.time = 13.21f;
                }

                if (audioM.time > 14.20f)
                {
                    audioM.Stop();
                }

                vol = (float)(twoDArray [200, 450] / 5);
                if (vol > 1)
                {
                    vol = 1;
                }
                //pitch = vol * 6 - 3;
                //	if (vol < 0.5)
                //		vol = 0;
                //		Debug.Log (vol);
                //		Debug.Log ("right");
                //vol = (float)intensityCalc_S(200,450,twoDArray[200,450]);
                //Debug.Log (vol);


                if (!audioL.isPlaying)
                {
                    audioR.volume = vol;
                    //audioL.pitch = pitch;
                    audioR.Play();
                    audioR.time = 13.21f;
                }

                if (audioR.time > 14.20f)
                {
                    audioR.Stop();
                }
                frame.Dispose();
                frame = null;

                //		if (i / 20 == 1) {
                //				i = 0;
                //
                //for (int j = 0; j < _Data.Length; j++) {
                //		depthPixels [j] = (byte)(_Data[j] >= minDepth && _Data[j] <= maxDepth ? (_Data[j] / MapDepthToByte) : 0);
                //		}
                //		string[] temp = new string[_Data.Length];
                //		for (int j = 0; j < _Data.Length; j++) {
                //			temp [j] = _Data [j].ToString ();
                //		}
                //				System.IO.File.WriteAllLines (@"C:\Users\Administrator\Desktop\WriteLines.txt", temp);
                //		} else {
                //		i++;
                //		}
            }
        }
    }