private void jump() { setIgnoringShelfCollisions(true); JumpStrategy jumpStrategy = getJumpStrategy(); startJumpForStrategy(jumpStrategy); if (jumpStrategy != JumpStrategy.NONE) { isJumping = true; } Debug.Log("Strategy " + jumpStrategy + " to jump from " + currentFloor); }
private void startJumpForStrategy(JumpStrategy strategy) { if (strategy == JumpStrategy.NONE) { return; } if (strategy != JumpStrategy.FORWARD) { speed = 0; } switch (strategy) { case JumpStrategy.DOWN: collisionDisablingTime = 0.5f; break; case JumpStrategy.NORMAL_UP: collisionDisablingTime = 1f; rb.velocity = Vector2.up * 7.5f; GetComponent <AudioSource>().Play(); break; case JumpStrategy.HIGH_UP: collisionDisablingTime = 1.3f; rb.velocity = Vector2.up * 9f; GetComponent <AudioSource>().Play(); break; case JumpStrategy.VERY_HIGH_UP: collisionDisablingTime = 1.5f; rb.velocity = Vector2.up * 10f; GetComponent <AudioSource>().Play(); break; case JumpStrategy.FORWARD: rb.velocity = Vector2.up * 7f; GetComponent <AudioSource>().Play(); break; } }