public override void Act(KeyboardState ks, MouseState ms) { if (Position.Y < -5) { SetPosition(1, 10, 1); return; } Vector3 bodyCenter = new Vector3(Position.X, GetCenterPointForAllHitboxes().Y, Position.Z); Vector2 msMovement = CurrentWindow.GetMouseCursorMovement(ms); AddRotationY(-msMovement.X * 40); Vector3 cameraLav = GetLookAtVector(); Vector3 cameraLavRotated = HelperRotation.RotateVector(cameraLav, -90, Plane.Y); float currentSpeed = 0.1f * KWEngine.DeltaTimeFactor; if (ks[Key.A] || ks[Key.D] || ks[Key.W] || ks[Key.S]) { if (ks[Key.W]) { MoveAlongVector(cameraLav, currentSpeed); } if (ks[Key.S]) { MoveAlongVector(cameraLav, -currentSpeed); } if (ks[Key.A]) { MoveAlongVector(-cameraLavRotated, currentSpeed); } if (ks[Key.D]) { MoveAlongVector(cameraLavRotated, currentSpeed); } } else { } MoveOffset(0, -0.1f, 0); DoCollisionDetection(); Console.WriteLine(Position); }
public override void Act(KeyboardState ks, MouseState ms) { if (Position.Y < -5) { _momentum = 0; SetPosition(1, 10, 1); return; } Vector3 bodyCenter = new Vector3(Position.X, GetCenterPointForAllHitboxes().Y, Position.Z); Vector2 msMovement = CurrentWindow.GetMouseCursorMovement(ms); AddRotationY(-msMovement.X * 40); //Vector3 camTargetWithOffset = DoCameraPosition(msMovement); Vector3 cameraLav = GetLookAtVector(); Vector3 cameraLavRotated = HelperRotation.RotateVector(cameraLav, -90, Plane.Y); float currentSpeed = _speed * KWEngine.DeltaTimeFactor; if (ks[Key.A] || ks[Key.D] || ks[Key.W] || ks[Key.S]) { if (ks[Key.W]) { MoveAlongVector(cameraLav, currentSpeed); } if (ks[Key.S]) { MoveAlongVector(cameraLav, -currentSpeed); } if (ks[Key.A]) { MoveAlongVector(-cameraLavRotated, currentSpeed); } if (ks[Key.D]) { MoveAlongVector(cameraLavRotated, currentSpeed); } _running = true; _attacking = false; } else { if (_running) { _percentage = 0; _running = false; } } if (_state == PlayerState.OnFloor && (ks[Key.Space] || ms[MouseButton.Right])) { if (!_upKeyPressed) { _state = PlayerState.Jump; _percentage = 0; _momentum = 0.35f; _upKeyPressed = true; _attacking = false; } } else if (!(ks[Key.Space] || ms[MouseButton.Right])) { _upKeyPressed = false; } if (ks[Key.ShiftLeft] || ms[MouseButton.Left]) { DoShoot(ms); } DoStates(); DoCollisionDetection(); DoAnimation(); }
public override void Act(KeyboardState ks, MouseState ms) { if (Position.Y < -25) { SetPosition(0, 0, 0); return; } Vector3 bodyCenter = new Vector3(Position.X, GetCenterPointForAllHitboxes().Y, Position.Z); Vector2 msMovement = CurrentWindow.GetMouseCursorMovement(ms); AddRotationY(-msMovement.X * 40); Vector3 camTargetWithOffset = DoCameraPosition(msMovement); Vector3 cameraLav = GetLookAtVector(); Vector3 cameraLavRotated = HelperRotation.RotateVector(cameraLav, -90, Plane.Y); float currentSpeed = _speed * KWEngine.DeltaTimeFactor; if (ks[Key.A] || ks[Key.D] || ks[Key.W] || ks[Key.S]) { if (ks[Key.W]) { MoveAlongVector(cameraLav, currentSpeed); } if (ks[Key.S]) { MoveAlongVector(cameraLav, -currentSpeed); } if (ks[Key.A]) { MoveAlongVector(-cameraLavRotated, currentSpeed); } if (ks[Key.D]) { MoveAlongVector(cameraLavRotated, currentSpeed); } _running = true; _attacking = false; } else { if (_running) { _percentage = 0; _running = false; } } if (_state == PlayerState.OnFloor && (ks[Key.Space] || ms[MouseButton.Right])) { if (!_upKeyPressed) { _state = PlayerState.Jump; _percentage = 0; _momentum = 0.35f; _upKeyPressed = true; _attacking = false; } } else if (!(ks[Key.Space] || ms[MouseButton.Right])) { _upKeyPressed = false; } //_sphere.SetPosition(target); if (ks[Key.ShiftLeft] || ms[MouseButton.Left]) { DoShoot(ms); //_attacking = true; //_percentage = 0.25f; } //if (_attacking && _percentage >= 1) //{ // _attacking = false; // _percentage = 0; //} DoStates(); DoCollisionDetection(); DoAnimation(); /* * List<GameObject> objects = PickGameObjectsFromLookAtVector(GetLookAtVector() + new Vector3(0, 1, 0), 0); * foreach(GameObject g in objects) * { * Console.WriteLine(CurrentWorld.GetCurrentTimeInMilliseconds() + ": " + g.Name); * } */ }