private void Update() { if (UpgradesStation.IsShopOpen() || inventory.IsOpen()) { return; } // Check for fuel consumption if (isInMiningState || Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D)) { fuelManager.DecreaseFuel(Time.deltaTime / 3); } if (!isFlying && IsTouchingGround() && (isInMiningState || rb.velocity.magnitude > 0.5f)) { movingAnim.SetBool("isMoving", true); } else { movingAnim.SetBool("isMoving", false); } if (isFlying && IsTouchingGround()) { isFlying = false; UseHorizontalDrill(); } // Check for mining state if (!isInMiningState && !isFlying && rb.velocity.magnitude == 0) { // Get player tile position Vector2Int pos = new Vector2Int(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y)); // Get direction to see if player wants to mine if (Input.GetKey(KeyCode.A) && isDirLeft && GroundManager.ExistsTileInPosition(pos + new Vector2Int(-1, 0))) { StartMining(pos, Vector2Int.left); } if (Input.GetKey(KeyCode.D) && !isDirLeft && GroundManager.ExistsTileInPosition(pos + new Vector2Int(1, 0))) { StartMining(pos, Vector2Int.right); } if (Input.GetKey(KeyCode.S) && GroundManager.ExistsTileInPosition(pos + new Vector2Int(0, -1))) { StartMining(pos, Vector2Int.down); } } }