private void HandlePing() { if (isInCutscene || isDead) { pingTimer = pingCooldown; } else { pingTimer = Mathf.Max(pingTimer - Time.deltaTime, 0); } bool pingInput = Input.GetAxisRaw("Ping") > 0; pingInputBuffer = Mathf.Max(pingInputBuffer - Time.deltaTime, 0); if (pingInput && !oldPingInput) { pingInputBuffer = 0.1f; } oldPingInput = pingInput; if (pingTimer == 0 && pingInputBuffer > 0) { // ping! (or unping) pingTimer = pingCooldown; bool isPing = ContactPingTarget(); // player animation pingTween?.Complete(); sprite.transform.localRotation = Quaternion.identity; sprite.color = isPing ? pingColor : unpingColor; pingTween = DOTween.Sequence() .Insert(0, sprite.transform.DOLocalRotate(new Vector3(0, 0, 360), 0.8f, RotateMode.LocalAxisAdd).SetEase(Ease.OutCubic)) .Insert(0, sprite.DOColor(baseSpriteColor, 0.6f).SetEase(Ease.InCubic)); // ring PingRing ring = Instantiate(pingRing, transform.position, Quaternion.identity) .GetComponent <PingRing>(); if (isPing) { ring.Init(2f, 5f, 0.2f, pingColor.WithA(0.5f)); } else { ring.Init(1f, 4f, 0.2f, Color.black.WithA(0.5f)); } // sound audioSource.PlayOneShot(isPing ? pingAudio : unpingAudio); } }
private void FixedUpdate() { if (!hasStarted && Input.GetAxis("Ping") > 0) { hasStarted = true; // player animation Color baseSpriteColor = actualPlayer.sprite.color; actualPlayer.sprite.transform.localRotation = Quaternion.identity; actualPlayer.sprite.color = actualPlayer.pingColor; DOTween.Sequence() .Insert(0, actualPlayer.sprite.transform.DOLocalRotate(new Vector3(0, 0, 360), 0.8f, RotateMode.LocalAxisAdd).SetEase(Ease.OutCubic)) .Insert(0, actualPlayer.sprite.DOColor(baseSpriteColor, 0.6f).SetEase(Ease.InCubic)); // ring PingRing ring = Instantiate(actualPlayer.pingRing, transform.position, Quaternion.identity) .GetComponent <PingRing>(); ring.Init(2f, 5f, 0.2f, actualPlayer.pingColor.WithA(0.5f)); // sound audioSource.PlayOneShot(actualPlayer.pingAudio); // start level transition GlobalManager.Instance.StopSong(); DOTween.Sequence().InsertCallback(1f, () => { Instantiate(fadeOut); }).InsertCallback(2f, () => { SceneManager.LoadScene(2); }); } }