private void Update() { if (Input.GetKeyUp(KeyCode.LeftShift)) { ToggleCursor(); } var input = new DemoInput { Forward = Input.GetKey(KeyCode.W), Backward = Input.GetKey(KeyCode.S), Left = Input.GetKey(KeyCode.A), Right = Input.GetKey(KeyCode.D), Up = Input.GetKey(KeyCode.E) || Input.GetKey(KeyCode.Space), Down = Input.GetKey(KeyCode.Q) || Input.GetKey(KeyCode.LeftControl), Yaw = Input.GetAxis("Mouse X"), Pitch = -Input.GetAxis("Mouse Y") }; if (!Cursor.visible) { Trans.Rotate(Vector3.up, HorizontalMouseSensitivity * Time.deltaTime * input.Yaw, Space.World); Trans.Rotate(Vector3.right, VerticalMouseSensitivity * Time.deltaTime * input.Pitch); } Vector3 delta = Vector3.zero; if (input.Forward ^ input.Backward) { delta += input.Forward ? Trans.forward : -Trans.forward; } if (input.Right ^ input.Left) { delta += input.Right ? Trans.right : -Trans.right; } if (input.Up ^ input.Down) { delta += input.Up ? Trans.up : -Trans.up; } if (MovementType == MovementType.CharacterController) { CharacterController?.Move(MoveSpeed * Time.deltaTime * delta.normalized); } else { Trans.position += MoveSpeed * Time.deltaTime * delta.normalized; } }
public async Task CreatDemo(DemoInput input) { var demoRepository = GetService <IDapperRepository <DemoEntity, string> >(); var entity = input.MapTo <DemoEntity>(); await demoRepository.InsertAsync(entity); }