private string SetMarkContainerText(Coords squareCoords, SquareMarkLocation markLocation) { string markText = string.Empty; if (markLocation == SquareMarkLocation.Top || markLocation == SquareMarkLocation.Bottom) { markText = squareCoords.Column.ToString(); } else if (markLocation == SquareMarkLocation.Right || markLocation == SquareMarkLocation.Left) { markText = squareCoords.Row.ToString(); } return(markText); }
private void AddMarkingGameObjectToSquare(GameObject square, SquareMarkLocation markLocation) { string markName = markLocation.Equals(SquareMarkLocation.Top | SquareMarkLocation.Bottom) ? GameObjectNames.SquareMarkHorizontal : GameObjectNames.SquareMarkVertical; var markContainer = new GameObject(markName, typeof(TextMeshPro)); markContainer.AddAsChildrenTo(square); markContainer.transform.localScale = new Vector3 { x = square.transform.localScale.x / 10f, y = square.transform.localScale.y / 2f, z = square.transform.localScale.z / 10f }; markContainer.transform.localRotation = Quaternion.Euler(90f, markLocation == SquareMarkLocation.Bottom ? 0f : 180f, markLocation == SquareMarkLocation.Right ? 180f: 0f); SetMarkContainerTextMesh(markContainer, square.GetComponent <Square>().GetCoordinates(), markLocation); markContainer.transform.localPosition = SetMarkContainerPosition(markContainer.transform.localPosition, square.transform.localScale, markLocation); }
private Vector3 SetMarkContainerPosition(Vector3 markContainerLocalPosition, Vector3 squareLocalScale, SquareMarkLocation markLocation) { switch (markLocation) { case SquareMarkLocation.Top: markContainerLocalPosition.z += squareLocalScale.z; break; case SquareMarkLocation.Bottom: markContainerLocalPosition.z -= squareLocalScale.z; break; case SquareMarkLocation.Left: markContainerLocalPosition.x -= squareLocalScale.x; break; case SquareMarkLocation.Right: markContainerLocalPosition.x += squareLocalScale.x; break; } markContainerLocalPosition.y += 0.1f; return(markContainerLocalPosition); }
private void SetMarkContainerTextMesh(GameObject markContainer, Coords squareCoords, SquareMarkLocation markLocation) { var markContainerTextMesh = markContainer.GetComponent <TextMeshPro>(); markContainerTextMesh.fontSize = BoardConfiguration.BorderMarksFontSize; markContainerTextMesh.text = SetMarkContainerText(squareCoords, markLocation); markContainerTextMesh.alignment = TextAlignmentOptions.Center; }