Play() private method

private Play ( ) : 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
    // Use this for initialization
    void Start()
    {
        transform.localScale = new Vector3(Camera.main.orthographicSize/2 * (Screen.width/Screen.height),Camera.main.orthographicSize/2,1f);

        audioSource = GetComponent<AudioSource> ();

        if (HammerController.gameOverState == 1) {
            //success
            GetComponent<MeshRenderer> ().materials [0].mainTexture = textures [0];
            movTerxture = (MovieTexture)GetComponent<MeshRenderer> ().materials [0].mainTexture;
            movTerxture.Play();
            audioSource.clip = music1;
            audioSource.Play();
            audioSource.PlayOneShot(voiceovers[0]);

        }
        else if(HammerController.gameOverState == 2 )
        {
            GetComponent<MeshRenderer> ().materials [0].mainTexture = textures [1];
            movTerxture = (MovieTexture)GetComponent<MeshRenderer> ().materials [0].mainTexture;
            movTerxture.Play();
            audioSource.clip = music2;
            audioSource.Play();
            audioSource.PlayOneShot(voiceovers[1]);

        }
    }
コード例 #3
0
ファイル: PlayerShoot.cs プロジェクト: schoolsout/Schools-Out
    //void awake()
    //{
    //}
    IEnumerator Start()
    {
        source = GetComponent<AudioSource>();
        while (true)
        {

                // Make a bullet with the same position and rotation as the player
            float vol = Random.Range(volLowRange, volHighRange);
            if (powerUp == true)
            {
                var bulpower = Instantiate(powerup, transform.position, transform.rotation);

                source.volume = vol;
                source.Play();

                // Wait 0.2 seconds
                Destroy(bulpower, 1);
                yield return new WaitForSeconds(0.2f);
            }
            else
            {
                var bul = Instantiate(bullet, transform.position, transform.rotation);

                source.volume = vol;
                source.Play();

                // Wait 0.2 seconds
                Destroy(bul, 1);
                yield return new WaitForSeconds(0.2f);
            }

        }
    }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        aSource = GetComponent<AudioSource>();

        aSource.Play();
        aSource.clip = song1;
        aSource.Play();
    }
コード例 #5
0
 public void PlayAudioSource(AudioSource audioSource)
 {
     if (AudioSources.Contains(audioSource)) {
         if (AllowClipping)
             audioSource.Play();
         else if (AudiosBeingPlayed() == 0)
             audioSource.Play();
     }
 }
コード例 #6
0
 void playSound(AudioSource sound)
 {
     if (sound.isPlaying)
     {
         sound.Stop();
         sound.Play();
     }
     else
         sound.Play();
 }
コード例 #7
0
	// Use this for initialization
	void Start () {
		AudioSource[] audioSources = GetComponents<AudioSource>();
		BGM = audioSources[0];
		BGMonVoice = audioSources[1];
		BGMonVoice.Play ();
		Invoke ("PlayNoVoice", BGMonVoice.clip.length);

		// メインBGMを止める
		GameObject obj = GameObject.FindWithTag ("MainBgmController");
		if (obj != null) {
			GameObject.Destroy (obj);
		}

		buttonCloseMenuCol.enabled = false;

		// Playコントローラーがある場合は削除してからインスタンス生成する
		GameObject obj2 = GameObject.FindWithTag ("PlayController");
		if (obj2 != null) {
			GameObject.Destroy (obj2);
		}
		playController = (GameObject)Instantiate (playControllerPrefab);
		play = playController.GetComponent<PlayController>();

		// お題表示
		Invoke ("ShowFab", 6.0f);
	}
コード例 #8
0
ファイル: Blade.cs プロジェクト: owlmazing/Hand2Hand
 //private GameObject leftBlade;
 //private GameObject rightBlade;
 // Use this for initialization
 void Start()
 {
     //healthHandler = GameObject.Find ("PlayerHealthHandler");
     hitSoundSource = transform.FindChild ("hitSoundPlayer").gameObject.GetComponent<AudioSource> ();
     newBladeSoundSource = transform.FindChild ("newBladeSoundPlayer").gameObject.GetComponent<AudioSource> ();
     newBladeSoundSource.Play();
 }
コード例 #9
0
 private void PlayBatDownAudio()
 {
     if (batDownOnce)
     {
         batDownAudio.Play();
     }
 }
コード例 #10
0
 void OnCollisionEnter(Collision col)
 {
     ScoreManager.score++;
     index = Random.Range (0, splats.Length - 1);
     splat = splats [index];
     splat.Play();
 }
コード例 #11
0
ファイル: PopSound.cs プロジェクト: calvinatlan/BubbleCubed
 // Use this for initialization
 void Start()
 {
     sE = gameObject.AddComponent<AudioSource>();
     sE.clip = pop [Random.Range(0, 4)];
     sE.volume = seVolume;
     sE.Play ();
 }
コード例 #12
0
ファイル: Background_Music.cs プロジェクト: theslimreaper/DnD
 void Start()
 {
     audioSource = gameObject.GetComponent<AudioSource>();
     audioSource.volume = Settings_Screen.BGMusicVol;
     audioSource.clip = soundClip;
     audioSource.Play();
 }
コード例 #13
0
 void Start()
 {
     audioSrc = GetComponentInChildren<AudioSource> ();
     audioSrc.clip = BGM_main;
     audioSrc.Play (0);
     //audioSrc.ignoreListenerVolume = true;
 }
コード例 #14
0
 // Use this for initialization
 void Awake()
 {
     bang = GetComponent<AudioSource> ();
     int ran = Random.Range (0, 3);
     bang.clip = asteroidExplosion [ran];
     bang.Play ();
 }
コード例 #15
0
ファイル: Bullets.cs プロジェクト: julianpoy/HackPoly2016
	// Use this for initialization
	void Start () {

		//Get a component reference to the Character's animator component
		animator = GetComponent<Animator>();
		render = GetComponent<SpriteRenderer>();

		//Get the rigid body on the prefab
		bullBody = GetComponent<Rigidbody2D>();

		//Set our bullet strength and speed
		strength = 4;
		speed = 40;

		//Go after our player!
		player = GameObject.Find("Player").GetComponent<Player>();

		//Get our Player current Direction
		if (player.getDirection () > 0 ||
			(player.getDirection() == 0 && player.getLastDirection() > 0 )) {
			animator.SetInteger ("Direction", 1);
			playerRight = true;
		} else {
			playerRight = false;
			animator.SetInteger ("Direction", -1);
		}

		//Play our shooting sound
		shoot = GameObject.Find ("Shoot").GetComponent<AudioSource> ();

			shoot.Play ();

		//Get our camera script
		actionCamera = Camera.main.GetComponent<ActionCamera>();
	}
コード例 #16
0
    public void bow()
    {
        float y = Head.position.y;

        if (headYPos.Count == 0)
        {
            headYPos.Insert(0, y);
        }
        else
        {
            if (y > (float)headYPos[headYPos.Count - 1] + shit)
            {
                headYPos.Clear();
                return;
            }

            else if (y < (float)headYPos[headYPos.Count - 1] - shit)
            {
                headYPos.Insert(headYPos.Count, y);
            }
            if (((float)headYPos[0] - (float)headYPos[headYPos.Count - 1]) > 0.3f)
            {
                konnichiwa.Play();
                headYPos.Clear();
            }
            else
            {
                Debug.Log("mada mada");
            }
        }
    }
コード例 #17
0
	void OnTriggerEnter(Collider other)
	{
		switch(other.transform.tag)
		{
			case TAG_POWERUP:
				audioSource = other.transform.GetComponent<AudioSource>();
				audioSource.Play();
				PowerUp powerUp = other.transform.GetComponent<PowerUp>();
				collisionManager.OnPowerUpCollision(powerUp.powerUp);
				break;
			case TAG_OBSTACLE:
				Obstacle obstacle = other.transform.GetComponent<Obstacle>();
				collisionManager.OnObstacleCollision(obstacle.obstacle);
				break;
			case TAG_MONEY:
				audioSource = other.transform.GetComponent<AudioSource>();
				audioSource.Play();
				Note note = other.transform.GetComponent<Note>();
				collisionManager.OnMoneyCollision(note.note);
				break;
			case TAG_GABEN:
				collisionManager.ShowBubble();
				break;
		}

		if(other.tag != TAG_GABEN)
			other.gameObject.SetActive(false);
	}
コード例 #18
0
ファイル: SFXObjS.cs プロジェクト: chorgan93/Ectoplazaa
    // Use this for initialization
    void Start()
    {
        ownSource = GetComponent<AudioSource>();
        // multiply volume by sfx volume mult
        ownSource.volume *= sfxVolumeMult;
        ownSource.Play();

        if (duckMusic){
            if (GameObject.Find("MusicPlayer")){
                if(longDuck){
                    GameObject.Find("MusicPlayer").GetComponent<BGMS>().DuckVolumeLonger(ownSource.clip.length);
                    //print ("long duck!!");
                }
                else{
                    GameObject.Find("MusicPlayer").GetComponent<BGMS>().DuckVolume();
                }
            }
            else if (GameObject.Find("MusicPlayer(Clone)")){
                if(longDuck){
                    GameObject.Find("MusicPlayer(Clone)").GetComponent<BGMS>().DuckVolumeLonger(ownSource.clip.length);
                    //print ("long duck!!");
                }
                else{
                    GameObject.Find("MusicPlayer(Clone)").GetComponent<BGMS>().DuckVolume();
                }
            }
            else{

                //print ("didn't find it");
            }
        }
    }
コード例 #19
0
ファイル: SoundControll.cs プロジェクト: Madzzzz/Pilot-Rep
 void Start()
 {
     source = GetComponent<AudioSource>();
     source.Stop();
     source.Play();
     source.loop = true;
 }
コード例 #20
0
ファイル: Intro.cs プロジェクト: kersseliM/syysjamit2015
 void a0()
 {
     audioSource = GetComponent<AudioSource>();
     audioSource.Play();
     Invoke("d", 2.1f);
     Invoke("a1", 10);
 }
コード例 #21
0
 public static void Pause( ref AudioSource sndInstance )
 {
     if ( sndInstance.isPlaying )
     {
         sndInstance.Play();
     }
 }
コード例 #22
0
 public static void PlaySound( ref AudioSource sndInstance, bool loop = false )
 {
     if ( Settings.IsMute )
         return;
     sndInstance.loop = loop;
     sndInstance.Play();
 }
コード例 #23
0
 static public int Play(IntPtr l)
 {
     try{
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l);
             System.UInt64           a1;
             checkType(l, 2, out a1);
             self.Play(a1);
             return(0);
         }
         else if (argc == 1)
         {
             UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l);
             self.Play();
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
コード例 #24
0
    static int Play(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.AudioSource)))
            {
                UnityEngine.AudioSource obj = (UnityEngine.AudioSource)ToLua.ToObject(L, 1);
                obj.Play();
                return(0);
            }
            else if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.AudioSource), typeof(ulong)))
            {
                UnityEngine.AudioSource obj = (UnityEngine.AudioSource)ToLua.ToObject(L, 1);
                ulong arg0 = (ulong)LuaDLL.lua_tonumber(L, 2);
                obj.Play(arg0);
                return(0);
            }
            else
            {
                return(LuaDLL.tolua_error(L, "invalid arguments to method: UnityEngine.AudioSource.Play"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #25
0
ファイル: backgroundMusic.cs プロジェクト: wolong91/MageDuel
    void Awake()
    {
        if (created == false)
        {
            DontDestroyOnLoad(this.gameObject);
            myAudioSource = GetComponent<AudioSource>();
            myAudioSource.clip = myaudioclip[0];//default background music
            myAudioSource.Play();
            created = true;
        }
        else
        {
            Debug.Log("here 0");
            myAudioSource = GetComponent<AudioSource>();
            // this.gameObject.GetComponent<backgroundMusic>().enabled = false;
            Destroy(this.gameObject);//duplicate
        }

        if (PlayerPrefs.HasKey("Power Level fire") == false)
        {
            PlayerPrefs.SetInt("Power Level fire", 1);
        }
        if (PlayerPrefs.HasKey("Power Level ice") == false)
        {
            PlayerPrefs.SetInt("Power Level ice", 1);
        }
        if (PlayerPrefs.HasKey("Power Level light") == false)
        {
            PlayerPrefs.SetInt("Power Level light", 1);
        }
        if(PlayerPrefs.HasKey("Difficulty") == false)
        {
            PlayerPrefs.SetInt("Difficulty", 1);//default is easy
        }
    }
コード例 #26
0
ファイル: Interraction.cs プロジェクト: Ferhed/ProjetBoss
 // Update is called once per frame
 void Update()
 {
     if(Input.GetButtonDown("X_button_1"))
     {
         Ray ray = new Ray(Camera.main.transform.position,transform.forward);
         RaycastHit hit;
         if (Physics.Raycast(ray,out hit))
         {
             if(hit.transform.gameObject.tag == "Bouton")
             {
                 hit.transform.GetComponent<Bouton>().utiliserBouton();
             }
             if(hit.transform.gameObject.name == "CubeWall 0-1-0")
             {
                 source = hit.transform.gameObject.GetComponent<AudioSource> ();
                 if (!source.isPlaying)
                 {
                     Instantiate(snail);
                     source.clip = WallSSound;
                     source.Play();
                 }
             }
         }
     }
 }
コード例 #27
0
    public void PlayMusic(string name, bool forceRestart)
    {
        bool shouldStartNew = false;
        // If there is current music and either forcing restart or it is not the same as requested
        if (null != mCurrentMusic && (forceRestart || mCurrentMusic.name != name))
        {
            mCurrentMusic.Stop();
            Destroy(mCurrentMusic.gameObject);
            shouldStartNew = true;
        }
        // If there is no current music
        else if (null == mCurrentMusic)
        {
            shouldStartNew = true;
        }

        AudioSource musicSource = mMusicByName[name];
        // if requested music found and should start new music
        if (null != musicSource && shouldStartNew)
        {
            mCurrentMusic = Instantiate(musicSource) as AudioSource;
            DontDestroyOnLoad(mCurrentMusic);
            mCurrentMusic.name = musicSource.name;
            if (isMusicEnabled)
            {
                mCurrentMusic.Play();
            }
        }
        // If should start new but source was null
        else if (shouldStartNew)
        {
            Debug.LogError(new System.Text.StringBuilder("Could not find music source with name: ").Append(name).ToString());
        }
    }
コード例 #28
0
	/// <summary>
	/// 
	/// </summary>
	void Awake()
	{

		if (SpawnObjects == null)
			return;

		int i = (int)Random.Range(0, (SpawnObjects.Count));

		if(SpawnObjects[i] == null)
			return;

		GameObject obj = (GameObject)vp_Utility.Instantiate(SpawnObjects[i], transform.position, transform.rotation);

		obj.transform.Rotate(Random.rotation.eulerAngles);
		m_Audio = audio;
		m_Audio.playOnAwake = true;
		
		// play sound
		if (Sound != null)
		{
			m_Audio.rolloffMode = AudioRolloffMode.Linear;
			m_Audio.clip = Sound;
			m_Audio.pitch = Random.Range(SoundMinPitch, SoundMaxPitch) * Time.timeScale;
			m_Audio.Play();
		}

	}
コード例 #29
0
ファイル: Audio.cs プロジェクト: Dirksolomon/TimeSaverGame
    //This is audio script for animation sounds.
    void Running()
    {
        sound = gameObject.GetComponents<AudioSource> ();

        run = sound [1];
        run.Play ();
    }
コード例 #30
0
    // Use this for initialization
    void Start()
    {
        // where the camera starts and whence it returns
        m_vStartPosition = transform.position;

        // get the appropriate audio source
        AudioSource[] sources = GetComponents<AudioSource>();
        foreach(AudioSource snd in sources) {
            if(1 == snd.priority) {
                m_baseAudio = snd;
                m_baseAudio.volume = 0.5f;
                m_baseAudio.Play();
            } else if(2 == snd.priority) {
                m_chimeAudio = snd;
                m_chimeAudio.Play();
                m_chimeAudio.volume = 0.0f;
            } else if(4 == snd.priority) {
                m_pianoAudio = snd;
                m_pianoAudio.Play();
                m_pianoAudio.volume = 0.0f;
            }
        }

        // merry go round
        m_baseAudio.loop = true;
        m_chimeAudio.loop = true;
        m_pianoAudio.loop = true;

        return;
    }
コード例 #31
0
	public void PlaySfxCar(Sfx.Type type)
	{
		if (MuteSfx) return;
		
		// name
		if (isPaused)
		{
			Debug.LogWarning("Its paused... get out");
			//    return;
		}
		
		string resName = Sfx.sfxFiles[(int)type];
		//Debug.Log("Load sfx:" + resName);
		AudioClip clip = (AudioClip)Resources.Load(resName,typeof(AudioClip));
		if (clip == null)
		{
			Debug.LogError("Unable to load clip: "+resName);
			return;
		}
		car = getFreeChannel();
		car.volume = _mute ? 0 : startVolume;
		car.pitch = startPitch;
		car.loop = true;
		car.clip = clip;
		car.Play();
		//XXXchan.PlayOneShot(clip);
	}
コード例 #32
0
 void Start()
 {
     player = gameObject.GetComponent<AudioSource> ();
     player.clip = musicChangeArray [0];
     player.volume = PlayerPrefsManager.GetMasterVolume ();
     player.Play ();
 }
コード例 #33
0
 static public int Play(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 1)
         {
             UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l);
             self.Play();
             pushValue(l, true);
             return(1);
         }
         else if (argc == 2)
         {
             UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l);
             System.UInt64           a1;
             checkType(l, 2, out a1);
             self.Play(a1);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
	void Awake ()
	{
        // Set up the reference to the aeroplane controller.
		plane = GetComponent<AeroplaneController>();	
		
		// Add the audiosources and get the references.
		engineSoundSource = gameObject.AddComponent<AudioSource>();
		windSoundSource = gameObject.AddComponent<AudioSource>();
		
		// Assign clips to the audiosources.
		engineSoundSource.clip = engineSound;
		windSoundSource.clip = windSound;
		
		// Set the parameters of the audiosources.
		engineSoundSource.minDistance = advanced.engineMinDistance;
		engineSoundSource.maxDistance = advanced.engineMaxDistance;
		engineSoundSource.loop = true;
		engineSoundSource.dopplerLevel = advanced.engineDopplerLevel;
		
		windSoundSource.minDistance = advanced.windMinDistance;
		windSoundSource.maxDistance = advanced.windMaxDistance;
		windSoundSource.loop = true;
		windSoundSource.dopplerLevel = advanced.windDopplerLevel;
		
        // Start the sounds playing.
		engineSoundSource.Play();
		windSoundSource.Play();	
	}
コード例 #35
0
 void Awake()
 {
     audioSource = GetComponent<AudioSource>();
     audioSource.clip = MenuSoundEffect;
     audioSource.Play();
     EventManager.StartListening( EventDictionary.ON_ENTER_GAME_STATE, OnEnterGame );
 }
コード例 #36
0
ファイル: Audio.cs プロジェクト: abhavgarg/Ratatoskr_final
 public void PlayMusic()
 {
     if (src.isPlaying)
     {
         return;
     }
     src.Play();
 }
コード例 #37
0
ファイル: RealTimeChating.cs プロジェクト: VRCMG/VRChat-2
    public void PlayAudio(byte[] ba)
    {
        int chan;

        float[] f = ToFloatArray(ba, out chan);
        audioSource.clip.SetData(f, 0);
        if (!audioSource.isPlaying)
        {
            audioSource.Play();
        }
    }
コード例 #38
0
 static public int Play(IntPtr l)
 {
     try {
         UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l);
         self.Play();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #39
0
 static public int Play__UInt64(IntPtr l)
 {
     try {
         UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l);
         System.UInt64           a1;
         checkType(l, 2, out a1);
         self.Play(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #40
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;
            }
        }
    }
コード例 #41
0
    private void CheckBatInGame()
    {
        float outOfBoundsBy = 0;
        float xSide         = 50 - halfBatLen;
        float zSide         = 130 - halfBatThick;

        if ((transform.position.x > xSide || transform.position.x < -xSide || transform.position.z < -zSide))
        {
            if (Math.Abs(transform.position.x) > xSide)
            {
                outOfBoundsBy = Math.Abs(transform.position.x) - xSide;
            }
            else if (transform.position.z < -zSide)
            {
                outOfBoundsBy = Math.Abs(transform.position.z) - zSide;
            }
        }

        if (outOfBoundsBy == 0 && wallCollideAudio.isPlaying)
        {
            wallCollideAudio.Pause();
            JoyconController.RumbleJoycon(0, 0, 0);
        }
        else if (!wallCollideAudio.isPlaying && outOfBoundsBy != 0)
        {
            wallCollideAudio.Play();
        }
        if (outOfBoundsBy != 0)
        {
            float rumbleAmp = 0;
            if (outOfBoundsBy < 10)
            {
                rumbleAmp = 0.4f;
            }
            else if (outOfBoundsBy < 30)
            {
                rumbleAmp = 0.7f;
            }
            else
            {
                rumbleAmp = 0.9f;
            }
            JoyconController.RumbleJoycon(90, 270, rumbleAmp);
            wallCollideAudio.volume = GameUtils.Scale(0, 45, 0.1f, 1, outOfBoundsBy);
        }
    }
コード例 #42
0
ファイル: AudioPreprocessor.cs プロジェクト: sulai1/VFX
        public void SetMicrophone(string device)
        {
            this.device      = device;
            audioSource.loop = true;
            audioSource.clip = Microphone.Start(device, audioSource.loop, 1, SampleRate);
            if (audioSource.clip == null)
            {
                Debug.Log($"Failed Loading Mic({device})");
            }
            int min;
            int max;

            Microphone.GetDeviceCaps(device, out min, out max);
            Debug.Log("Start recording" + min + " " + max);
            while (!(Microphone.GetPosition(null) > 0))
            {
                audioSource.Play();
            }
        }
        //Receive from inputs.
        public void Receive(Variable _value, Input _input)
        {
            if (_input.InputId == 0)
            {
                var newGameObject = UnityObjectsConvertions.ConvertToGameObject(_value.GetObject());
                if (newGameObject != null)
                {
                    var newAudioSource = newGameObject.GetComponent <UnityEngine.AudioSource> () as UnityEngine.AudioSource;
                    if (audioSource != null)
                    {
                        audioSource = newAudioSource;
                    }
                }
            }

            if (_input.InputId == 1 && audioSource != null)
            {
                audioSource.Play();
            }
        }
コード例 #44
0
    //plays an audio clip based on the options mentioned.//
    void playAudio(string name, string option)
    {
        //name and option verification.//
        name = name.Replace("\"", "");
        int index = -1;

        for (int i = 0; i < Data.data.sounds.Length; i++)
        {
            if (Data.data.sounds[i].rcname == name)
            {
                index = i; break;
            }
        }
        if (index < 0)
        {
            UnityEngine.Debug.Log(name + " audio clip not found!!!"); return;
        }
        if (option != "once" && option != "repeat")
        {
            UnityEngine.Debug.Log("invalid option " + option + "!!!"); return;
        }

        //creating a gameobject to play audio and destroying after finished playing.//
        UnityEngine.GameObject  audio = new UnityEngine.GameObject("audio player");
        UnityEngine.AudioSource src   = audio.AddComponent <UnityEngine.AudioSource>();
        if (option == "once")
        {
            src.PlayOneShot(Data.data.sounds[index].clip);
            DestroyScript ds = audio.AddComponent <DestroyScript>();
            ds.setTime(Data.data.sounds[index].clip.length + 5);
        }
        else
        {
            src.clip = Data.data.sounds[index].clip;
            src.Play();
            src.loop = true;
        }
    }
コード例 #45
0
            public void playGlobal(Vec3 position, Transform parent)
            {
                if (Global.Sfx.sfxVolume <= 0.0f)
                {
                    return;
                }

                GO obj = new GO();

                // Center in parent
                obj.transform.parent   = parent;
                obj.transform.position = position;

                AudioSource player = obj.AddComponent <AudioSource>();

                player.clip         = this.src;
                player.spatialBlend = 1.0f; // full-3D
                player.minDistance  = 0.5f;
                player.maxDistance  = 10.0f;
                player.volume       = Global.Sfx.sfxVolume;
                player.Play();
                obj.AddComponent <DestroyOnAudioDone>();
            }
    private void OnGestureDetected(object sender, GestureEventArgs e, int bodyIndex)
    {
        var isDetected = e.IsBodyTrackingIdValid && e.IsGestureDetected;

        if (_kinectManager && _kinectManager.IsInitialized() && _kinectManager.IsUserDetected())
        {
            long userId = _kinectManager.GetPrimaryUserID();

            if (_kinectManager.IsJointTracked(userId, (int)_jointFootRight) &&
                _kinectManager.IsJointTracked(userId, (int)_jointFootLeft))
            {
                float jointPosFootLeftHeight  = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootLeft).y;
                float jointPosFootRightHeight = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootRight).y;
                float jointPosFootLeftDepth   = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootLeft).z;
                float jointPosFootRightDepth  = _kinectManager.GetJointKinectPosition(userId, (int)_jointFootRight).z;

//				if ((jointPosFootLeftDepth > jointPosFootRightDepth - _footDepthTolerance) && (jointPosFootLeftDepth < jointPosFootRightDepth + _footDepthTolerance) &&
//				     (jointPosFootRightDepth > jointPosFootLeftDepth - _footDepthTolerance) && (jointPosFootRightDepth < jointPosFootLeftDepth + _footDepthTolerance))
//				{
//					_inStartingPosition = true;
//				}
//				else if (!_bothFeetUp)
//				{
//					_inStartingPosition = false;
//				}
                _inStartingPosition = true;

                rightFootHeightText.text = "R Height: " + jointPosFootRightHeight.ToString();
                leftFootHeightText.text  = "L Height: " + jointPosFootLeftHeight.ToString();
                rightFootDepthText.text  = "R Depth: " + jointPosFootRightDepth.ToString();
                leftFootDepthText.text   = "L Depth: " + jointPosFootLeftDepth.ToString();

                // Check if in starting position and foot currentFootHeight is between initialFootHeight + difference tolerance
                if (_inStartingPosition &&
                    (jointPosFootLeftHeight > _initialStartingHeightLeft + _startingHeightDifference) &&
                    (jointPosFootRightHeight > _initialStartingHeightRight + _startingHeightDifference))
                {
                    _bothFeetUp = true;
                }
                else
                {
                    _bothFeetUp = false;
                }
            }
        }
        // Check positions of joints of current exercise
        foreach (var check in UserDataObject.GetCurrentChecksArray())
        {
            if (_exerciseExecutionValidationManager.GetMethodToCheck(check))
            {
                checkItemList[Array.IndexOf(UserDataObject.GetCurrentChecksArray(), check)].checkToggle.isOn  = true;
                checkItemList[Array.IndexOf(UserDataObject.GetCurrentChecksArray(), check)].checkImage.sprite = Resources.Load <Sprite>("Images/Toggle");
                checkItemList[Array.IndexOf(UserDataObject.GetCurrentChecksArray(), check)].checkImage.color  = MainColors.ToggleIsOn();
                _methodCheckedArray[Array.IndexOf(UserDataObject.GetCurrentChecksArray(), check)]             = true;
            }
            else
            {
                checkItemList[Array.IndexOf(UserDataObject.GetCurrentChecksArray(), check)].checkToggle.isOn  = false;
                checkItemList[Array.IndexOf(UserDataObject.GetCurrentChecksArray(), check)].checkImage.sprite = Resources.Load <Sprite>("Images/IconNotChecked");
                checkItemList[Array.IndexOf(UserDataObject.GetCurrentChecksArray(), check)].checkImage.color  = MainColors.White();
                _methodCheckedArray[Array.IndexOf(UserDataObject.GetCurrentChecksArray(), check)]             = false;
                _checksPassed = false;
            }

            // Debug.Log(_exerciseExecutionValidationManager.GetMethodToCheck(check));
            armsUpText.text = _checksPassed.ToString();
        }

        bothFeetUpText.text = "DIFF: " + _startingHeightDifference + " |UP: " + _bothFeetUp + "| INPOS: " + _inStartingPosition;

        if (_exerciseExecutionValidationManager.LeftFootOnLine() || _exerciseExecutionValidationManager.RightFootOnLine())
        {
            if (CanvasHandCursor.activeSelf)
            {
                _interactionManager.enabled = false;
                CanvasHandCursor.gameObject.SetActive(false);
            }
        }
        // Discrete Gesture tracking
        if ((e.GestureType == GestureType.Discrete))
        {
            _gestureAccuracy = e.DetectionConfidence;

            for (int i = 0; i < _methodCheckedArray.Length; i++)
            {
                if (_methodCheckedArray[i] == false)
                {
                    _gestureAccuracy -= 0.1f;
                }
                testText.text = _gestureAccuracy.ToString();
            }

            if (_gestureAccuracy > 1.0f)
            {
                _gestureAccuracy = 1.0f;
            }
            _durationManager.SetProgress(_gestureAccuracy);

            if (GestureDetected(_gestureAccuracy, 0.4f, 1f) && _bothFeetUp)
            {
                if (CanvasHandCursor.activeSelf)
                {
                    _interactionManager.enabled = false;
                    CanvasHandCursor.gameObject.SetActive(false);
                }

                _durationManager.StartTimer();

                if (MinTimeReached())
                {
                    audioSuccess.Play();

                    if (_currentRepetition == UserDataObject.GetCurrentRepetitionsArray().Last())
                    {
                        Debug.Log("LASTREP");
                        successMainText.text = "Exercise finished!";
                        successSubText.text  = "Preparing next exercise";
                        StartCoroutine("StartLastAnimateSuccess");
                    }
                    else
                    {
                        StartCoroutine("StartAnimateSuccess");
                    }
                }

                confidenceIterator++;
                _currentRepetitionConfidence += _gestureAccuracy * 100;

//				testText.text = "if DISCRETE: " +  e.IsGestureDetected.ToString() + " " + _gestureAccuracy;
            }
            else
            {
                if (_durationManager.IsTimerRunning() && _durationManager.GetlatestTimeInSeconds() <= _currentRepetition.minTime)
                {
                    audioFail.Play();
                    Debug.Log("Activate handcursor");

//					if (!CanvasHandCursor.activeSelf)
//					{
//						CanvasHandCursor.gameObject.SetActive(true);
//						_interactionManager.enabled = true;
//					}
                }

                if (_durationManager.IsTimerRunning())
                {
                    attemptsIterator++;
                }
                _durationManager.StopTimer();

                // if tracked time is greater than given time of the repetition
                if (_durationManager.GetlatestTimeInSeconds() >= _currentRepetition.minTime)
                {
                    _repsIterator += 1;
                    ToggleAndCheckRepetition();
                }

//				testText.text = "else DISCRETE: " +  e.IsGestureDetected.ToString() + " " + _gestureAccuracy;
            }
//				testText.text = "DISCRETE: " +  e.IsGestureDetected.ToString() + " " + e.DetectionConfidence;
        }
        else if ((e.GestureType == GestureType.Continuous))
        {
            _gestureAccuracy = e.Progress;

            for (int i = 0; i < _methodCheckedArray.Length; i++)
            {
                if (_methodCheckedArray[i] == false)
                {
                    _gestureAccuracy -= 0.1f;
                }
                testText.text = _gestureAccuracy.ToString();
            }

            if (_gestureAccuracy > 1.0f)
            {
                _gestureAccuracy = 1.0f;
            }
            _durationManager.SetProgress(_gestureAccuracy);

//			if (_thirdCheckpoint)
//			{
//				_durationManager.StartTimer();
//
//				confidenceIterator++;
//				_currentRepetitionConfidence += e.Progress * 100;
//
//				if (e.Progress <= 0.4f)
//				{
//					Debug.Log(e.Progress);
//					if (_durationManager.IsTimerRunning())
//					{
//						_currentRepetition.attempts++;
//						Debug.Log("CURRENT REPETITION ATTEMPT: " + _currentRepetition.attempts);
//
//					}
//
//					_durationManager.StopTimer();
//
//					_thirdCheckpoint = false;
//
//					// if tracked time is greater than given time of the repetition
//					if (_durationManager.GetlatestTimeInSeconds() >= _currentRepetition.minTime)
//					{
//						ToggleAndCheckRepetition();
//					}
//				}
//			}
//			else
//			{
//				if (_secondCheckpoint && GestureDetected(e.Progress, 0.7f, 1f))
//				{
//					_thirdCheckpoint = true;
//				}
//				else if (_firstCheckpoint && GestureDetected(e.Progress, 0.4f, 0.7f))

//				Debug.Log(_bothFeetUp +  " | " + _gestureAccuracy + " | " + e.Progress + " | "+ GestureDetected(_gestureAccuracy, 0.7f, 1f) + " | " + GestureDetected(e.Progress, 0.7f, 1f));

            if (GestureDetected(_gestureAccuracy, _progressMinConfidence, 1f) && _bothFeetUp)
            {
                if (CanvasHandCursor.activeSelf)
                {
                    _interactionManager.enabled = false;
                    CanvasHandCursor.gameObject.SetActive(false);
                }
                _durationManager.StartTimer();

                if (MinTimeReached())
                {
                    audioSuccess.Play();

                    if (_currentRepetition == UserDataObject.GetCurrentRepetitionsArray().Last())
                    {
                        Debug.Log("LASTREP");

                        successMainText.text = "Exercise finished!";
                        successSubText.text  = "Preparing next exercise";
                        StartCoroutine("StartLastAnimateSuccess");
                    }
                    else
                    {
                        StartCoroutine("StartAnimateSuccess");
                    }
                }

                confidenceIterator++;
                _currentRepetitionConfidence += _gestureAccuracy * 100;

//					testText.text = "if CONTINUOUS: " + _gestureAccuracy;
            }
            else
            {
                if (_durationManager.IsTimerRunning() && _durationManager.GetlatestTimeInSeconds() <= _currentRepetition.minTime)
                {
                    audioFail.Play();
                    Debug.Log("Activate handcursor");
//						if (!CanvasHandCursor.activeSelf)
//						{
//							CanvasHandCursor.gameObject.SetActive(true);
//							_interactionManager.enabled = true;
//						}
                }

                if (_durationManager.IsTimerRunning())
                {
                    attemptsIterator++;
                    Debug.Log("CURRENT REPETITION ATTEMPT: " + attemptsIterator);
                    _durationManager.StopTimer();
                }

                // if tracked time is greater than given time of the repetition
                if (_durationManager.GetlatestTimeInSeconds() >= _currentRepetition.minTime)
                {
                    _repsIterator += 1;
                    ToggleAndCheckRepetition();
                }

//					testText.text = "else CONTINUOUS: " + _gestureAccuracy;
            }
//			}
        }
    }
コード例 #47
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++;
                //		}
            }
        }
    }
コード例 #48
0
 private void PlayBatUpAudio()
 {
     batUpAudio.Play();
     batUpOnce = false;
 }
コード例 #49
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);
                        }
                    }
                }
            }
        }
    }
コード例 #50
0
 public void footstep(int _num)
 {
     sound.clip = footsounds[_num];
     sound.Play();
 }
コード例 #51
0
ファイル: DetectJoints.cs プロジェクト: Alex23013/DuelofFates
    // Use this for initialization
    void Start()
    {
        count   = 0;
        _sensor = KinectSensor.GetDefault();

        if (_sensor != null)
        {
            _sensor.Open();

            _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body);
            _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;
        }
        if (BodySrcManager == null)
        {
            Debug.Log("Assign Game Object with Body Source Manager");
        }
        else
        {
            bodyManager = BodySrcManager.GetComponent <BodySourceManager>();
        }
        line    = gameObject.AddComponent <LineRenderer>();
        source  = gameObject.GetComponent <UnityEngine.AudioSource> ();
        source1 = gameObject.AddComponent <UnityEngine.AudioSource> ();

        laser1 = new GameObject("Laser1").AddComponent <LineRenderer>();
        laser2 = new GameObject("Laser2").AddComponent <LineRenderer>();
        laser3 = new GameObject("Laser3").AddComponent <LineRenderer>();
        start  = new Vector3(0.0f, 0.0f);
        end    = new Vector3(0.5f, 0.5f);

        profLaser1    = 0.9f;
        profLaser1end = profLaser1 + 0.2f;
        profLaser2    = 0.9f;
        profLaser2end = 0.7f;
        profLaser3    = 0.9f;
        profLaser3end = 0.7f;

        laser1x     = 0.1f * multiplier;
        laser1y     = 0.4f * multiplier;
        startLaser1 = new Vector3(laser1x, laser1y, profLaser1 * multiplier);
        endLaser1   = new Vector3(laser1x, laser1y, profLaser1end * multiplier);

        startLaser2 = new Vector3(0.2f * multiplier, 0.2f * multiplier, profLaser2 * multiplier);
        endLaser2   = new Vector3(0.21f * multiplier, 0.21f * multiplier, profLaser2end * multiplier);
        Debug.Log(string.Format("Laser2startX: {0},startY: {1}", 0.2f * multiplier, 0.2f * multiplier));
        Debug.Log(string.Format("endX: {0},endY: {1}", 0.21f * multiplier, 0.2f * multiplier));

        startLaser3 = new Vector3(0.2f * multiplier, 0.4f * multiplier, profLaser3 * multiplier);
        endLaser3   = new Vector3(0.21f * multiplier, -0.3f * multiplier, profLaser3end * multiplier);
        //Debug.Log(string.Format("start3X: {0},start3Y: {1}", 0.2f * multiplier, 0.4f * multiplier));
        //Debug.Log(string.Format("end3X: {0},end3Y: {1}", 0.21f * multiplier, -0.3f * multiplier));
        configureLine(line);
        configureLine(laser1);
        configureLine(laser2);
        configureLine(laser3);

        setPosLineRenderer(line, start, end);
        setPosLineRenderer(laser1, startLaser1, endLaser1);
        setPosLineRenderer(laser2, startLaser2, endLaser2);
        setPosLineRenderer(laser3, startLaser3, endLaser3);

        sword       = Resources.Load("Materials/LaserMat", typeof(Material)) as Material;
        clip        = Resources.Load("Materials/fx4", typeof(AudioClip)) as AudioClip;
        source.clip = clip;
        source.Play();

        //sword1 = Resources.Load("Materials/laser", typeof(Image)) as Texture2D;


        if (sword != null)
        {
            line.material = sword;
        }
        sword1 = Resources.Load("Materials/LaserMat1", typeof(Material)) as Material;
        if (sword1 != null)
        {
            laser1.material = sword1;
        }
        if (sword1 != null)
        {
            laser2.material = sword1;
        }
        if (sword1 != null)
        {
            laser3.material = sword1;
        }
        //if (sword1 != null) line.material.mainTexture = sword1;
    }