Esempio n. 1
0
    //Metodo el cual se encarga de revisar todas la codicciones del jugador por medio de tres raycast
    private void CheckDamagePlayer()
    {
        RaycastHit2D groundInfo     = Physics2D.Raycast(groundDetection.position, Vector2.up, distance, layerWall);
        RaycastHit2D enemyDetection = Physics2D.Raycast(enemyDetectionEnemy.position, Vector2.right, distance, layerEnemy);
        RaycastHit2D groundDownInfo = Physics2D.Raycast(groundDetectionDown.position, Vector2.down, distance, layerWall);

        if (groundInfo.collider)
        {
            Death();
        }


        if (!groundDownInfo.collider && timeForTouchGround <= 0)
        {
            StartCoroutine(TimeForDown());
        }

        timeForRestLive -= Time.deltaTime;

        if (enemyDetection.collider && timeForRestLive <= 0)
        {
            live -= 1;
            currentLive.ChangeLive(live);
            animCamera.SetBool("Damage", true);
            timeForRestLive = timeForRestLiveCL;
        }
        else
        {
            animCamera.SetBool("Damage", false);
        }

        if (live <= 0)
        {
            Death();
        }
    }