internal Vector2?fromScreenToPosition(Vector2 p) { if (BoardBounds.Contains(p.toPoint())) { p.X -= BoardBounds.X; p.Y -= BoardBounds.Y; return(new Vector2((int)(p.X / TilesSize), (int)(p.Y / TilesSize))); } else { return(null); } }
/// <summary> /// The Offline setup allows us to play on any wild screen /// The Online setup is placing borders at fixed positions /// </summary> void SetupBorders() { if (_gameMode == GameModes.Offline) { var cam = Camera.main; var leftBound = cam.ViewportToWorldPoint(new Vector3(0, 0, 0)).x; var rightBound = cam.ViewportToWorldPoint(new Vector3(1, 0, 0)).x; HorizontalBounds = new BoardBounds(leftBound, rightBound); _leftCollider.DOMoveX(HorizontalBounds.Left, 0.25f); _rightCollider.DOMoveX(HorizontalBounds.Right, 0.25f); } else { _leftCollider.position = new Vector2(-_onlineBoardOffset, 0); _rightCollider.position = new Vector2(_onlineBoardOffset, 0); HorizontalBounds = new BoardBounds(-_onlineBoardOffset, _onlineBoardOffset); } }