public TaskTree SlowMo(float duration) { silent = true; ActionTask slow_down = new ActionTask(() => { StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.Linear, t => { Services.AudioManager.SetPitch(Mathf.Lerp(1, 0.1f, t)); })); }); Wait wait = new Wait(duration / 2); ActionTask speed_up = new ActionTask(() => { StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.Linear, t => { Services.AudioManager.SetPitch(Mathf.Lerp(0.1f, 1, t)); })); }); Wait wait2 = new Wait(duration / 2); ActionTask reset = new ActionTask(() => { Services.AudioManager.SetPitch(1f); silent = false; }); TaskTree to_return = new TaskTree(slow_down, new TaskTree(wait, new TaskTree(speed_up, new TaskTree(wait2, new TaskTree(reset))))); return(to_return); }
public TaskTree SlowTimeScale(float duration) { slow_mo = true; ActionTask slow_down = new ActionTask(() => { StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.QuintEaseOut, t => { Time.timeScale = Mathf.Lerp(1f, 0.1f, t); })); }); Wait wait = new Wait(duration / 2); ActionTask speed_up = new ActionTask(() => { StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.QuintEaseIn, t => { Time.timeScale = Mathf.Lerp(0.1f, 1f, t); })); }); Wait wait2 = new Wait(duration / 2); ActionTask reset = new ActionTask(() => { Time.timeScale = 1f; slow_mo = false; }); TaskTree to_return = new TaskTree(slow_down, new TaskTree(wait, new TaskTree(speed_up, new TaskTree(wait2, new TaskTree(reset))))); return(to_return); }
public void FadeOutLevelMusic() { Services.Clock.eventManager.Unregister <Measure>(DynamicLevelMusicVolumes); previousVolumes = new List <float>(); var to_destroy = levelMusicHolder; foreach (AudioSource source in levelMusicSources) { previousVolumes.Add(source.volume); } for (int i = 0; i < levelMusicSources.Count; i++) { AudioSource to_change = levelMusicSources[i]; float starting_value = previousVolumes[i]; float new_value = 0.0f; StartCoroutine(Coroutines.DoOverEasedTime(Services.Clock.MeasureLength(), Easing.Linear, t => { float new_volume = Mathf.Lerp(starting_value, new_value, t); to_change.volume = new_volume; })); } Delay(() => { Destroy(to_destroy); }, Services.Clock.MeasureLength() * 2); }
public TaskTree SlowMo(float duration, Vector3 location) { shaking = false; float startOrthographicSize = Camera.main.orthographicSize; ActionTask slow_down = new ActionTask(() => { StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.QuadEaseOut, t => { transform.position = new Vector3(Mathf.Lerp(basePos.x, location.x, t), Mathf.Lerp(basePos.y, location.y, t), -10f); Camera.main.orthographicSize = Mathf.Lerp(startOrthographicSize, 4, t); })); }); Wait wait = new Wait(duration / 2); ActionTask speed_up = new ActionTask(() => { StartCoroutine(Coroutines.DoOverEasedTime(duration / 2, Easing.QuintEaseIn, t => { transform.position = new Vector3(Mathf.Lerp(location.x, basePos.x, t), Mathf.Lerp(location.y, basePos.y, t), -10f); Camera.main.orthographicSize = Mathf.Lerp(4, startOrthographicSize, t); })); }); Wait wait2 = new Wait(duration / 2); ActionTask reset = new ActionTask(() => { Camera.main.orthographicSize = startOrthographicSize; SetPosition(basePos); }); TaskTree to_return = new TaskTree(slow_down, new TaskTree(wait, new TaskTree(speed_up, new TaskTree(wait2, new TaskTree(reset))))); return(to_return); }
private void _HeadTowardsWall() { // StartCoroutine(Coroutines.DoOverEasedTime(LENGTH_OF_TIME_IN_SECONDS, EASING_FUNCTION, t => //FMODUnity.RuntimeManager.PlayOneShot(chimeLoopInstance, transform.position); //playingChimeSound = true; var startPosition = transform.position; Vector3 endPosition = wallL.transform.position; startRot = transform.rotation; Quaternion endRot = Random.rotation; //GetTarget (true, 0, 0, out endPosition.x, out endPosition.y, out endPosition.z); Debug.Log("TO WALL"); StartCoroutine(Coroutines.DoOverEasedTime(Clock.Instance.HalfLength(), Easing.Linear, t => { // this is where we define what happens inside of a coroutine we're generating on the spot transform.position = Vector3.Lerp(startPosition, endPosition, t); //Debug.Log("t = " + t); //Debug.Log("start" + startPosition + "end" + endPosition); transform.rotation = Quaternion.Lerp(startRot, endRot, t); //chimeLoopInstance.setVolume(t); })); }
private void _ComeBackToHand() { StopAllCoroutines(); var startPosition = transform.position; var endPosition = HandPosition; Debug.Log("TO HAND"); Quaternion currentRot = transform.rotation; StartCoroutine(Coroutines.DoOverEasedTime(Clock.Instance.EighthLength(), Easing.Linear, t => { // this is where we define what happens inside of a coroutine we're generating on the spot transform.position = Vector3.Lerp(startPosition, endPosition, t); transform.rotation = Quaternion.Lerp(currentRot, startRot, t); //Debug.Log("t = " + t); //chimeLoopInstance.setVolume(1 - t); if (t > 0.6f) { chimeLoopInstance.setParameterValue("Release", 1.0f); } })); }
private IEnumerator Behavior() { while (gameObject.activeInHierarchy) { // Pulse for a sec var startScale = Vector3.one; var endScale = Vector3.one * 1.25f; yield return(Coroutines.DoOverEasedTime(_pulseInterval / 2, Easing.BounceEaseOut, t => { transform.localScale = Vector3.Lerp(startScale, endScale, t); })); yield return(Coroutines.DoOverEasedTime(_pulseInterval / 2, Easing.BounceEaseOut, t => { transform.localScale = Vector3.Lerp(endScale, startScale, t); })); // Pick a random spot var startPos = transform.position; var endPos = CameraUtil.RandomPositionInView(transform.position.z); // Move there yield return(Coroutines.DoOverEasedTime(_moveInterval, Easing.CircEaseIn, t => { transform.position = Vector3.Lerp(startPos, endPos, t); })); } }
// Use this for initialization void Start() { StartCoroutine(Coroutines.DoOverEasedTime(3, Easing.Linear, t => { Color.Lerp(Color.white, Color.clear, t); })); }
IEnumerator FadeOutLight() { yield return(StartCoroutine(Coroutines.DoOverEasedTime(1.0f, easing.FadeOutEasing, t => { float intensity = Mathf.Lerp(brightIntensity, dimIntensity, t * 5.0f); spotLight.intensity = intensity; }))); }
IEnumerator FadeInAudio() { yield return(StartCoroutine(Coroutines.DoOverEasedTime(1.0f, easing.FadeInEasing, t => { float volume = Mathf.Lerp(0, 0.3f, t * 0.01f); _audioSource.volume = volume; }))); }
private void DynamicLevelMusicVolumes(BeatEvent e) { previousVolumes = new List <float>(); previousVolumes.Add(levelMusicSources[0].volume); if (levelMusicSources.Count >= 2) { previousVolumes.Add(levelMusicSources[1].volume); levelMusicVolumes[1] = Mathf.Clamp((float)Services.GameData.totalFilledMapTiles / (float)Services.GameData.totalMapTiles, 0.0f, BASEMUSICVOLUME); } if (levelMusicSources.Count >= 4) { previousVolumes.Add(levelMusicSources[2].volume); levelMusicVolumes[2] = Mathf.Clamp(Services.GameData.productionRates[0], 0.0f, BASEMUSICVOLUME); previousVolumes.Add(levelMusicSources[3].volume); levelMusicVolumes[3] = Mathf.Clamp(Services.GameData.productionRates[1], 0.0f, BASEMUSICVOLUME); } if (levelMusicSources.Count >= 6) { previousVolumes.Add(levelMusicSources[4].volume); levelMusicVolumes[4] = Mathf.Clamp(2.0f / Services.GameData.distancesToOpponentBase[0], 0.0f, BASEMUSICVOLUME); previousVolumes.Add(levelMusicSources[5].volume); levelMusicVolumes[5] = Mathf.Clamp(2.0f / Services.GameData.distancesToOpponentBase[1], 0.0f, BASEMUSICVOLUME); } if (levelMusicSources.Count >= 7) { for (int i = 6; i < levelMusicSources.Count; i++) { previousVolumes.Add(levelMusicSources[i].volume); levelMusicVolumes[i] = Mathf.Clamp(Services.GameData.secondsSinceMatchStarted / (5.0f * 60f), 0.0f, BASEMUSICVOLUME); } } for (int i = 0; i < levelMusicSources.Count; i++) { AudioSource to_change = levelMusicSources[i]; float starting_value = previousVolumes[i]; float new_value = levelMusicVolumes[i]; StartCoroutine(Coroutines.DoOverEasedTime(Services.Clock.HalfLength() + Services.Clock.QuarterLength(), Easing.Linear, t => { float new_volume = Mathf.Lerp(starting_value, new_value, t); to_change.volume = new_volume; })); } }
private IEnumerator Die() { // Shrink var startScale = Vector3.one; var endScale = new Vector3(0.15f, 0.15f, 0.15f); yield return(Coroutines.DoOverEasedTime(0.25f, Easing.BounceEaseOut, t => { transform.localScale = Vector3.Lerp(startScale, endScale, t); })); Destroy(gameObject); }
public void Run(bool isRunning) { running = isRunning; if (isRunning) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, 50, t); })); } else if (!isRunning) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, fov_default, t); })); } }
// Update is called once per frame void Update() { //ticker + playercomms code if (Input.GetMouseButton(1)) { isSpeaking = true; // keys.SetActive(true); if (Input.GetKeyDown(KeyCode.W)) { letter_w.color = Color.cyan; ticker.text += "w"; } else if (Input.GetKeyUp(KeyCode.W)) { letter_w.color = textColor; } if (Input.GetKeyDown(KeyCode.A)) { letter_a.color = Color.cyan; ticker.text += "a"; } else if (Input.GetKeyUp(KeyCode.A)) { letter_a.color = textColor; } if (Input.GetKeyDown(KeyCode.S)) { letter_s.color = Color.cyan; ticker.text += "s"; } else if (Input.GetKeyUp(KeyCode.S)) { letter_s.color = textColor; } if (Input.GetKeyDown(KeyCode.D)) { letter_d.color = Color.cyan; ticker.text += "d"; } else if (Input.GetKeyUp(KeyCode.D)) { letter_d.color = textColor; } if (Input.GetKeyDown(KeyCode.Space)) { ticker.text += " "; } } else if (!Input.GetMouseButton(0)) { isSpeaking = false; } //end playercomms //Comms UI Pops up if (Input.GetMouseButtonDown(1)) { StartCoroutine(Coroutines.DoOverEasedTime(0.01f, Easing.Linear, t => { CommsUIGroup.alpha = Mathf.Lerp(0, 1.5f, t); if (!isFocusing && chatLogGroup.alpha < 0.5f) { chatLogGroup.alpha = Mathf.Lerp(0, 1.5f, t); } })); } else if (Input.GetMouseButtonUp(1)) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { CommsUIGroup.alpha = Mathf.Lerp(1, -1.5f, t); if (!isFocusing && chatLogGroup.alpha > 0.5f) { chatLogGroup.alpha = Mathf.Lerp(1, -1.5f, t); } })); } //Focus UI if (Input.GetMouseButtonDown(0)) { isFocusing = true; if (!isSpeaking) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { chatLogGroup.alpha = Mathf.Lerp(0, 1.5f, t); })); } } else if (Input.GetMouseButtonUp(0)) { isFocusing = false; if (!isSpeaking) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { chatLogGroup.alpha = Mathf.Lerp(1, -1.5f, t); })); } //keys.SetActive(false); } }
// Update is called once per frame void Update() { //ticker + playercomms code if (Input.GetMouseButton(1)) { isSpeaking = true; // keys.SetActive(true); if (Input.GetKeyDown(KeyCode.W)) { letter_w.color = Color.cyan; ticker.text += "w"; } else if (Input.GetKeyUp(KeyCode.W)) { letter_w.color = textColor; } if (Input.GetKeyDown(KeyCode.A)) { letter_a.color = Color.cyan; ticker.text += "a"; } else if (Input.GetKeyUp(KeyCode.A)) { letter_a.color = textColor; } if (Input.GetKeyDown(KeyCode.S)) { letter_s.color = Color.cyan; ticker.text += "s"; } else if (Input.GetKeyUp(KeyCode.S)) { letter_s.color = textColor; } if (Input.GetKeyDown(KeyCode.D)) { letter_d.color = Color.cyan; ticker.text += "d"; } else if (Input.GetKeyUp(KeyCode.D)) { letter_d.color = textColor; } if (Input.GetKeyDown(KeyCode.Space)) { ticker.text += " "; } } else if (!Input.GetMouseButton(0)) { isSpeaking = false; } //end playercomms //Comms UI Pops up if (Input.GetMouseButtonDown(1)) { StartCoroutine(Coroutines.DoOverEasedTime(0.01f, Easing.Linear, t => { CommsUIGroup.alpha = Mathf.Lerp(0, 1.5f, t); if (!isFocusing && chatLogGroup.alpha < 0.5f) { chatLogGroup.alpha = Mathf.Lerp(0, 1.5f, t); } })); } else if (Input.GetMouseButtonUp(1)) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { CommsUIGroup.alpha = Mathf.Lerp(1, -1.5f, t); if (!isFocusing && chatLogGroup.alpha > 0.5f) { chatLogGroup.alpha = Mathf.Lerp(1, -1.5f, t); } })); //sends message to language broadcast and chat ticker if (ticker.text.Length > 0) { if (PlayerController.instance.ih.holdingItem) { Language.TakeMessage(ticker.text, sm, PlayerController.instance.ih.itemHeld.transform); } else { Language.TakeMessage(ticker.text, sm); } ChatLog.instance.TakeMessage("You: " + ticker.text + "\n"); } // Debug.Log("_" + ticker.text + "_"); ticker.text = null; letter_w.color = textColor; letter_a.color = textColor; letter_s.color = textColor; letter_d.color = textColor; } //Focus UI if (Input.GetMouseButtonDown(0)) { isFocusing = true; if (!isSpeaking) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { chatLogGroup.alpha = Mathf.Lerp(0, 1.5f, t); })); } } else if (Input.GetMouseButtonUp(0)) { isFocusing = false; if (!isSpeaking) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { chatLogGroup.alpha = Mathf.Lerp(1, -1.5f, t); })); } //keys.SetActive(false); } }
// Update is called once per frame void Update() { //movement float horizontal = 0; float vertical = 0; if (CanMove(transform.right * Input.GetAxisRaw("Horizontal"))) { horizontal = Input.GetAxisRaw("Horizontal"); } if (CanMove(transform.forward * Input.GetAxisRaw("Vertical"))) { vertical = Input.GetAxisRaw("Vertical"); } moveDirection = (horizontal * transform.right + vertical * transform.forward).normalized; running = Input.GetKey(KeyCode.LeftShift); //end movement //items //disables mouselook when esc is pressed if (Input.GetKeyDown(KeyCode.Escape)) { mouseLook.enabled = false; lookEnabled = false; } if (lookEnabled == false && (Input.GetMouseButtonDown(1) || (!Input.GetMouseButton(1) && Input.GetMouseButtonDown(0)))) { Cursor.visible = false; //hides mouse cursor Cursor.lockState = CursorLockMode.Locked; //locks mouse in center of screen } if (Input.GetMouseButtonDown(1)) { if (lookEnabled == false) { mouseLook.enabled = true; } //CheckInteraction(); isSpeaking = true; Cursor.visible = true; Cursor.lockState = CursorLockMode.Confined; StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { cam.fieldOfView = Mathf.Lerp(fov_default, fov_comms, t); })); } if (Input.GetMouseButtonUp(1)) { //CheckInteraction(); isSpeaking = false; if (!isFocusing) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { cam.fieldOfView = Mathf.Lerp(fov_comms, fov_default, t); })); } if (isFocusing) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { cam.fieldOfView = Mathf.Lerp(fov_comms, fov_focus, t); })); } Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } //focus code begin if (Input.GetMouseButtonDown(0)) { isFocusing = true; if (!isSpeaking) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { cam.fieldOfView = Mathf.Lerp(fov_default, fov_focus, t); })); } } if (Input.GetMouseButtonUp(0)) { isFocusing = false; if (!isSpeaking) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { cam.fieldOfView = Mathf.Lerp(fov_focus, fov_default, t); })); } } //focus code end if (Input.GetKeyDown(KeyCode.LeftShift) && !isSpeaking) { safeRelease = false; StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, 50, t); })); } if (Input.GetKeyUp(KeyCode.LeftShift) && !isSpeaking) { StartCoroutine(Coroutines.DoOverEasedTime(0.1f, Easing.Linear, t => { cam.fieldOfView = Mathf.Lerp(cam.fieldOfView, 50, t); })); } if (ih.holdingItem) { ih.HoldItem(); if (Input.GetKeyDown(KeyCode.E)) { ih.DropItem(); } } else { if (Input.GetKeyDown(KeyCode.E)) { CheckInteraction(); } } //end items //time slow if (isSpeaking) { Time.timeScale = slowSpeed; } else { Time.timeScale = 1f; } }