/// <summary> /// Zapocinje rotiranje jednog tocka. Rotacija se odvija u 2 etape. /// Etapa 1 - tocak obrne nekoliko krugova, sve do izabranog simbola, zaustavlja se na tom simbolu, trajanje je rotationTime /// Etapa 2 - "pingpong" animacija na kraju rotacije, iluzija zaustavljanja tocka /// Izabrani simbol dolazi iz npr. Game Managera /// </summary> /// <param name="target">naziv simbola</param> /// <param name="rotTime">vreme za koje ce vreme rotacije tocka biti 'promuckano'</param> public void StartRoll(GameManager.Symbols target, float rotTime) { audioRoll.Play(); audioRoll.DOPitch(1.9f, 3); /** hocemo lepu rotaciju **/ rotationTime = 0; // ponisti sabranu rotaciju rotationTime = rotationTimeTemp + rotTime; // saberi original sa ulazom rotationSpeed = 0; // iskljuci rotaciju glavnog tocka float ang = (float)symbolPosition[target]; // ugao koji trazimo i na koji treba postaviti tocak je unapred definisan u hash tabli int randomCircle = Random.Range(2, 4); // random broj krugova za koje ce tocak biti okrenut ang = ang + randomCircle * 360; // na ugao treba dodati broj krugova... // Rotiraj, a na kraju pozovi MovementDone() zbog 'ping-ping' efekta na kraju animacije // Metodi MovementDone() se prosledjuje i ugao na koji treba da se vrati iTween.RotateTo(gameObject, iTween.Hash( "z", -ang, "time", rotationTime, "easetype", iTween.EaseType.easeInCubic, "oncomplete", "MovementDone", "oncompleteparams", ang )); }
public void HandleGameOver() { if (isHandled) { return; } isHandled = true; if (!skipGameOverMenu) { menu.SetActive(true); var menuCanvas = menu.GetComponentInChildren <CanvasGroup>(); menuCanvas.DOFade(0f, 0.5f).From().SetUpdate(true); Cursor.visible = true; Time.timeScale = 0f; } else { DOVirtual.DelayedCall(3.5f, () => { Restart(); }); music.DOPitch(0.6f, 2.4f); if (skyboxMaterial != null) { skyboxBorder = skyboxMaterial.GetFloat(skyboxPropName); skyboxMaterial.DOFloat(1f, skyboxPropName, 2.5f).SetEase(Ease.InExpo); } } }
void Update() { if (GameManager.Instance.GameState != GameState.InGame) { return; } if (GameManager.Instance.IsGamePaused) { return; } if (Input.GetKeyDown(KeyCode.Space)) { PausePressed?.Invoke(null, null); } if (Input.GetKeyDown(KeyCode.F3)) { canUseSlowMo = !canUseSlowMo; } if (Input.GetMouseButtonDown(0)) { if (inSlowMo) { SetSlowMo(false); } else { Shot?.Invoke(null, null); ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out var hit)) { var newBullet = Instantiate(Bullet, transform.position, Quaternion.identity); Destroy(newBullet, 0.5f); newBullet.transform.LookAt(hit.point); bullets.Add(newBullet.GetComponent <Rigidbody>()); if (hit.transform.gameObject.CompareTag("Target")) { SetSlowMo(true, newBullet.transform); } } audioSource.volume = GameManager.Instance.SoundVolume / 5; audioSource.DOPitch(inSlowMo ? UnityEngine.Random.Range(0.2f, 0.2f) : 1, 0.1f); audioSource.Play(); } } for (int i = 0; i < bullets.Count; i++) { if (bullets[i] == null || bullets[i].transform == null) { SetSlowMo(false); bullets.RemoveAt(i); } } }
public void OnInteractKeyPressed(KeyCode keyCode) { StartCoroutine(CheckHeldTime(keyCode)); _audioSource.Play(); s1.Append(_audioSource.DOPitch(3.0f, 4.0f)); s1.OnComplete(() => { _audioSource.Stop(); }); }
private void OnClickBtnDo() { float endValue = 0; float duration = 0; float.TryParse(_iptDuration.text, out duration); switch (enmDoAudioSource) { case DoAudioSource.DOFade: endValue = _sldTo.value; /* * duration秒内将一个AudioSource的音量Tween到endValue * endValue∈[0,1] */ _ads.DOFade(endValue, duration).OnUpdate(() => { UpdateFloat(_ads.volume); }); break; case DoAudioSource.DOPitch: float.TryParse(_iptToPitch.text, out endValue); /* * duration秒内将一个AudioSource的pitch(音高)Tween到endValue */ _ads.DOPitch(endValue, duration).OnUpdate(() => { UpdateFloat(_ads.pitch); }); break; } }
public void GameOver() { canPlay = false; musicPlayer.DOPitch(0, 1f).SetUpdate(true).OnComplete(() => CompleteTransition()); ambiencePlayer.DOFade(0, .5f).SetUpdate(true); DOVirtual.Float(1, 0, 1f, (x) => Time.timeScale = x).SetUpdate(true); gameoverScreen.DOFade(1, .8f).SetUpdate(true); }
private void StartEngine() { shipModelController.CurrentState = ShipModelController.ShipModelState.Moving; shipThruster.SetActive(true); Audio.Stop(); Audio.pitch = Sounds.engineStartPitch + Sounds.RandomPitch; Sounds.pitchTween.Kill(); Sounds.pitchTween = Audio.DOPitch(Sounds.engineEndPitch + Sounds.RandomPitch, Sounds.tweenTime); Audio.PlayOneShot(Sounds.Running); }
static int DOPitch(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 3); AudioSource obj = (AudioSource)LuaScriptMgr.GetUnityObjectSelf(L, 1, "AudioSource"); float arg0 = (float)LuaScriptMgr.GetNumber(L, 2); float arg1 = (float)LuaScriptMgr.GetNumber(L, 3); DG.Tweening.Tweener o = obj.DOPitch(arg0, arg1); LuaScriptMgr.PushObject(L, o); return(1); }
private void Update() { if (Input.GetKeyDown(KeyCode.KeypadPlus)) { music.DOPitch(music.pitch += 0.25f, 1f); } if (Input.GetKeyDown(KeyCode.KeypadMinus)) { music.DOPitch(music.pitch -= 0.25f, 1f); } music.pitch = Mathf.Clamp(music.pitch, -3, +3); if (Input.GetKey(KeyCode.LeftControl) && Input.GetKeyDown(KeyCode.M)) { if (!isMusicMuted) { mixer.DOSetFloat("MusicVolume", -80f, 3f); isMusicMuted = true; } else { mixer.DOSetFloat("MusicVolume", musicDefaultVolume, 3f); isMusicMuted = false; } } else if (Input.GetKeyDown(KeyCode.M)) { if (!isMasterMuted) { mixer.DOSetFloat("MasterVolume", -80f, 3f); isMasterMuted = true; } else { mixer.DOSetFloat("MasterVolume", 0f, 3f); isMasterMuted = false; } } }
/// <summary> /// Creates and returns a Tween for the informed component. /// The Tween is configured based on the attribute values of this TweenData file. /// </summary> /// <param name="transform"></param> /// <returns></returns> public Tween GetTween(AudioSource source) { switch (command) { case AudioSourceCommand.Fade: return(source.DOFade(to, duration)); case AudioSourceCommand.Pitch: return(source.DOPitch(to, duration)); default: return(null); } }
public override Tween GetTween(UniTween.UniTweenTarget uniTweenTarget) { AudioSource source = (AudioSource)GetComponent(uniTweenTarget); switch (command) { case AudioSourceCommand.Fade: return(source.DOFade(to, duration)); case AudioSourceCommand.Pitch: return(source.DOPitch(to, duration)); default: return(null); } }
void LostGame() { float pitchFadeDuration = 3f; float audioFadeDuration = 0.5f; audio.DOPitch(0, pitchFadeDuration); audio.DOFade(0, audioFadeDuration).SetDelay(pitchFadeDuration - audioFadeDuration); float screenFadeDuration = 1f; Utils.FadeOut(screenFadeDuration, () => { StartCoroutine(Utils.WaitAndAction(0.1f, () => { string scene = RuntimeData.useCustomMusic ? "CustomMusic" : "SelectMusic"; SceneManager.LoadScene(scene); })); }, pitchFadeDuration - screenFadeDuration); }
public IEnumerator StartCountdown() { audio.DOPitch(2, 6); for (int i = 5; i > 0; i--) { audio.Play(); Animation(); startCountdown.text = i.ToString(); yield return(new WaitForSeconds(1f)); } audio.Play(); Animation(); startCountdown.text = "Tirez!"; yield return(new WaitForSeconds(1f)); gameObject.SetActive(false); GameManager.StartGame(); }
public void UpdatePitch(float value = 1, bool IsUseAnimation = false, float time = Contains.DurationFade, System.Action OnUpdateCompleted = null) { if (!object.ReferenceEquals(soundPlayer, null)) { soundPlayer.DOKill(); if (IsUseAnimation) { soundPlayer.DOPitch(value, time).OnComplete(() => { if (!object.ReferenceEquals(OnUpdateCompleted, null)) { OnUpdateCompleted(); } }); } else { // TODO: Stop the sound. soundPlayer.pitch = value; } } }
public IEnumerator HyperventilationHandler() { float hyperventilationInterval = 0; hyperventilationInterval = UnityEngine.Random.Range(minHyperventilationInterval, maxHyperventilationInterval); Debug.Log(hyperventilationInterval); yield return(new WaitForSeconds(hyperventilationInterval)); audioSource.clip = hyperventilationSound; audioSource.volume = 0.3f; audioSource.Play(); while (alreadyHiding) { if (enemyNearby == false) { break; } audioSource.DOFade(1.0f, hyperventilationDuration); audioSource.DOPitch(2.0f, hyperventilationDuration); if (!waitingForPrompt) { yield return(StartCoroutine(PromptCalm())); } if (hyperventilationStrike == 2) { break; } //audioSource.PlayOneShot(hyperventilationSound); hyperventilationInterval = UnityEngine.Random.Range(minHyperventilationInterval, maxHyperventilationInterval); Debug.Log(hyperventilationInterval); yield return(new WaitForSeconds(hyperventilationInterval)); } if (hyperventilationStrike == 2) { BreathedTooLoudWrapper(); hyperventilationStrike = 0; } }
public void ChangePitch(float newPitch) { audioSource.DOPitch(newPitch, 1f); }
public void DoBGMPitch(float targetPitch, float targetTime) { BGM.DOPitch(targetPitch, targetTime); }
private Tween TweenSoundtrackPitch(float targetPitch) { return(soundtrackAudioSource .DOPitch(targetPitch, pitchChangeDuration) .SetUpdate(isIndependentUpdate: true)); }
// Update is called once per frame void Update() { if (isPlaying) { if (isOnConnector) { if (currentConnector.holdUntilTime > 0) { if (Input.GetButton(currentConnector.buttonName)) { chargeIndicator.gameObject.SetActive(true); holdTime += Time.deltaTime; } chargeIndicator.updateChargeBar(0, holdTime, currentConnector.holdUntilTime - currentConnector.startTime); float currentLerpTime = (gameTime - currentRail.startTime) / (currentRail.endTime - currentRail.startTime); playerObject.transform.position = Vector3.Lerp(currentRail.transform.position, currentRail.endPosition, currentLerpTime); if (Input.GetButtonUp(currentConnector.buttonName)) { if (Mathf.Abs(holdTime - (currentConnector.holdUntilTime - currentConnector.startTime)) < 0.2f) { releaseInTime = true; } calculateMovementCurve(currentConnector, currentConnector.pressed && releaseInTime); } if ((!releaseInTime && currentConnector.pressed && Input.GetButtonUp(currentConnector.buttonName)) || (releaseInTime && currentConnector.pressed) || (gameTime - currentConnector.startTime > 0.15f && !currentConnector.pressed)) { if (currentConnector.pressed && releaseInTime && currentConnector.pressedAction == ConnectorActionEnum.JUMP_TO_RAIL) { Debug.Log("releaseInTime"); currentLerpTime = (gameTime - currentConnector.holdUntilTime) / (currentConnector.endTime - currentConnector.holdUntilTime); //playerObject.transform.position = Vector3.Lerp(currentConnector.transform.position, currentConnector.pressedToRail.transform.position, currentLerpTime); playerObject.transform.position = LerpOverNumber(spline.GetPoints(), currentLerpTime); playerObject.GetComponent <Animator>().SetBool("isJumping", true); if (gameTime > currentConnector.endTime) { // finish connecting to other rail currentRail = currentConnector.pressedToRail; isOnConnector = false; isOnRail = true; releaseInTime = false; } } else if (currentConnector.unpressedAction == ConnectorActionEnum.JUMP_TO_RAIL) { Debug.Log("release missed"); float endTime = currentConnector.unpressedEndTime > 0 ? currentConnector.unpressedEndTime : currentConnector.endTime; currentLerpTime = (gameTime - currentConnector.startTime) / (endTime - currentConnector.startTime); //playerObject.transform.position = Vector3.Lerp(currentConnector.transform.position, Vector3.Lerp(currentConnector.unpressedToRail.transform.position, currentConnector.unpressedToRail.endPosition, (endTime - currentConnector.unpressedToRail.startTime) / (currentConnector.unpressedToRail.endTime - currentConnector.unpressedToRail.startTime)), currentLerpTime); playerObject.transform.position = LerpOverNumber(spline.GetPoints(), currentLerpTime); if (gameTime > endTime) { // finish connecting to other rail currentRail = currentConnector.unpressedToRail; isOnConnector = false; isOnRail = true; } } else { Debug.Log("release missed"); isOnConnector = false; isOnRail = true; } chargeIndicator.gameObject.SetActive(false); } } else { if (currentConnector.pressed && currentConnector.pressedAction == ConnectorActionEnum.JUMP_TO_RAIL) { float currentLerpTime = (gameTime - currentConnector.startTime) / (currentConnector.endTime - currentConnector.startTime); //playerObject.transform.position = Vector3.Lerp(currentConnector.transform.position, currentConnector.pressedToRail.transform.position, currentLerpTime); playerObject.transform.position = LerpOverNumber(spline.GetPoints(), currentLerpTime); playerObject.GetComponent <Animator>().SetBool("isJumping", true); if (gameTime > currentConnector.endTime) { // finish connecting to other rail currentRail = currentConnector.pressedToRail; isOnConnector = false; isOnRail = true; } chargeIndicator.gameObject.SetActive(false); } else if (currentConnector.unpressedAction == ConnectorActionEnum.JUMP_TO_RAIL) { chargeIndicator.gameObject.SetActive(false); float endTime = currentConnector.unpressedEndTime > 0 ? currentConnector.unpressedEndTime : currentConnector.endTime; float currentLerpTime = (gameTime - currentConnector.startTime) / (endTime - currentConnector.startTime); //playerObject.transform.position = Vector3.Lerp(currentConnector.transform.position, Vector3.Lerp(currentConnector.unpressedToRail.transform.position, currentConnector.unpressedToRail.endPosition, (endTime - currentConnector.unpressedToRail.startTime) / (currentConnector.unpressedToRail.endTime - currentConnector.unpressedToRail.startTime)), currentLerpTime); playerObject.transform.position = LerpOverNumber(spline.GetPoints(), currentLerpTime); if (gameTime > endTime) { // finish connecting to other rail currentRail = currentConnector.unpressedToRail; isOnConnector = false; isOnRail = true; } } else if (currentConnector.unpressedAction == ConnectorActionEnum.LEVEL_END) { isPlaying = false; playerObject.GetComponent <SpriteRenderer>().DOFade(0f, 1f); music.DOFade(0f, 1f); StartCoroutine(GameOver()); } else if (currentConnector.finished && currentConnector.unpressedAction == ConnectorActionEnum.NOTHING) { isOnConnector = false; isOnRail = true; chargeIndicator.gameObject.SetActive(false); } } playerObject.GetComponent <Animator>().SetBool("isNearConnector", false); } else if (isOnRail) { //playerObject.transform.Translate(Vector3.right * Time.deltaTime * rails[currentRail].movingSpeed); playerObject.GetComponent <Animator>().SetBool("isJumping", false); float currentLerpTime = (gameTime - currentRail.startTime) / (currentRail.endTime - currentRail.startTime); playerObject.transform.position = Vector3.Lerp(currentRail.transform.position, currentRail.endPosition, currentLerpTime); } if (gameTime > timeToLockCamera) { // if (cameraOffset == Vector3.zero) // { // cameraOffset = mainCamera.transform.position - playerObject.transform.position; // } // mainCamera.transform.position = playerObject.transform.position + cameraOffset; // if (mainCamera.transform.position.y < playerObject.transform.position.y - 2) { specificVector = new Vector3(playerObject.transform.position.x + 1, playerObject.transform.position.y - 2, mainCamera.transform.position.z); mainCamera.transform.position = Vector3.Lerp(mainCamera.transform.position, specificVector, smoothSpeed * Time.deltaTime); } else if (mainCamera.transform.position.y > playerObject.transform.position.y + 2) { specificVector = new Vector3(playerObject.transform.position.x + 1, playerObject.transform.position.y + 2, mainCamera.transform.position.z); mainCamera.transform.position = Vector3.Lerp(mainCamera.transform.position, specificVector, smoothSpeed * Time.deltaTime); } else { specificVector = new Vector3(playerObject.transform.position.x + 1, mainCamera.transform.position.y, mainCamera.transform.position.z); mainCamera.transform.position = Vector3.Lerp(mainCamera.transform.position, specificVector, smoothSpeed * Time.deltaTime); } } // find area //foreach(AreaData areaData in areas) //{ // if (areaData.topCorner) //} if (playerObject.transform.position.y < -2 && !stillInWater) { fallTrigger = true; mixer.SetFloat("lowPassFreq", 2000); } else if (playerObject.transform.position.y > -2) { stillInWater = false; mixer.SetFloat("lowPassFreq", 20000); music.pitch = 1f; } if (fallTrigger) { stillInWater = true; fallTrigger = false; music.pitch = 0.5f; music.DOPitch(1f, 4f); } gameTime += (Time.deltaTime * music.pitch); if (Mathf.Abs(gameTime - music.time) > 0.02f) { music.time = gameTime; } } if (debugText) { string debugString = "gameTime: "; debugString += gameTime.ToString("0.0000"); debugString += " songTime: "; if (music) { debugString += music.time.ToString("0.0000") + " @ " + music.pitch.ToString("0.00"); float timeDiff = gameTime - music.time; float absTimeDiff = Mathf.Abs(timeDiff); debugString += "\ntimeDiff: "; debugString += timeDiff.ToString("0.0000"); debugString += "\n0.02: "; debugString += (absTimeDiff >= 0.02).ToString(); debugString += "\n0.01: "; debugString += (absTimeDiff >= 0.01).ToString(); debugString += "\n0.005: "; debugString += (absTimeDiff >= 0.005).ToString(); } debugString += "\nonRail: " + isOnRail.ToString() + " onConnector: " + isOnConnector.ToString(); debugText.text = debugString; } //if (Input.GetKeyDown(KeyCode.P) && !isPlaying) //{ // StartCoroutine(startPlaying()); //} if (Input.GetKeyDown(KeyCode.Escape)) { togglePause(); } }
public void Change_Music() { Background_Music.DOPitch(Game_Manager.instance.Speed, 0.1f); }
public void SetPitch(float value, float duration = 1f, bool isIgnoringTime = false) { audioSource.DOPitch(0.5f, duration).SetUpdate(UpdateType.Normal, isIgnoringTime).Play(); }
public override Tween GetTween(UnityEngine.Object target) { TweenerCore <float, float, DG.Tweening.Plugins.Options.FloatOptions> result; switch (m_type) { case SpecificType.Image_Fade: { Image img = (Image)target; var colorResult = img.DOFade(m_targetValue, duration); if (m_useFrom) { colorResult.From(new Color(img.color.r, img.color.g, img.color.b, m_fromValue), false); } return(colorResult); } case SpecificType.Image_FillAmount: { Image img = (Image)target; result = img.DOFillAmount(m_targetValue, duration); break; } case SpecificType.CanvasGroup_Fade: { CanvasGroup canvasGroup = (CanvasGroup)target; result = canvasGroup.DOFade(m_targetValue, duration); break; } case SpecificType.Camera_Aspect: { Camera camera = (Camera)target; result = camera.DOAspect(m_targetValue, duration); break; } case SpecificType.Camera_FarClipPlane: { Camera camera = (Camera)target; result = camera.DOFarClipPlane(m_targetValue, duration); break; } case SpecificType.Camera_FieldOfView: { Camera camera = (Camera)target; result = camera.DOFieldOfView(m_targetValue, duration); break; } case SpecificType.Camera_NearClipPlane: { Camera camera = (Camera)target; result = camera.DONearClipPlane(m_targetValue, duration); break; } case SpecificType.Camera_OrthoSize: { Camera camera = (Camera)target; result = camera.DOOrthoSize(m_targetValue, duration); break; } case SpecificType.AudioSource_Fade: { AudioSource audioSource = (AudioSource)target; result = audioSource.DOFade(m_targetValue, duration); break; } case SpecificType.AudioSource_Pitch: { AudioSource audioSource = (AudioSource)target; result = audioSource.DOPitch(m_targetValue, duration); break; } case SpecificType.Graphic_Fade: { var graphic = (Graphic)target; return(graphic.DOFade(m_targetValue, duration)); } case SpecificType.Light_Intensity: { var light = (Light)target; return(light.DOIntensity(m_targetValue, duration)); } case SpecificType.Light_ShadowStrength: { var light = (Light)target; return(light.DOShadowStrength(m_targetValue, duration)); } case SpecificType.Material_Fade: { var material = (Material)target; return(material.DOFade(m_targetValue, duration)); } case SpecificType.Outline_Fade: { var outline = (Outline)target; return(outline.DOFade(m_targetValue, duration)); } default: result = null; break; } if (m_useFrom) { result.From(m_fromValue, false); } return(result); }