public void sound3() { sound_3.GetComponent <AudioSource>().Play(); }
//############################################################################################## // This is the primary function for how a sound is set up and played TODO TODO // // This function returns the sound id of the record, for reference later. For example, a loop // can be started and the id cached, then stopped at a later time, using that id. //############################################################################################## public int PlaySoundInternal(SoundAsset asset, GameObject transformObject) { if (asset == null || asset.clip == null || asset.volume <= 0.0f) { return(INVALID_SOUND); } int index = GetValidSoundIndex(asset.priority); if (index != INVALID_SOUND) { AudioSource source = usedSources[index]; AudioReverbFilter reverb = source.GetComponent <AudioReverbFilter>(); AudioLowPassFilter lowPassFilter = source.GetComponent <AudioLowPassFilter>(); // Setup source source.Stop(); source.clip = asset.clip; source.loop = (asset.count == SoundCount.Looping); // Randomize the pitch if needed if (asset.pitchBend > 0.0f) { source.pitch = 1.0f + (Random.value * asset.pitchBend) - (asset.pitchBend * 0.5f); } else { source.pitch = 1.0f; } // Apply volume source.volume = asset.volume * globalVolume; // Position immediately before next update source.gameObject.transform.position = transformObject == null ? Vector3.zero : transformObject.transform.position; // setup records SoundRecord record = records[index]; record.volume = asset.volume; record.features = asset.features; record.priority = asset.priority; record.soundId = soundIdIndex; record.parent = transformObject; record.reverb = reverb; record.lowPassFilter = lowPassFilter; soundIdIndex++; // Set defaults for advanced features bool delayed = false; reverb.reverbPreset = AudioReverbPreset.Off; lowPassFilter.cutoffFrequency = SoundConstants.LPF_CLEAR; source.spatialBlend = SoundConstants.SPATIAL_BLEND_TWO_D; // Advanced features require three-dimensional spatialization and a valid transform if ((asset.features & SoundFeatures.ThreeDimensional) != 0) { if (transformObject != null) { source.spatialBlend = SoundConstants.SPATIAL_BLEND_THREE_D; if ((asset.features & SoundFeatures.SimulatedReverb) != 0) { float physicalVolumeNormalized = CalculatePhysicalVolumeNormalized(record.parent); ApplyReverbFromPhysicalVolume(reverb, physicalVolumeNormalized); record.timeUntilReverbUpdate = REVERB_UPDATE_TIME; record.previousVolumeNormalized = physicalVolumeNormalized; record.physicalVolumeNormalized = physicalVolumeNormalized; } if ((asset.features & SoundFeatures.Occlusion) != 0) { // Mark previous occlusion as invalid to immediately apply record.currentOcclusion = Occluded(transformObject); record.previousOcclusion = record.currentOcclusion; record.timeUntilOcclusionUpdate = OCCLUSION_UPDATE_TIME; ApplyOcclusion(lowPassFilter, record.currentOcclusion); } if ((asset.features & SoundFeatures.DistanceDelayed) != 0) { delayed = true; } if ((asset.features & SoundFeatures.EmitsSlapbacks) != 0) { // TODO Shoot ray away from listener, and create delayed slapback at that point? } if ((asset.features & SoundFeatures.Doppler) != 0) { source.dopplerLevel = SoundConstants.DOPPLER_ON; } else { source.dopplerLevel = SoundConstants.DOPPLER_OFF; } } if (transformObject == null && asset.features != 0) { Logger.Error("All Sound Assets with Sound Features require a transform object as an argument."); record.features = 0; } } // play the sound unless delayed if (!delayed) { source.Play(); } return(records[index].soundId); } else { Logger.Warning("Failed to play " + asset.clip + " with priority " + asset.priority); return(INVALID_SOUND); } }
void Start() { bgm.GetComponent <AudioSource>(); bgm.Play(); }
IEnumerator PlaySong(Command c) { if (c.file == "") { if (currentSong != null) { Destroy(currentSong); } currentSong = null; yield break; } c.file = AddDefaultExtension(c.file); //IncrementPlayCount(c.file); if (c.type == CommandType.SONG && currentSong != null) { if (c.file == currentSong.GetComponent <videoScript>().command.file) { Debug.Log("already playing song " + c.file); yield break; } } Debug.Log("playing " + c.file); videoScript vs; if (c.file.EndsWith(".avi")) { GameObject go = Instantiate(baseVideoPlayer); VideoPlayer vp = go.GetComponent <VideoPlayer>(); vs = go.GetComponent <videoScript>(); vs.command = c; vp.isLooping = c.loop; vp.url = path + c.file; vp.targetCamera = null; vp.renderMode = VideoRenderMode.APIOnly; if (c.type == CommandType.AUDIO) { go.GetComponent <AudioSource>().volume *= otherVolume; playing_audio.Add(go); vs.fadeOutFinished += AudioEndReached; vp.prepareCompleted += AudioPrepared; } if (c.type == CommandType.SONG) { go.GetComponent <AudioSource>().volume *= musicVolume; if (currentSong != null) { Destroy(currentSong); } currentSong = go; vs.fadeOutFinished += SongEndReached; vp.prepareCompleted += SongPrepared; } //vs.Init(); vp.Prepare(); yield break; } Debug.Log("test PlaySong"); AudioSource source = Instantiate(baseVideoPlayer).GetComponent <AudioSource>(); vs = source.GetComponent <videoScript>(); source.loop = c.loop; vs.command = c; GameObject player = source.gameObject; source.playOnAwake = true; using (var www = new WWW(path + c.file)) { yield return(www); source.clip = www.GetAudioClip(); while (source.clip.loadState == AudioDataLoadState.Loading) { System.Threading.Thread.Sleep(1); } if (c.type == CommandType.SONG) { source.volume *= musicVolume; if (currentSong != null) { Destroy(currentSong); } currentSong = source.gameObject; vs.fadeOutFinished += SongEndReached; } else if (c.type == CommandType.AUDIO) { source.volume *= otherVolume; playing_audio.Add(source.gameObject); vs.fadeOutFinished += AudioEndReached; } //vs.Init(); source.Play(); } }
// Update is called once per frame void Update() { if (!HUDManager.Instance.iSGameStarted) { return; } if (mPlayerNumer == PlayerNumber.Player1) { if (Input.GetButton("Fire1")) { ProcessFarting(); HUDManager.Instance.SetFartMeter(fartMeter / fartMAX, mPlayerNumer); } else { fartTimer = 0; m_fartParticles.Stop(); AudioController.FadeOut(fartAudioSource, 0.2f); fartAudioSource.GetComponent <FartAudio>().fartTriggered = false; } } else { if (Input.GetButton("Fire2")) { ProcessFarting(); HUDManager.Instance.SetFartMeter(fartMeter / fartMAX, mPlayerNumer); } else { fartTimer = 0; m_fartParticles.Stop(); AudioController.FadeOut(fartAudioSource, 0.2f); fartAudioSource.GetComponent <FartAudio>().fartTriggered = false; } } if (mPlayerNumer == PlayerNumber.Player1) { if (Input.GetButtonUp("Fire1")) { GetComponent <Rigidbody>().velocity = Vector3.zero; isSuperFart = false; if (rainbow != null) { Destroy(rainbow); } } } else { if (Input.GetButtonUp("Fire2")) { GetComponent <Rigidbody>().velocity = Vector3.zero; isSuperFart = false; if (rainbow != null) { Destroy(rainbow); } } } // ----------- CHEAT ------------- if (Input.GetKeyDown(KeyCode.P)) { fartMeter = fartMAX; } // ----------- End CHEAT ------------- }
void Engine() { //speed. speed = rigid.velocity.magnitude * 3.0f; //Acceleration Calculation. acceleration = 0f; acceleration = (transform.InverseTransformDirection(rigid.velocity).z - lastVelocity) / Time.fixedDeltaTime; lastVelocity = transform.InverseTransformDirection(rigid.velocity).z; //Drag Limit Depends On Vehicle Acceleration. rigid.drag = Mathf.Clamp((acceleration / 50f), 0f, 1f); //Steer Limit. steerAngle = Mathf.Lerp(defsteerAngle, highSpeedSteerAngle, (speed / highSpeedSteerAngleAtSpeed)); FrontLeftWheelCollider.steerAngle = ApplySteering(); FrontRightWheelCollider.steerAngle = ApplySteering(); float wheelRPM = ((Mathf.Abs((FrontLeftWheelCollider.rpm * FrontLeftWheelCollider.radius) + (FrontRightWheelCollider.rpm * FrontRightWheelCollider.radius)) / 2f) / 3.25f); engineRPM = Mathf.Clamp((Mathf.Lerp(0 - (minimumEngineRPM * (currentGear + 1)), maximumEngineRPM, wheelRPM / (gearSpeed[currentGear] * 1.25f)) + minimumEngineRPM), minimumEngineRPM, maximumEngineRPM); //Engine Audio Volume. if (engineAudio) { engineAudio.GetComponent <AudioSource>().pitch = Mathf.Lerp(engineAudio.GetComponent <AudioSource>().pitch, Mathf.Lerp(1f, 2f, (engineRPM - minimumEngineRPM / 1.5f) / (maximumEngineRPM + minimumEngineRPM)), Time.deltaTime * 5); if (!changingGear) { engineAudio.GetComponent <AudioSource>().volume = Mathf.Lerp(engineAudio.GetComponent <AudioSource>().volume, Mathf.Clamp(motorInput - brakeInput, .35f, .85f), Time.deltaTime * 5); } else { engineAudio.GetComponent <AudioSource>().volume = Mathf.Lerp(engineAudio.GetComponent <AudioSource>().volume, .35f, Time.deltaTime * 5); } } //Applying WheelCollider Motor Torques Depends On Wheel Type Choice. switch (_wheelTypeChoise) { case WheelType.FWD: FrontLeftWheelCollider.motorTorque = ApplyWheelMotorTorque(); FrontRightWheelCollider.motorTorque = ApplyWheelMotorTorque(); break; case WheelType.RWD: RearLeftWheelCollider.motorTorque = ApplyWheelMotorTorque(); RearRightWheelCollider.motorTorque = ApplyWheelMotorTorque(); break; case WheelType.AWD: FrontLeftWheelCollider.motorTorque = ApplyWheelMotorTorque(); FrontRightWheelCollider.motorTorque = ApplyWheelMotorTorque(); RearLeftWheelCollider.motorTorque = ApplyWheelMotorTorque(); RearRightWheelCollider.motorTorque = ApplyWheelMotorTorque(); break; } // Apply the brake torque values to the rear wheels. FrontLeftWheelCollider.brakeTorque = ApplyWheelBrakeTorque() / 1f; FrontRightWheelCollider.brakeTorque = ApplyWheelBrakeTorque() / 1f; RearLeftWheelCollider.brakeTorque = ApplyWheelBrakeTorque(); RearRightWheelCollider.brakeTorque = ApplyWheelBrakeTorque(); }
void Start() { audioSource.GetComponent <AudioSource>(); audioSource.loop = false; }
// Use this for initialization void Start() { scoreScript = scoreGO.GetComponent <ScoreIncrement> (); colorScript = scoreGO.GetComponent <ColorIncrement> (); musicScript = musicGO.GetComponent <ChangeMusic> (); }
// Use this for initialization void Start() { audioGears.GetComponent <AudioSource>(); }
// Update is called once per frame void Update() { soundManager.GetComponent <AudioSource>().volume = musicVolume; }
private void Start() { gManager = GameObject.Find("GameManager"); soundPlayer = GameObject.Find("SoundManager").GetComponent <AudioSource>(); soundManager = soundPlayer.GetComponent <SoundManager>(); }
private void Start() { isNotMoving = new Vector3(0f, 0f, 0f); audioS.GetComponent <AudioSource>(); }
// Start is called before the first frame update void Start() { source.GetComponent <AudioSource>(); }
public void SetValues() { //Deal with Camera's and render textures mainCam = GameObject.Find("Main Camera").GetComponent <Camera>(); uiCam = GameObject.Find("ViewUICam").GetComponent <Camera>(); dinoCam = GameObject.Find("ViewDinoCam").GetComponent <Camera>(); uiRendTex = GameObject.Find("ViewUIRendTex").GetComponent <RenderTexture>(); dinoRendTex = GameObject.Find("ViewDinoRendTex").GetComponent <RenderTexture>(); if (dinoRendTex != null && uiRendTex != null) { uiCam.targetTexture = uiRendTex; dinoCam.targetTexture = dinoRendTex; } //Deal with Scripts NewGameOverScreen ngo = FindObjectOfType <NewGameOverScreen>(); gameOverScreen = ngo; tapController = FindObjectOfType <TapController>(); NewGameValues gv = FindObjectOfType <NewGameValues>(); gameValues = gv; gv.TimeGO = GameObject.Find("Time Display"); if (gv.TimeGO != false) { gv.TimeTXT = gv.TimeGO.GetComponent <Text>(); } gameValues.ScoreTXT = GameObject.Find("YourScore").GetComponent <Text>(); gameValues.GameOverScreen = ngo.transform.gameObject; gameOverScreen.GV = gameValues; if (music != null) { gameOverScreen.Music = music; } ngo.GV = gv; gv.NGOS = ngo; SpecialMeter sm = FindObjectOfType <SpecialMeter>(); specialMeter = sm; sm.AS = music.GetComponent <AudioSource>(); sm.MultiPlyUI = GameObject.Find("ScoreMultiplied"); scoreMultiplied = sm.MultiPlyUI; sm.GV = gameValues; sm.NormalTrailRend = GameObject.Find("TR1"); sm.SpecialTrailRend = GameObject.Find("TR2"); specialMeter.GM = this; specialMeter.GV = gameValues; if (gv.boostr != null) { gv.boostr.SM = specialMeter; } gv.boostr.GV = gv; //Complex dealings NewDeliveryPointManager dpm = FindObjectOfType <NewDeliveryPointManager>(); if (dpm != null) { dpManager = dpm; dpManager.SM = specialMeter; sm.DPmanager = dpManager; } SlotManager slot = FindObjectOfType <SlotManager>(); slotManager = slot; gv.SM = slotManager; slot.GV = gameValues; foreach (Transform child in dpManager.transform) { NewDeliveryPoint dp = child.GetComponent <NewDeliveryPoint>(); dp.SlotMgr = slot; } Image img = GameObject.Find("DinoImage").GetComponent <Image>(); dinoImage = img; gameValues.CharImg = img; specialMeter.Indicators.Clear(); foreach (Transform child in indicatorParent) { specialMeter.Indicators.Add(child.gameObject.GetComponent <Image>()); } gameValues.SDelGO = GameObject.Find("Successful Deliveries"); foreach (Transform t in gameValues.SDelGO.transform) { if (t.name == "SDel_Txt") { successfulDisplay = t.gameObject.GetComponent <Text>(); gameValues.SDelTXT = successfulDisplay; } } gameValues.FDelGO = GameObject.Find("Failed Deliveries"); foreach (Transform t in gameValues.FDelGO.transform) { if (t.name == "FDel_Txt") { failedDisplay = t.gameObject.GetComponent <Text>(); gameValues.FDelTXT = failedDisplay; } }//Pterodactyls GameObject ptero = GameObject.Find("Pterodactyls"); if (ptero != false) { pteros.Clear(); foreach (Transform child in ptero.transform) { pteros.Add(child.GetComponent <PteroDactyl>()); } GameObject stolenUI = GameObject.Find("PostStolen"); GameObject shakeUI = GameObject.Find("ShakePrompt"); Image shake = GameObject.Find("ShakeMeter").GetComponent <Image>(); GameObject pteroNice = GameObject.Find("Nice"); foreach (PteroDactyl pt in pteros) { pt.DPmanager = dpManager; pt.SManager = slotManager; pt.StolenUI = stolenUI; pt.ShakePrompt = shakeUI; pt.ShakeMeter = shake; pt.Nice = pteroNice; } } }
private void Awake() { backgroundAudioSource = backgroundAudioSource.GetComponent <AudioSource>(); audioSource = GetComponent <AudioSource>(); }
private void Start() { fadeAnim = fadeCanvas.GetComponentInChildren <Animator>(); musicAnim = musicManager.GetComponent <Animator>(); }
void Start() { musica.GetComponent <AudioSource>(); }
public void OnPointerClick(PointerEventData eventData) { ParkSound3.GetComponent <AudioSource>().Play(); cw.wrong2 = true; }
private void SoundsEsp(AudioClip a) { aSourceAux.GetComponent <AudioSource>().PlayOneShot(a); aSourceAux.pitch = 1; }
void Start() { plot = GetComponent <Plot> (); forestPlayer = audioSource.GetComponent <ForestPlayer>(); //Debug.Log (defaultText); }
void touche(RaycastHit2D hit) { if (hit.collider.tag == "Enemy") { float x = hit.collider.gameObject.transform.position.x; float y = hit.collider.gameObject.transform.position.y; count += 10; score.text = "" + count; Destroy(hit.collider.gameObject); GameObject xx = (GameObject)Instantiate(blast, new Vector2(x, y), Quaternion.identity); StartCoroutine(destroying(xx)); } else if (hit.collider.tag == "Bomb") { Handheld.Vibrate(); count -= 50; score.text = "" + count; if (life[0] != null) { Destroy(life[0]); } else if (life[1] != null) { Destroy(life[1]); } else { Destroy(life[2]); gameover.SetActive(true); btn1.enabled = true; clip.GetComponent <AudioSource>().mute = true; finalscore.text = score.text; Time.timeScale = 0.0f; psebtn.enabled = false; StartCoroutine(off()); score.GetComponent <Text>().enabled = false; text1.GetComponent <Text>().enabled = false; text2.GetComponent <Text>().enabled = false; timer.GetComponent <Text>().enabled = false; } float x = hit.collider.gameObject.transform.position.x; float y = hit.collider.gameObject.transform.position.y; Destroy(hit.collider.gameObject); GameObject xx = (GameObject)Instantiate(explosion, new Vector2(x, y), Quaternion.identity); StartCoroutine(destroying(xx)); } else if (hit.collider.tag == "Player") { count += 50; score.text = "" + count; float x = hit.collider.gameObject.transform.position.x; float y = hit.collider.gameObject.transform.position.y; Destroy(hit.collider.gameObject); GameObject xx = (GameObject)Instantiate(sparks, new Vector2(x, y), Quaternion.identity); StartCoroutine(destroying(xx)); } else if (hit.collider != null) { switch (hit.collider.name) { case "psebtn": menu.SetActive(true); StartCoroutine(mokerstop()); Time.timeScale = 0.0f; menu.SetActive(true); clip.GetComponent <AudioSource>().mute = true; break; /* case "Volume1": * * lis.enabled=false; * volumeon.SetActive(false); * volumeoff.SetActive(true); * break; * case "Volume2": * * lis.enabled = true; * volumeon.SetActive(true); * volumeoff.SetActive(false); * break;*/ case "Resumegme": Time.timeScale = 1.0f; menu.SetActive(false); clip.GetComponent <AudioSource>().mute = false; break; case "Restartgme": ; Application.LoadLevel("scene1"); Time.timeScale = 1.0f; break; case "Quit": Application.Quit(); break; } } }
private void Start() { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; door_open_sound = door_open_sound.GetComponent <AudioSource>(); }
//These are our new methods void OnMarkerFound(ARMarker marker) { AudioSource theAudio = null; if (marker.Tag == markersTags[0]) { audio1.loop = true; theAudio = audio1; } else if (marker.Tag == markersTags[1]) { audio1.GetComponent <AudioEchoFilter> ().enabled = true; //audio2.loop = true; //theAudio = audio2; } else if (marker.Tag == markersTags[2]) { audio1.GetComponent <SEF_lowpass> ().enabled = true; audio2.GetComponent <SEF_lowpass> ().enabled = true; } else if (marker.Tag == markersTags[3]) { audio1.GetComponent <SEF_highpass> ().enabled = true; audio2.GetComponent <SEF_highpass> ().enabled = true; } if (theAudio != null) { theAudio.Play(); } }
private void Start() { audiosrc.GetComponent <AudioSource>(); AudioSource.PlayClipAtPoint(audioclip, transform.position); Invoke("DestroyProjectile", lifeTime); }
// Upon colliding with something void OnCollisionEnter(Collision collision) { // If colliding with an entity that has health, damage it LivingEntity collisionEntity = collision.gameObject.GetComponent <LivingEntity> (); if (collisionEntity != null || collision.gameObject.tag == "Enemy") { if (collisionEntity == null) { collisionEntity = transform.parent.parent.GetComponent <LivingEntity> (); } bool damageDealt = false; if (collision.gameObject.name == "Survivor") { if (collision.gameObject.GetComponent <Survivor> ().friendlyFireOn) { collisionEntity.TakeHit(damage); damageDealt = true; } } else { if (canDamage) { collisionEntity.lastHitBy = firedBy; collisionEntity.TakeHit(damage); } damageDealt = true; penetration--; if (startingPenetration - penetration <= 0 && startingPenetration == 5) { achievement.AwardAchievement(2); } if (penetration <= 0) { // Destroy the bullet canDamage = false; Destroy(gameObject); } } if (!collisionEntity.Dead && damageDealt) { // Only spawns damage particles if the entity is still alive Instantiate(gunManager.enemyParticles, transform.position, Quaternion.identity); } } else { // Spawn some flash particles Instantiate(gunManager.defaultParticles, transform.position, Quaternion.identity); if (SFX.Length > 0) { int random = Random.Range(0, SFX.Length - 1); AudioSource newAudio = Instantiate(SFX [random]); newAudio.transform.position = transform.position; newAudio.GetComponent <Sound> ().PlaySound(); // Destroy the bullet Destroy(gameObject); } } }
/// <summary> /// Sets up riff editor and calls appropriate init function. /// </summary> public void Initialize() { _initialized = false; // Check if riff is valid if (CurrentRiff == null) { Debug.LogError("RiffEditor.Initialize(): no riff selected!"); return; } // Initialize effect status sprites AudioSource source = MusicManager.Instance.GetAudioSource(CurrentRiff.Instrument); Sprite percussionFilled = UIManager.Instance.FilledPercussionNoteIcon; Sprite percussionEmpty = UIManager.Instance.EmptyPercussionNoteIcon; // Initialize effect toggle sprites _distortionButton.sprite = source.GetComponent <AudioDistortionFilter>().enabled ? percussionFilled : percussionEmpty; _tremoloButton.sprite = source.GetComponent <AudioTremoloFilter>().enabled ? percussionFilled : percussionEmpty; _chorusButton.sprite = source.GetComponent <AudioChorusFilter>().enabled ? percussionFilled : percussionEmpty; _flangerButton.sprite = source.GetComponent <AudioChorusFilter>().enabled ? percussionFilled : percussionEmpty; _echoButton.sprite = source.GetComponent <AudioEchoFilter>().enabled ? percussionFilled : percussionEmpty; _reverbButton.sprite = source.GetComponent <AudioReverbFilter>().enabled ? percussionFilled : percussionEmpty; HideSliders(); // Clear all previous buttons Cleanup(); // Set up riff editor properties _nameInputField.text = CurrentRiff.Name; _playRiffButton.sprite = UIManager.Instance.PlayIcon; UpdateTempoText(); _numButtons = Riff.MAX_BEATS; // Set initial scrollbar values SyncScrollbars(); // Refresh button grid _buttonGrid.Clear(); for (int n = 0; n < _numButtons; n++) { _buttonGrid.Add(new List <GameObject>()); } // Create note buttons if (CurrentRiff.Instrument.InstrumentType == Instrument.Type.Percussion) { InitializePercussionSetup((PercussionInstrument)CurrentRiff.Instrument); } else if (CurrentRiff.Instrument.InstrumentType == Instrument.Type.Melodic) { InitializeMelodicSetup((MelodicInstrument)CurrentRiff.Instrument); } else { Debug.LogError(CurrentRiff.Instrument.Name + " unable to initialize."); } // Update riff volume slider _riffVolumeSlider.value = CurrentRiff.Volume; _initialized = true; }
// Update is called once per frame void Update() { if (disableAll) { if (Input.GetKeyDown(KeyCode.Escape) && !MainCharacter.instance.IsDead()) { paused = !paused; if (paused) { pausedText.text = "Paused"; Time.timeScale = 0; } else { pausedText.text = ""; Time.timeScale = 1; } } return; } if (muteButton.GotSelected()) { muted = !muted; if (muted) { musicAudio.GetComponent <AudioSource>().Stop(); } else { musicAudio.GetComponent <AudioSource>().Play(); } muteButton.SetSelected(false); } if (mainMenuSelected) { if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } } if (playButton.GotSelected()) { if (!MainCharacter.instance.GamePlayHasStarted()) { MainCharacter.instance.GamePlayStart(); muteButton.transform.position = new Vector3(100, 100, 0); mainMenuSelected = false; } for (int i = 0; i < guiObjects.Length; i++) { if (guiObjects[i].transform.position.x < 6) { guiObjects[i].transform.position += new Vector3(21 * Time.deltaTime, 0, 0); } else { disableAll = true; //disable all gui elements once gameplay starts } } } if (highScoreButton.GotSelected())//HighScoreGUI.selected { mainMenuSelected = false; for (int i = 0; i < guiObjects.Length; i++) { if (guiObjects[i].transform.position.x < 6) { guiObjects[i].transform.position += new Vector3(21 * Time.deltaTime, 0, 0); //main menu out } } for (int i = 0; i < highScoreObjects.Length; i++) { if (highScoreObjects[i].transform.position.x < 0) { highScoreObjects[i].transform.position += new Vector3(20 * Time.deltaTime, 0, 0); //score menu in } else { highScoreButton.SetSelected(false); for (int j = 0; j < highScoreObjects.Length; j++) { highScoreObjects[j].transform.position = new Vector3(0, highScoreObjects[j].transform.position.y, highScoreObjects[j].transform.position.z); } } } } if (exitHighScoreButton.GotSelected() || Input.GetKeyDown(KeyCode.Escape))//HighScoreGUI.unselected { mainMenuSelected = true; exitHighScoreButton.SetSelected(true); for (int i = 0; i < guiObjects.Length; i++) { if (guiObjects[i].transform.position.x > 0) { guiObjects[i].transform.position -= new Vector3(21 * Time.deltaTime, 0, 0); //main menu in } else { guiObjects[i].transform.position = new Vector3(0, guiObjects[i].transform.position.y, guiObjects[i].transform.position.z); } } for (int i = 0; i < highScoreObjects.Length; i++) { if (highScoreObjects[i].transform.position.x > -5) { highScoreObjects[i].transform.position -= new Vector3(20 * Time.deltaTime, 0, 0); //score menu out } else { exitHighScoreButton.SetSelected(false); for (int j = 0; j < guiObjects.Length; j++) { guiObjects[j].transform.position = new Vector3(0, guiObjects[j].transform.position.y, guiObjects[j].transform.position.z); } } } } }
void moveButton() { if ((Input.GetKeyDown("up") || Input.GetAxis("DPadY") == 1) && !dPadPressed) { selectedObject = selectedObject.GetComponent <GraphicsSettings>().up; transform.position = new Vector3(selectedObject.transform.position.x, selectedObject.transform.position.y, selectedObject.transform.position.z - 1); dPadPressed = true; } else if ((Input.GetKeyDown("down") || Input.GetAxis("DPadY") == -1) && !dPadPressed) { selectedObject = selectedObject.GetComponent <GraphicsSettings>().down; transform.position = new Vector3(selectedObject.transform.position.x, selectedObject.transform.position.y, selectedObject.transform.position.z - 1); dPadPressed = true; } else if ((Input.GetKeyDown("left") || Input.GetAxis("DPadX") == -1) && !dPadPressed) { selectedObject = selectedObject.GetComponent <GraphicsSettings>().left; transform.position = new Vector3(selectedObject.transform.position.x, selectedObject.transform.position.y, selectedObject.transform.position.z - 1); dPadPressed = true; } else if ((Input.GetKeyDown("right") || Input.GetAxis("DPadX") == 1) && !dPadPressed) { selectedObject = selectedObject.GetComponent <GraphicsSettings>().right; transform.position = new Vector3(selectedObject.transform.position.x, selectedObject.transform.position.y, selectedObject.transform.position.z - 1); dPadPressed = true; } // reset one button press when no direction is held ( not the best way might look into cleaner way) if (Input.GetAxis("DPadY") == 0 && Input.GetAxis("DPadX") == 0) { dPadPressed = false; } if (Input.GetKeyDown("space") || Input.GetButtonDown("A")) { if (selectedObject == back) { //goto settings back.GetComponent <SettingScript>().gotoSettings(); } else { QualitySettings.SetQualityLevel(selectedObject.GetComponent <GraphicsSettings>().graphicsValue, true); } //confirm sound audioSource.GetComponent <PlaySound>().playSound(); } else if (Input.GetButtonDown("B")) { //goto settings back.GetComponent <SettingScript>().gotoSettings(); } if (Input.GetAxis("MouseX") != 0 || Input.GetAxis("MouseY") != 0) { //move it off screen transform.position = new Vector3(10000, 0, 0); } }
public void SetActiveAudios(AudioClip nextMusic, AudioClip nextAmbient, float mVol, float aVol) { musicVolume = mVol; //set the next music //if the 1st audio isn't playing if (!musicSource1.isPlaying) { //if the 2nd source is already playing the same music, just adjust the volume if needed if (musicSource2.GetComponent <AudioClip>() == nextMusic) { currentMusicVolume2 = mVol; } else //set the next music to the 1st slot and set the 2nd slot to fade out { musicSource1.clip = nextMusic; musicSource1.Play(); currentMusicVolume1 = 0f; music1FadingIn = true; if (musicSource2.isPlaying) { music2FadingOut = true; } } } //if 1st slot is playing and the 2nd isn't else if (!musicSource2.isPlaying) { //if the next clip is already playing if (musicSource1.GetComponent <AudioClip>() == nextMusic) { musicSource1.volume = mVol; } else { //set the next music to the 2nd slot and set the 1nd slot to fade out musicSource2.clip = nextMusic; musicSource2.Play(); musicSource2.volume = 0f; music2FadingIn = true; if (musicSource1.isPlaying) { music1FadingOut = true; } } } else //just in case for some weird situation if both audios are still playing { if (musicSource1.GetComponent <AudioClip>() == nextMusic) { currentMusicVolume1 = mVol; music2FadingOut = true; music1FadingIn = false; music1FadingOut = false; } else if (musicSource2.GetComponent <AudioClip>() == nextMusic) { currentMusicVolume2 = mVol; music1FadingOut = true; music2FadingIn = false; music1FadingOut = false; } else { musicSource1.clip = nextMusic; currentMusicVolume1 = 0; music1FadingOut = false; music1FadingIn = true; music2FadingOut = true; } } //set the ambient audio if (!ambientSource.clip || ambientSource.clip != nextAmbient) { ambientSource.clip = nextAmbient; ambientSource.Play(); } currentAmbientVolume = aVol; }
public void Next_Level() { ChangeAudio.GetComponent <AudioSource>().Play(); Invoke("Go_Next_Level", 0.3f); }