public Vector3 GetNextPosition(Vector3 currentPosition, PlayerAction action) { if (isServer) { bool isSpace = Matrix.Matrix.At(currentPosition).IsSpace(); if (isSpace && !isInSpace) { isInSpace = true; } else if (!isSpace && isInSpace) { isInSpace = false; } } var direction = GetDirection(action); if (!isGhost) { playerSprites.FaceDirection(direction); } var adjustedDirection = AdjustDirection(currentPosition, direction); if (adjustedDirection == Vector3.zero) { Interact(currentPosition, direction); } return(currentPosition + adjustedDirection); }
private Vector3Int GetMoveDirection(MatrixInfo matrixInfo) { Vector3Int direction = Vector3Int.zero; for (int i = 0; i < pressedKeys.Count; i++) { direction += GetMoveDirection(pressedKeys[i]); } direction.x = Mathf.Clamp(direction.x, -1, 1); direction.y = Mathf.Clamp(direction.y, -1, 1); if (!isGhost && PlayerManager.LocalPlayer == gameObject) { playerSprites.CmdChangeDirection(Orientation.From(direction)); //Prediction: playerSprites.FaceDirection(Orientation.From(direction)); } if (matrixInfo.MatrixMove) { //Converting world direction to local direction direction = Vector3Int.RoundToInt(matrixInfo.MatrixMove.ClientState.Orientation.EulerInverted * direction); } return(direction); }
//THIS IS ONLY USED FOR LOCAL PLAYER public void MovePlayer(Vector2 direction) { //At the moment it just checks if the input window is open and if it is false then allow move if (!UIManager.Chat.chatInputWindow.activeSelf && IsMine) { physicsMove.MoveInDirection(direction); //Tile based physics move playerSprites.FaceDirection(direction); //Handles the playersprite change on direction change } }
public Vector3Int GetNextPosition(Vector3Int currentPosition, PlayerAction action) { Vector3Int direction = GetDirection(action); if (!isGhost) { playerSprites.FaceDirection(new Vector2(direction.x, direction.y)); } Vector3Int adjustedDirection = AdjustDirection(currentPosition, direction); if (adjustedDirection == Vector3.zero) { Interact(currentPosition, direction); } return(currentPosition + adjustedDirection); }
public Vector3 GetNextPosition(Vector3 currentPosition, PlayerAction action) { var direction = GetDirection(action); if (!isGhost) { playerSprites.FaceDirection(direction); } var adjustedDirection = AdjustDirection(currentPosition, direction); if (adjustedDirection == Vector3.zero) { Interact(currentPosition, direction); Interact(currentPosition, Vector3.zero); } return(currentPosition + adjustedDirection); }
private Vector3Int GetMoveDirection(List <KeyCode> actions) { Vector3Int direction = Vector3Int.zero; for (int i = 0; i < pressedKeys.Count; i++) { direction += GetMoveDirection(pressedKeys[i]); } direction.x = Mathf.Clamp(direction.x, -1, 1); direction.y = Mathf.Clamp(direction.y, -1, 1); if (!isGhost && PlayerManager.LocalPlayer == gameObject) { playerSprites.CmdChangeDirection(new Vector2(direction.x, direction.y)); //Prediction: playerSprites.FaceDirection(new Vector2(direction.x, direction.y)); } return(direction); }