Beispiel #1
0
 private void onShowWaterIndicator()
 {
     if (HasFlow)
     {
         WaterIndicator.SetActive(true);
     }
 }
    /// <summary>
    /// Анализ окружающей персонажа обстановки
    /// </summary>
    protected override void Analyse()
    {
        if (groundCheck.WallInFront())
        {
            groundState = GroundStateEnum.grounded;
        }
        else
        {
            groundState = GroundStateEnum.inAir;
        }

        if ((groundState == GroundStateEnum.grounded))
        {
            bool crouching = false;
            if (Physics2D.OverlapCircle(wallAboveCheck.position, groundRadius, whatIsGround) || Input.GetButton("Flip"))
            {
                groundState = GroundStateEnum.crouching;
                crouching   = true;
            }
            if (employment > 6)
            {
                Crouch(crouching);
            }

            if (fallSpeed > minDamageFallSpeed)
            {
                TakeDamage(Mathf.Round((fallSpeed - minDamageFallSpeed) * damagePerFallSpeed), true);
            }
            if (fallSpeed > minDamageFallSpeed / 10f)
            {
                Animate(new AnimationEventArgs("fall"));
            }
            fallSpeed = 0f;
        }
        else
        {
            Crouch(false);
            fallSpeed = -rigid.velocity.y;
        }

        bool _underWater = Physics2D.OverlapCircle(waterCheck.position, groundRadius, LayerMask.GetMask("Water"));

        if (underWater != _underWater)
        {
            underWater = _underWater;
            WaterIndicator waterIndicator = waterCheck.GetComponent <WaterIndicator>();
            if (_underWater)
            {
                rigid.gravityScale = .6f;
                waterIndicator.StartCoroutine(SuffocateProcess());
            }
            else
            {
                rigid.gravityScale = 1f;
                waterIndicator.StopAllCoroutines();
                AirSupply = maxAirSupply;
            }
            Animate(new AnimationEventArgs("waterSplash"));
        }

        if (onLadder)
        {
            if (!Physics2D.OverlapCircle(transform.position - transform.up * ladderCheckOffset, ladderStep, LayerMask.GetMask("ladder")))
            {
                LadderOff();
            }
        }
    }