private void Die() { gameObject.SetActive(false); OnPlayerDie?.Invoke(); Instantiate(deathEffect, transform.position, Quaternion.identity); SoundManager.instance.PlaySound(loseSound); }
private void OnDisable() { onPlayerLoseLife -= LoseOneLife; onPlayerTakeDamage -= TakeDamage; onPlayerDie -= Die; }
private void OnCollisionEnter2D(Collision2D other) { if (!other.gameObject.CompareTag("Border")) { OnPlayerDie?.Invoke(); Destroy(this.gameObject); } }
private void Start() { RefreshHeartUi(); OnSceneChangeCallback += RearrangeObjectsBasedOnScene; OnSceneChangeCallback?.Invoke(false); onPlayerDieCallback += RefreshHeartUi; }
private void OnEnable() { onPlayerLoseLife += LoseOneLife; onPlayerTakeDamage += TakeDamage; onPlayerDie += Die; }
private void Die() { OnPlayerDie?.Invoke(); ObjectsCollision.OnCoinCollect -= CollectCoin; ObjectsCollision.OnDeath -= Die; DOTween.Clear(true); }
IEnumerator DieProcess() { var arm = Camera.main.gameObject.GetComponent <SmoothJointArm>(); if (arm != null) { arm.target = null; } m_HitBox.enabled = false; m_SideBlockCollider.enabled = false; m_MovementCollider.enabled = false; yield return(new WaitForSeconds(4f)); OnPlayerDie.Invoke(); }
public void RaiseTheDead() { OnPlayerDie?.Invoke(false); SetInvulnerableTrue(); Vector2 toCentreVector = GameObjectsHolder.Instance.Centre.GetToCentreVector(rb2D.position); Vector2 toCentreDirection = toCentreVector.normalized; float toCentreDistance = toCentreVector.magnitude - Centre.CentreRadius; rb2D.velocity = Vector2.zero; float differenceBetweenMaxRaiseHeightAndCurrentPosition = maxRaiseHeight - toCentreDistance / 5f; float raiseHeight = differenceBetweenMaxRaiseHeightAndCurrentPosition >= minRaiseHeight ? differenceBetweenMaxRaiseHeightAndCurrentPosition : minRaiseHeight; float impulseVelocity = Mathf.Sqrt(raiseHeight * rb2D.mass * 2 * Gravity.GravityAcceleration * Gravity.GravityScale); rb2D.AddForce(-1 * toCentreDirection * impulseVelocity, ForceMode2D.Impulse); float fallingTime = Mathf.Sqrt(2 * (raiseHeight + toCentreDistance) / (Gravity.GravityAcceleration * Gravity.GravityScale)); // fallingTime учитывает только время падения; так же есть время взлёта Debug.Log($"Your falling time to the surface of the Centre after raise is {fallingTime}"); }
private void Die() { OnPlayerDie?.Invoke(true); GameManager.Instance.GameOver(); }
public void CallOnPlayerDie() { OnPlayerDie?.Invoke(); }