// 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]); } }
void Update() { body = GetActiveBody(); if (body != null) { //trackBody(body); } Debug.Log("Player Detected: " + playerDetected); if (playerDetected == true) { GameObject.Find("PlayerDetectedGUI").GetComponent <GUIText>().enabled = true; if (!detectTrueAudio) { audioSource.PlayOneShot(bodyDetected_true); detectTrueAudio = true; } detectFalseAudio = false; } else if (playerDetected == false) { GameObject.Find("PlayerDetectedGUI").GetComponent <GUIText>().enabled = false; detectTrueAudio = false; if (!detectFalseAudio) { audioSource.PlayOneShot(bodyDetected_false); detectFalseAudio = true; } detectTrueAudio = false; } }
IEnumerator ToggleDoor () { m_Audio = audio; Debug.Log ("Toggling door"); if ((moving == false) & (door_open)) { Debug.Log ("closing"); moving = true; // play the start sound, if any if (SoundCloseDoors != null) m_Audio.PlayOneShot(SoundCloseDoors); door.transform.Find ("Door_Top").animation.Play ("top_close"); door.transform.Find ("Door_Bot").animation.Play ("bot_close"); yield return new WaitForSeconds(2); IsClose(); } else if ((moving == false) & (door_open == false)) { Debug.Log ("opening"); moving = true; // play the start sound, if any if (SoundCloseDoors != null) m_Audio.PlayOneShot(SoundCloseDoors); door.transform.Find ("Door_Top").animation.Play ("top_open"); door.transform.Find ("Door_Bot").animation.Play ("bot_open"); yield return new WaitForSeconds(2); IsOpen(); } }
public override void OnEnter() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go != null) { // cache the AudioSource component audio = go.audio; if (audio != null) { if (oneShotClip == null) { audio.Play(); if (!volume.IsNone) audio.volume = volume.Value; return; } else { if (!volume.IsNone) audio.PlayOneShot(oneShotClip, volume.Value); else audio.PlayOneShot(oneShotClip); return; } } } // Finish if failed to play sound Finish(); }
IEnumerator ToggleDoors () { m_Audio = audio; Debug.Log ("Toggling doors"); if ((moving == false) & (down)) { moving = true; // play the start sound, if any if (SoundCloseDoors != null) m_Audio.PlayOneShot(SoundCloseDoors); GameObject.Find ("DoorElevator1_down").animation.Play ("close"); GameObject.Find ("DoorElevator1_inside_down").animation.Play ("close"); yield return new WaitForSeconds(2); Platform.SendMessage("GoTo", Platform.TargetedWaypoint == 0 ? 1 : 0, SendMessageOptions.DontRequireReceiver); yield return new WaitForSeconds(3); IsUp (); } else if ((moving == false) & (down == false)) { moving = true; if (SoundCloseDoors != null) m_Audio.PlayOneShot(SoundCloseDoors); GameObject.Find("DoorElevator1_up").animation.Play("close"); GameObject.Find("DoorElevator1_inside_up").animation.Play("close"); yield return new WaitForSeconds(2); Platform.SendMessage("GoTo", Platform.TargetedWaypoint == 0 ? 1 : 0, SendMessageOptions.DontRequireReceiver); yield return new WaitForSeconds(3); IsDown (); } }
IEnumerator ToggleDoors () { m_Audio = audio; Debug.Log ("Toggling doors"); if ((moving == false) & (down)) { Debug.Log ("Going UP"); moving = true; // play the start sound, if any if (SoundCloseDoors != null) m_Audio.PlayOneShot (SoundCloseDoors); DoorFence.animation.Play ("close"); OutsideDoorBot.transform.Find ("Door_Bot").animation.Play ("bot_close"); OutsideDoorBot.transform.Find ("Door_Top").animation.Play ("top_close"); yield return new WaitForSeconds (2); Platform.SendMessage ("GoTo", Platform.TargetedWaypoint == 0 ? 1 : 0, SendMessageOptions.DontRequireReceiver); yield return new WaitForSeconds (54); // 17 para 0.01 de velocidad. 54 para 0.002 IsUp (); } else if ((moving == false) & (down == false)) { Debug.Log ("Going DOWN"); moving = true; if (SoundCloseDoors != null) m_Audio.PlayOneShot (SoundCloseDoors); DoorFence.animation.Play ("close"); OutsideDoorTop.transform.Find ("Door_Top").animation.Play ("top_close"); OutsideDoorTop.transform.Find ("Door_Bot").animation.Play ("bot_close"); yield return new WaitForSeconds (2); Platform.SendMessage ("GoTo", Platform.TargetedWaypoint == 0 ? 1 : 0, SendMessageOptions.DontRequireReceiver); yield return new WaitForSeconds (54); // 17 para 0.01 de velocidad. 54 para 0.002 IsDown (); } else { Debug.Log ("Error"); } }
// PlayJumpingSound internal void PlayJumpingSound( string groundTag, ref AudioSource m_Audio, float volumeScale ) { m_Audio.pitch = Time.timeScale; switch( groundTag ) { case TagsManager.matConcrete: m_Audio.PlayOneShot( matConcrete.jumpingSound, volumeScale ); break; case TagsManager.matGravel: m_Audio.PlayOneShot( matGravel.jumpingSound, volumeScale ); break; case TagsManager.matMetal: m_Audio.PlayOneShot( matMetal.jumpingSound, volumeScale ); break; case TagsManager.matWood: m_Audio.PlayOneShot( matWood.jumpingSound, volumeScale ); break; default: m_Audio.PlayOneShot( genericMat.jumpingSound, volumeScale ); break; } }
private void StartSuccessSequence() { state = State.Transcending; audioSource.Stop(); audioSource.PlayOneShot(success); successParticles.Play(); Invoke("LoadNextLevel", levelLoadDelay); // parameterise time }
public IEnumerator PlayGetTakenOverSound(AudioSource source) { float delay = 0.08f; source.PlayOneShot(GetNote(8)); yield return new WaitForSeconds(delay); source.PlayOneShot(GetNote(7)); yield return new WaitForSeconds(delay); source.PlayOneShot(GetNote(6)); }
public AudioSource playSound(SoundClips clip, AudioSource source) { if (source == null) { source = gameObject.AddComponent<AudioSource>(); source.PlayOneShot(mAudioClips [(int)clip]); Destroy(source,mAudioClips [(int)clip].length + 1); } else { source.PlayOneShot (mAudioClips [(int)clip]); } return source; }
// Use this for initialization void Start() { player = GameObject.Find ("Player"); objCnt = 0; dieTimer = 0.0f; duration = 0.0f; audio = GetComponent<AudioSource>(); audio.PlayOneShot (aDown, 0.4f); audio.PlayOneShot (aAttack, 0.4f); }
void PlayStepSound(UnityEngine.AudioClip stepsound) { if (m_AudioSource != null) { m_AudioSource.PlayOneShot(stepsound); } }
// Use this for initialization void Start () { flag = 0; temp = renderer as SpriteRenderer; m_sound = this.audio; m_sound.PlayOneShot (sound); }
void Start() { startTime = Time.time; pEmitters = gameObject.GetComponentsInChildren<KSPParticleEmitter>(); foreach(KSPParticleEmitter pe in pEmitters) { pe.emit = true; pe.force = (4.49f * FlightGlobals.getGeeForceAtPosition(transform.position)); if(pe.maxEnergy > maxTime) { maxTime = pe.maxEnergy; } } lightFX = gameObject.AddComponent<Light>(); lightFX.color = Misc.ParseColor255("255,238,184,255"); lightFX.intensity = 8; lightFX.range = 50; exSound = GameDatabase.Instance.GetAudioClip("BDArmory/Sounds/explode1"); audioSource = gameObject.AddComponent<AudioSource>(); audioSource.minDistance = 20; audioSource.maxDistance = 1000; audioSource.volume = Mathf.Sqrt(GameSettings.SHIP_VOLUME); audioSource.PlayOneShot(exSound); }
// Use this for initialization void Start () { supportive = GetComponent<AudioSource>(); // This is some instantiation. // We want it so that if the player is within a + direction from the particle, they will get hurt. GameObject player = GameObject.FindGameObjectWithTag("Player"); int playerX = (int)player.transform.position.x; int playerY = (int)player.transform.position.y; Coord myPlace = new Coord((int)this.transform.position.x, (int)this.transform.position.y); Coord playerCoord = new Coord(playerX, playerY); Coord n, w, s, e; n = playerCoord.nextCoord (Direction.North); w = playerCoord.nextCoord (Direction.West); s = playerCoord.nextCoord (Direction.South); e = playerCoord.nextCoord (Direction.East); if( myPlace.isEqual (playerCoord) || myPlace.isEqual (n) || myPlace.isEqual (w) || myPlace.isEqual (s) || myPlace.isEqual (e) ) { PlayerMovement hitPlayer = player.GetComponent<PlayerMovement>(); supportive.PlayOneShot(haha,1f); hitPlayer.LoseHealth(750); } Destroy (this.gameObject, 3); }
// Use this for initialization void Start () { Cat = GameObject.FindObjectOfType<PlayerController>(); audioSource = gameObject.GetComponent<AudioSource>(); SinusAmpRatio = Random.RandomRange(0, 0.25f); SinusFreqRatio = Random.RandomRange(0, 2f); transform.localScale = new Vector3(transform.localScale.x * Random.value > 0.5f ? 1 : -1, transform.localScale.y, transform.localScale.z); float distance = transform.position.z - Camera.main.transform.position.z; Vector3 leftMostCamera = Camera.main.ViewportToWorldPoint(new Vector3(0.0f, 0, distance)); Vector3 rightMostCamera = Camera.main.ViewportToWorldPoint(new Vector3(1f, 0, distance)); Vector3 topMostCamera = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance)); Vector3 botMostCamera = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, distance)); print(rightMostCamera.x); x_min = leftMostCamera.x + X_sprite_padding; x_max = rightMostCamera.x - X_sprite_padding; y_min = topMostCamera.y + Y_sprite_padding; y_max = botMostCamera.y - Y_sprite_padding; float x_speed = Random.Range(0, Speed); float y_speed = Speed - x_speed; speed_vector = new Vector3(x_speed, y_speed,0); audioSource.PlayOneShot(SpawnSound); InvokeRepeating("SpontaniusDirectionChange", 3f, 3f); }
// Use this for initialization void Start () { gm = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameManagerScript>(); source = GetComponentInChildren<AudioSource>(); rb = GetComponent<Rigidbody2D>(); rend = GetComponentInChildren<Renderer>(); circleCollider = GetComponent<CircleCollider2D>(); letter = GetComponentInChildren<TextMesh>(); char[] alphabet = "AABCDEEEFGHIIJKLMNOOPQRSTUVWXYZ".ToCharArray(); int randomLetter = Random.Range(0, alphabet.Length); letter.text = alphabet[randomLetter].ToString(); if ("AEIOU".Contains(letter.text)) { letter.color = vowelColor; } timeToLive = Time.time + timeToLive; rb.drag = 0; float x = Random.Range(-1.0f, 1.0f); float y = Random.Range(-1.0f, 1.0f); int speed = Random.Range(50, 150); source.PlayOneShot(bubbleSpawn, .5f); rb.AddForce(new Vector2(x, y) * speed); }
public void Explode(Weapon sourceWeapon) { if(hasExploded) { return; } audioPlayer = GetComponent<AudioSource>(); Collider2D[] overlaps = Physics2D.OverlapCircleAll(transform.position, explosionRadius); for(int i = 0; i < overlaps.Length; i++) { Actor mech = overlaps[i].GetComponent<Actor>(); if(mech != null) { mech.TakeDamage(baseDamage, sourceWeapon != null? sourceWeapon.owner.GetComponent<MechController>() : null, sourceWeapon); } } // Create the effect if(explosionEffectPrefab != null) { Animator explosionAnimator = (Animator)Instantiate(explosionEffectPrefab, transform.position, Quaternion.identity); Destroy(explosionAnimator.gameObject, 0.3f); } if(explosionParticlePrefab != null) { GameObject spawned = WorldManager.instance.SpawnObject(explosionParticlePrefab.gameObject, transform.position); ParticleSystem explosionEffect = spawned.GetComponent<ParticleSystem>(); //(ParticleSystem)Instantiate(explosionParticlePrefab, transform.position, Quaternion.identity); explosionEffect.Play(); } if(audioPlayer != null && explodeSound != null) { audioPlayer.PlayOneShot(explodeSound); } explodedTime = Time.time; hasExploded = true; }
IEnumerator Start() { spaceship = GetComponent<Spaceship> (); common = GetComponent<EnemyCommon>(); common.Init(); Transform s1 = common.CreateShotPosition(); //SE関係 audioSource = gameObject.GetComponent<AudioSource>(); audioSource.clip = shootSE; // yield return new WaitForEndOfFrame(); while (true) { audioSource.PlayOneShot(shootSE); common.Shot(s1, 0+30, power, speed, BulletManager.BulletType.BlossomBullet); common.Shot(s1, 60 + 30, power, speed, BulletManager.BulletType.BlossomBullet); common.Shot(s1, 120 + 30, power, speed, BulletManager.BulletType.BlossomBullet); common.Shot(s1, 180 + 30, power, speed, BulletManager.BulletType.BlossomBullet); common.Shot(s1, 240 + 30, power, speed, BulletManager.BulletType.BlossomBullet); common.Shot(s1, 300 + 30, power, speed, BulletManager.BulletType.BlossomBullet); yield return new WaitForSeconds(spaceship.shotDelay); } }
private void OnTriggerEnter2D(Collider2D collision) { if (gameObject.CompareTag(collision.gameObject.tag)) { m_game.Deploy(); m_game.Score++; audioSource.PlayOneShot(sound1); audioSource.PlayOneShot(sound2); } else { m_enableInput = false; StartCoroutine(DisableInputCoroutine()); audioSource.PlayOneShot(sound3); } }
//Setters void Start(){ animator = GetComponent<Animator>(); body = GetComponent<Rigidbody2D>(); audSource = GetComponent<AudioSource> (); audSource.PlayOneShot (castClip [Random.Range (0, castClip.Length)]); }
static public int PlayOneShot(IntPtr l) { try{ if (matchType(l, 2, typeof(UnityEngine.AudioClip), typeof(float))) { UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l); UnityEngine.AudioClip a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); self.PlayOneShot(a1, a2); return(0); } else if (matchType(l, 2, typeof(UnityEngine.AudioClip))) { UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l); UnityEngine.AudioClip a1; checkType(l, 2, out a1); self.PlayOneShot(a1); 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); } }
static int PlayOneShot(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { UnityEngine.AudioSource obj = (UnityEngine.AudioSource)ToLua.CheckObject <UnityEngine.AudioSource>(L, 1); UnityEngine.AudioClip arg0 = (UnityEngine.AudioClip)ToLua.CheckObject <UnityEngine.AudioClip>(L, 2); obj.PlayOneShot(arg0); return(0); } else if (count == 3) { UnityEngine.AudioSource obj = (UnityEngine.AudioSource)ToLua.CheckObject <UnityEngine.AudioSource>(L, 1); UnityEngine.AudioClip arg0 = (UnityEngine.AudioClip)ToLua.CheckObject <UnityEngine.AudioClip>(L, 2); float arg1 = (float)LuaDLL.luaL_checknumber(L, 3); obj.PlayOneShot(arg0, arg1); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.AudioSource.PlayOneShot")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
//static GameObject go = GameDatabase.Instance.GetModel("BDArmory/Models/bulletHit/bulletHit"); //===TODO: static object wont load after scene reload void Start() { startTime = Time.time; pEmitters = gameObject.GetComponentsInChildren<KSPParticleEmitter>(); audioSource = gameObject.AddComponent<AudioSource>(); audioSource.minDistance = 1; audioSource.maxDistance = 50; audioSource.spatialBlend = 1; audioSource.volume = BDArmorySettings.BDARMORY_WEAPONS_VOLUME; int random = UnityEngine.Random.Range(1,3); if(ricochet) { string path = "BDArmory/Sounds/ricochet" + random; hitSound = GameDatabase.Instance.GetAudioClip(path); } else { string path = "BDArmory/Sounds/bulletHit" + random; hitSound = GameDatabase.Instance.GetAudioClip(path); } audioSource.PlayOneShot(hitSound); }
static public int PlayOneShot(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 2) { UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l); UnityEngine.AudioClip a1; checkType(l, 2, out a1); self.PlayOneShot(a1); pushValue(l, true); return(1); } else if (argc == 3) { UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l); UnityEngine.AudioClip a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); self.PlayOneShot(a1, a2); 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 OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Player") { Destroy(this.gameObject); playerAttack = coll.GetComponent<PlayerAttackScript>(); playerAudioSource = coll.GetComponent<AudioSource>(); playerAudioSource.PlayOneShot(playerAttack.pickUpSound); if (thisPower == "Freeze") { playerAttack.freezePowerReady = true; } else if (thisPower == "Wind") { playerAttack.windPowerReady = true; } else if (thisPower == "Speed") { playerAttack.speedPowerReady = true; } else if (thisPower == "Shield") { playerAttack.shieldPowerReady = true; } } }
static int PlayOneShot(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.AudioSource), typeof(UnityEngine.AudioClip))) { UnityEngine.AudioSource obj = (UnityEngine.AudioSource)ToLua.ToObject(L, 1); UnityEngine.AudioClip arg0 = (UnityEngine.AudioClip)ToLua.ToObject(L, 2); obj.PlayOneShot(arg0); return(0); } else if (count == 3 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.AudioSource), typeof(UnityEngine.AudioClip), typeof(float))) { UnityEngine.AudioSource obj = (UnityEngine.AudioSource)ToLua.ToObject(L, 1); UnityEngine.AudioClip arg0 = (UnityEngine.AudioClip)ToLua.ToObject(L, 2); float arg1 = (float)LuaDLL.lua_tonumber(L, 3); obj.PlayOneShot(arg0, arg1); return(0); } else { return(LuaDLL.tolua_error(L, "invalid arguments to method: UnityEngine.AudioSource.PlayOneShot")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
void OnShoot() { gunshot = Resources.Load<AudioClip>("Sounds/gunfire"); source = GetComponent<AudioSource>(); source.PlayOneShot(gunshot); }
public static void PlaySoundOneShot(AudioClip audioClip, float volumeScale, AudioSource audioSource) { if(gameSounds == GameSounds.enabled) { audioSource.PlayOneShot(audioClip, volumeScale); } }
void Start() { source = GetComponent<AudioSource>(); System.Random rnd = new System.Random(); int number = rnd.Next(0, 1); source.PlayOneShot(startBattleSound[number]); }
public static void PlaySoundOneShot(AudioClip audioClip, AudioSource audioSource) { if (gameSounds == GameSounds.enabled) { audioSource.PlayOneShot(audioClip); } }
IEnumerator Start() { grid = FindObjectOfType<Grid>(); AudioSource = FindObjectOfType<AudioSource>(); while (isValidGridPos()) { yield return new WaitForSeconds(1); transform.Translate(0, -100f, 0, Space.World); if (!isValidGridPos()) { transform.Translate(0, 100f, 0, Space.World); GameMaster.CanMove = false; updateGrid(); break; } if (transform.name == "ColoredBall(Clone)") { AudioSource.PlayOneShot(ColoredballSound); } updateGrid(); } if (GameMaster.GameOver) { Destroy(gameObject); } }
// Use this for initialization void Start() { animator = gameObject.GetComponent<Animator>(); rb = gameObject.GetComponent<Rigidbody2D>(); source = gameObject.GetComponent<AudioSource>(); source.PlayOneShot(shoot); }
public static void play(AudioSource aus,AudioClip[] clips,float scale) { AudioClip clip=U.choose(clips) as AudioClip; // System.Collections.Generic.Dictionary<AudioClip,Alarm> dic=dic; if(!clip||!(!dic.ContainsKey(clip)||dic[clip].a))return; dic[clip]=new Alarm(0.2f); aus.PlayOneShot(clip,scale); }
IEnumerator playSoundThenLoad(int scene) { audioSource = GetComponent<AudioSource>(); audioSource.PlayOneShot(audioSource.clip); yield return new WaitForSeconds(audioSource.clip.length - (float)1.63); // 1.63 length of silence in sound clip Application.LoadLevel(scene); }
// 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(); }
public void play(AudioSource source, AudioType type) { if (canPlay (type)) { source.PlayOneShot (source.clip); audiosPlaying [type] = audiosPlaying [type] + 1; StartCoroutine (decrementAudiosPlaying (type, source.clip.length)); } }
void Start() { #if UNITY_5 audio = GetComponent<AudioSource>(); #endif audio.PlayOneShot(sound); }
public void PlayRandomAudioClip() { if (audioSource == null) { return; } audioSource.PlayOneShot(audioClips.GetRandom()); }
static public int PlayOneShot__AudioClip(IntPtr l) { try { UnityEngine.AudioSource self = (UnityEngine.AudioSource)checkSelf(l); UnityEngine.AudioClip a1; checkType(l, 2, out a1); self.PlayOneShot(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
// Detect collision with Red Guy void OnCollisionEnter(Collision col) { if (col.gameObject.name == "RedGuy" && hm.isBlueAttacking == true) { if (canHit == true) { /* ================================================================================================================ * NOTE * Health bars were switched on screen so when blue guy hits he's actually taking health off himself * but on screen the health bars are placed over other player to give impresssion the other player is losing health * ================================================================================================================ */ if (hm.isBlueBlocking == false) { // Keeping track of blue guy health hm.blueHealth -= hm.damage; // Play animation that shows player being knocked back after gettng hit p2.takenHit(); // Play hit sound source.PlayOneShot(hitSound, 1); //source.PlayOneShot(anotherSound, 1); //Slap Sound Effect // Deplete health bar health_bar.IncrimentBar(hm.damage); // Update the health bar health_bar.Update(); // Reset is attacking value hm.isBlueAttacking = false; } if (hm.isRedBlocking == true) { // Start coroutine that delays isRedBlocking variable StartCoroutine(BlockCoroutine()); } // Reset timer _hitTimer = 0; } } // End outer if } // End OnCollisionEnter
// Update is called once per frame void Update() { // process bodies bool newBodyData = false; // Get the latest frame using (BodyFrame bodyFrame = this.bodyFrameReader.AcquireLatestFrame()) { if (bodyFrame != null) { bodyFrame.GetAndRefreshBodyData(this.bodies); newBodyData = true; }// End if if (newBodyData) { // update gesture detectors with the correct tracking id for (int bodyIndex = 0; bodyIndex < this.bodyCount; bodyIndex++) { var body = this.bodies[bodyIndex]; if (body != null) { if (body.IsTracked) { if (body.HandRightState == HandState.Open) { // Play sound to show hand gesture worked source.PlayOneShot(menuBeep, 1f); OnApplicationQuit(); SceneManager.LoadScene("Main"); } } } } } } // End using } // End Update
//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; } }
public virtual void UpdateMovement() { if (HaltUpdateMovement) { return; } bool moveForward = Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow); bool moveLeft = Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow); bool moveRight = Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow); bool moveBack = Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow); bool moveUp = Input.GetKey(KeyCode.T); bool moveDown = Input.GetKey(KeyCode.G); bool zoomIn = Input.GetAxis("Mouse ScrollWheel") > 0; bool zoomOut = Input.GetAxis("Mouse ScrollWheel") < 0; MoveScale = 1.0f; if ((moveForward && moveLeft) || (moveForward && moveRight) || (moveBack && moveLeft) || (moveBack && moveRight)) { MoveScale = 0.70710678f; } MoveScale *= SimulationRate * Time.deltaTime; // Compute this for key movement float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; Quaternion ort = (HmdRotatesY) ? CameraController.centerEyeAnchor.rotation : transform.rotation; Vector3 ortEuler = ort.eulerAngles; ortEuler.z = ortEuler.x = 0f; ort = Quaternion.Euler(ortEuler); if (moveForward) { MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * Vector3.forward); } if (moveBack) { MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back); } if (moveLeft) { MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left); } if (moveRight) { MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right); } if (moveUp) { MoveThrottle += ort * (transform.lossyScale.y * moveInfluence * Vector3.up); } if (moveDown) { MoveThrottle += ort * (transform.lossyScale.y * moveInfluence * BackAndSideDampen * Vector3.down); } if (zoomIn) { Camera leftCamera = CameraController.leftEyeAnchor.GetComponent <Camera> (); Camera rightCamera = CameraController.rightEyeAnchor.GetComponent <Camera> (); if (leftCamera.fieldOfView > 2) { leftCamera.fieldOfView -= 2; } if (rightCamera.fieldOfView > 2) { rightCamera.fieldOfView -= 2; } } if (zoomOut) { Camera leftCamera = CameraController.leftEyeAnchor.GetComponent <Camera> (); Camera rightCamera = CameraController.rightEyeAnchor.GetComponent <Camera> (); if (leftCamera.fieldOfView < 99) { leftCamera.fieldOfView += 2; } if (rightCamera.fieldOfView < 99) { rightCamera.fieldOfView += 2; } } //toggle if (Input.GetKey(KeyCode.R) & buttonPushed < Time.time - 0.2f) //show hide ribbons { if (addAtoms.ribbonShowing) { addAtoms.ribbonShowing = addAtoms.resetProtein("ribbons"); } else { addAtoms.ribbonShowing = addAtoms.showMode("ribbons"); } buttonPushed = Time.time; } if (Input.GetKey(KeyCode.N) & buttonPushed < Time.time - 0.2f) //menu { source.PlayOneShot(menuToggled, 0.5f); menu.enabled = !menu.enabled; //hide show menu buttonPushed = Time.time; } if (Input.GetKey(KeyCode.V) & buttonPushed < Time.time - 0.2f) //center { addAtoms.setPosition(ort * Vector3.forward * 30 + this.transform.position); //centers the atoms infront of the user buttonPushed = Time.time; } if (Input.GetKey(KeyCode.L) & buttonPushed < Time.time - 0.2f) //screenshot { Application.CaptureScreenshot(Application.dataPath + "/Screenshot.png", 4); buttonPushed = Time.time; } if (Input.GetKey(KeyCode.X) & buttonPushed < Time.time - 0.2f) //reset center { addAtoms.resetTarget(); buttonPushed = Time.time; } if (Input.GetKey(KeyCode.Z) & buttonPushed < Time.time - 0.2f) //lock target { addAtoms.lockTarget(); buttonPushed = Time.time; } if (Input.GetKey(KeyCode.P) & buttonPushed < Time.time - 0.2f) // change driver { bool newDriver = false; foreach (var user in trackedUsers) { if (user == null) { continue; } if (user.IsTracked) { if (driver == user.TrackingId) { newDriver = true; continue; } if (newDriver) { setDriver(user.TrackingId); newDriver = false; break; } } } if (newDriver) //iterate once more if a new driver wasn't selected { foreach (var user in trackedUsers) { if (user == null) { continue; } if (user.IsTracked) { if (newDriver) { setDriver(user.TrackingId); break; } } } } } moveInfluence = SimulationRate * Time.deltaTime * Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; }