Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Move(Character character, float cameraAngle, Vector3 forwardVector, List<int> keys)
- {
- float x_temp = 0;
- float z_temp = 0;
- float yRotation_temp = 0;
- float angle = 0;
- FacingDirection dirFacing = GetDirectionForAngle(angle);
- FacingDirection camFacing = GetDirectionForAngle(cameraAngle);
- _console.AddLog("Cam facing: " + camFacing.ToString());
- if (keys.Contains((int)KeyInput.W) && keys.Contains((int)KeyInput.A))
- {
- if (character.AsPlayer()._PlayerState != PlayerState.STRAFING_DIAGONALLY)
- {
- character.AsPlayer()._PlayerState = PlayerState.STRAFING_DIAGONALLY;
- character.AsPlayer().PerformAnimation(new Animation("strafe", 0));
- }
- }
- else
- {
- if (character.AsPlayer()._PlayerState == PlayerState.STRAFING_DIAGONALLY)
- {
- character.AsPlayer()._PlayerState = PlayerState.IDLE;
- }
- }
- if (character.AsPlayer()._PlayerState != PlayerState.MOVING && character.AsPlayer()._PlayerState != PlayerState.STRAFING_DIAGONALLY)
- {
- character.AsPlayer()._PlayerState = PlayerState.MOVING;
- character.AsPlayer().PerformAnimation(new Animation("run", 0));
- }
- if (keys.Contains((int)KeyInput.W))
- {
- //x_temp = (0.055f * (float)Math.Round(Math.Sin(angle * (Math.PI / 180)), 4) * forwardVector.Z);
- if (camFacing != FacingDirection.NORTH && camFacing != FacingDirection.SOUTH)
- {
- x_temp += (0.055f * (float)Math.Round(Math.Cos(angle * (Math.PI / 180)), 4) * forwardVector.X);
- z_temp += (0.055f * (float)Math.Round(Math.Cos(angle * (Math.PI / 180)), 4) * forwardVector.Z);
- }
- else
- {
- z_temp = (0.055f * (float)Math.Round(Math.Cos(angle * (Math.PI / 180)), 4) * forwardVector.Z);
- x_temp = (0.055f * (float)Math.Round(Math.Cos(angle * (Math.PI / 180)), 4) * forwardVector.X);
- }
- }
- if (keys.Contains((int)KeyInput.A))
- {
- if (camFacing != FacingDirection.NORTH && camFacing != FacingDirection.SOUTH)
- {
- z_temp += (0.055f * (float)Math.Round(Math.Cos(angle * (Math.PI / 180)), 4) * forwardVector.X);
- } else
- x_temp -= (0.055f * (float)Math.Round(Math.Cos(angle * (Math.PI / 180)), 4) * forwardVector.Z);
- }
- if (keys.Contains((int)KeyInput.S))
- {
- x_temp -= (0.055f * (float)Math.Round(Math.Sin(angle * (Math.PI / 180)), 4) * forwardVector.X);
- z_temp -= (0.055f * (float)Math.Round(Math.Cos(angle * (Math.PI / 180)), 4) * forwardVector.Z);
- }
- if (keys.Contains((int)KeyInput.D))
- {
- if (camFacing != FacingDirection.NORTH && camFacing != FacingDirection.SOUTH)
- {
- z_temp -= (0.055f * (float)Math.Round(Math.Cos(angle * (Math.PI / 180)), 4) * forwardVector.X);
- }
- else
- x_temp += (0.055f * (float)Math.Round(Math.Cos(angle * (Math.PI / 180)), 4) * forwardVector.Z);
- }
- character._Position.angle = cameraAngle;
- //temp new pos
- x_temp += character._Position.x;
- z_temp += character._Position.z;
- yRotation_temp += character._Rotation.Y;
- if (character.IsPlayer())
- {
- var player = character.AsPlayer();
- player._OldPosition = character.AsPlayer()._Position;
- player._OldRotation = new Vector3(0, yRotation_temp, 0);
- DetectCollision(player, x_temp, z_temp, yRotation_temp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment