Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }