void Update() { if (Time.timeScale == 0) { return; } bool onGround2 = timeInAir < 0.02f; if (!onGround) { timeInAir += Time.deltaTime; } if (GameMaster.enabledMovement && (Input.GetKey(KeyCode.DownArrow) || InputMixer.CrouchS)) { if (!isCrouching && !isJumping) { isCrouching = true; controller.Crouch(true); } } else if (isCrouching && controller.CanStand()) { isCrouching = false; controller.Crouch(false); } if (GameMaster.enabledMovement && (Input.GetButtonDown("Jump") || InputMixer.JumpDownS) && !isCrouching) { if (onGround) { doubleJumpTimer = 0; Jump(); } else if (canDoubleJump) { velocity.y = 0; canDoubleJump = false; Jump(); } } if (GameMaster.enabledMovement && (Input.GetButtonUp("Jump") || InputMixer.JumpUpS) && isJumping) { velocity.y *= 0.4f; isJumping = false; } if (jumpTimer < timeToJumpApex) { jumpTimer += Time.deltaTime; } if (jumpTimer >= timeToJumpApex) { isJumping = false; } if (GameMaster.enabledMovement && (Input.GetButton("Jump") || InputMixer.JumpS) && !onGround && !isDashing && !isJumping && !isCrouching) { doubleJumpTimer += Time.deltaTime; if (doubleJumpTimer > 0.1f) { floatGravity = true; } } else { doubleJumpTimer = 0; floatGravity = false; } Vector2 input; if (GameMaster.enabledMovement) { input = new Vector2(Mathf.Clamp(Input.GetAxisRaw("Horizontal") + InputMixer.HorizontalS, -1, 1), Input.GetAxisRaw("Vertical")); } else { input = new Vector2(0, 0); } //совршить рывок if (GameMaster.enabledMovement && (Input.GetKeyDown(KeyCode.LeftShift) || InputMixer.DashDownS) && sinceLastDash >= timeBetweenDashes && !isCrouching && stamina > 0) { isDashing = true; stamina -= 1; StartCoroutine(DecreaseSlider(sliderSTA, .2f, stamina / 10)); } if (!isDashing) { sinceLastDash += Time.deltaTime; } else { sinceLastDash = 0; } if (isCrouching) { velocity.x = input.x * crouchSpeed; } else if (isDashing && dashTime <= maxDashTime) { dashTime += Time.deltaTime; velocity.x = (input.x != 0)?(input.x * dashSpeed):((facingRight)?(dashSpeed):(-dashSpeed)); } else { velocity.x = input.x * moveSpeed; isDashing = false; dashTime = 0; } if (!isCrouching && (Input.GetKeyDown(KeyCode.C) || InputMixer.Skill3DownS)) { ult.Ultimate(facingRight, skill3modifier); } if (onGround && !isCrouching && !isDashing && weapon.CanWalk()) { if (GameMaster.enabledMovement && (Input.GetKeyDown(KeyCode.Z) || InputMixer.Skill1DownS) && stamina > 0) { weapon.Hit1(facingRight, skill1modifier); stamina -= 1; StartCoroutine(DecreaseSlider(sliderSTA, .2f, stamina / 10)); } else if (GameMaster.enabledMovement && (Input.GetKeyDown(KeyCode.X) || InputMixer.Skill2DownS) && stamina > 0) { weapon.Hit2(facingRight, skill2modifier); stamina -= 2; StartCoroutine(DecreaseSlider(sliderSTA, .2f, stamina / 10)); } } if (!weapon.CanWalk()) { velocity.x = 0; } if (velocity.x != 0 || isCrouching || isDashing || !onGround) { weaponRenderer.enabled = false; } else { weaponRenderer.enabled = true; } animator.SetBool("isMoving", velocity.x != 0); animator.SetBool("floatGravity", floatGravity); animator.SetBool("isJumping", isJumping); animator.SetBool("isDashing", isDashing); animator.SetBool("isCrouching", isCrouching); animator.SetBool("onGround", onGround2); }