private void Die()
 {
     gameObject.SetActive(false);
     OnPlayerDie?.Invoke();
     Instantiate(deathEffect, transform.position, Quaternion.identity);
     SoundManager.instance.PlaySound(loseSound);
 }
Esempio n. 2
0
    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;
    }
Esempio n. 5
0
    private void OnEnable()
    {
        onPlayerLoseLife += LoseOneLife;

        onPlayerTakeDamage += TakeDamage;

        onPlayerDie += Die;
    }
Esempio n. 6
0
        private void Die()
        {
            OnPlayerDie?.Invoke();

            ObjectsCollision.OnCoinCollect -= CollectCoin;
            ObjectsCollision.OnDeath       -= Die;

            DOTween.Clear(true);
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
    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}");
    }
Esempio n. 9
0
 private void Die()
 {
     OnPlayerDie?.Invoke(true);
     GameManager.Instance.GameOver();
 }
Esempio n. 10
0
 public void CallOnPlayerDie()
 {
     OnPlayerDie?.Invoke();
 }