private void Lash(int direction) { velocityBeforeLash = myRigidBody.velocity; switch (direction) { case UP: if (!myObjectRotator.RotateObject(CEILING_ANGLE)) { break; } myRigidBody.gravityScale = -1f; myConstantForce2D.force = Vector2.zero; isLashing = true; OnCeiling(); break; case DOWN: if (!myObjectRotator.RotateObject(FLOORED_ANGLE)) { break; } myRigidBody.gravityScale = 1f; myConstantForce2D.force = Vector2.zero; isLashing = false; OnFloor(); break; case RIGHT: if (!myObjectRotator.RotateObject(RIGHT_ANGLE)) { break; } myRigidBody.gravityScale = 0f; myConstantForce2D.force = Vector2.right * (myRigidBody.mass * 9.81f); isLashing = true; OnRightWall(); break; case LEFT: if (!myObjectRotator.RotateObject(LEFT_ANGLE)) { break; } myRigidBody.gravityScale = 0f; myConstantForce2D.force = Vector2.left * (myRigidBody.mass * 9.81f); isLashing = true; OnLeftWall(); //Turn these into coroutines that only call the orientation changers only when no direction key is held OR the player lands OR just put a "wait for release" coroutine before break; default: break; } }
public void Lash(int direction, bool rotate) { if (!stormlightCloud.isPlaying) { stormlightCloud.Play(); } _lashed = true; heldStormlight = ObjectLashCost; switch (direction) { case UP: if (rotate) { if (!myObjectRotator.RotateObject(CEILING_ANGLE)) { break; } } myRigidbody2D.gravityScale = -1f * gravityScale; myConstantForce2D.force = Vector2.zero; myRigidbody2D.bodyType = RigidbodyType2D.Dynamic; break; case DOWN: if (rotate) { if (!myObjectRotator.RotateObject(FLOORED_ANGLE)) { break; } } myRigidbody2D.gravityScale = 1f * gravityScale; myConstantForce2D.force = Vector2.zero; myRigidbody2D.bodyType = RigidbodyType2D.Dynamic; break; case RIGHT: if (rotate) { if (!myObjectRotator.RotateObject(RIGHT_ANGLE)) { break; } } myRigidbody2D.gravityScale = 0f; myConstantForce2D.force = Vector2.right * (myRigidbody2D.mass * 9.81f * gravityScale); myRigidbody2D.bodyType = RigidbodyType2D.Dynamic; break; case LEFT: if (rotate) { if (!myObjectRotator.RotateObject(LEFT_ANGLE)) { break; } } myRigidbody2D.gravityScale = 0f; myConstantForce2D.force = Vector2.left * (myRigidbody2D.mass * 9.81f * gravityScale); myRigidbody2D.bodyType = RigidbodyType2D.Dynamic; break; default: break; } }