Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        _EC.directionalInfluence = playerControls.Player.Move.ReadValue <Vector2>();

        if (_EC.state == EntityMotionState.AIR)
        {
            if (_EC.subAirTime == COYOTE_TIME && !isJumping)
            {
                jumps--;
            }
        }

        // While holding jump, keep going until the max jump is achieved, and then drop afterwards.
        if (isJumping)
        {
            if (jumpTimeCounter > 0)
            {
                //rb.velocity = Vector2.up * jumpVelocity;
                jumpTimeCounter -= Time.deltaTime;
            }
            else
            {
                isJumping = false;
                _EC.TallyAirTime();
            }
        }

        // Holding down to CROUCH while on the ground and you are not dashing into the ground.
        if (_EC.state == EntityMotionState.GROUNDED && !dashAction.IsActive())
        {
            crouching = _EC.directionalInfluence.y < 0 ? true : false;
        }

        // Enable and disable the top half collider for the player when crouching.
        // TODO: Can optimize to not constantly change form!
        if (crouching)
        {
            _EC.ChangeForm(1);
        }
        else
        {
            _EC.ChangeForm(0);
        }

        // Decay heat.
        if (currentHeat > 0f && heatDelayCounter <= 0f)
        {
            AdjustCurrentHeat(-heatDecayPerSec * Time.deltaTime);
        }
        if (heatDelayCounter > 0f)
        {
            heatDelayCounter -= Time.deltaTime;
        }
        if (currentColor != Color.white)
        {
            swingHitboxSprite.color = currentColor;
            currentColor            = Color.Lerp(currentColor, Color.white, 0.1f);
        }
    }