# Components

### ChessGameBaseGUI Component

{% hint style="info" %}
There are quite a few GUI components inherited from this components as their base class. However, only [ChessPuzzleGUI ](#chesspuzzlegui-inherited-from-chessgamebasegui-component)and [ChessPuzzleEditorGUI ](#chesspuzzleeditorgui-inherited-from-chessgamebasegui-component)has different Inspector UI due to the nature of their game mode and usage.
{% endhint %}

<figure><img src="https://2079102914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA7OKfIba5xvQF1lhv60z%2Fuploads%2Fl8wZq3c0R5ZWQHChr0RY%2FUnity_ISjvp4xXYE.png?alt=media&#x26;token=128893c6-82d0-4a54-817a-1d07df546346" alt=""><figcaption></figcaption></figure>

**Force Optional Draw** - Should auto draw on threefold repetition and fifty-moves rule. When unticked, players have the option to decline such draw when it happens. Note that this option is useless even when it is ticked on [ChessPGN](../scenes-details/chesspgn) scene as PGN text file imported from other places might not stops at threefold repetition or fifty-moves rule.

**Has Graveyard** - Should spawn graveyard tiles when the scene first loaded.

**Start With Fen** - If the game should start with fen when pieces are being first spawn to the board.

**Fen String** - The FEN(Forsyth-Edwards Notation) string being used to spawn pieces when Start With Fen toggle is ticked.



<figure><img src="https://2079102914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA7OKfIba5xvQF1lhv60z%2Fuploads%2FN66APAIq6yg8mGgv8aSd%2Fprefab.png?alt=media&#x26;token=5a7d1aab-c0ae-4605-9a5f-940fa234beb1" alt=""><figcaption></figcaption></figure>

Those removed script component found on certain prefab on scene are meant to be replaced by their derived component as shown in image above, any of those script component that has GUI name within it can exist only exactly once per scene. see [inheritence](../honorable-mentioned/gui-classes).



#### ChessPuzzleGUI(Inherited from ChessGameBaseGUI) Component

<figure><img src="https://2079102914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA7OKfIba5xvQF1lhv60z%2Fuploads%2FIPRSDsDTryxgqHTAAvU2%2FUnity_1reBNX1EiQ.png?alt=media&#x26;token=558c5cb3-80b9-457f-ac29-43414ad2e251" alt=""><figcaption></figcaption></figure>

For puzzle game, all SerializedField are being hidden from inspector since Chess Puzzle Game does not need any of the options available like GUIs used for standard chess game does.



#### ChessPuzzleEditorGUI(Inherited from ChessGameBaseGUI) Component

<figure><img src="https://2079102914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA7OKfIba5xvQF1lhv60z%2Fuploads%2FqQDBRiu3fhcxvruuIaU4%2FUnity_BSwBBnVN7f.png?alt=media&#x26;token=2dfb8863-5329-4904-b3de-1c80572f41fd" alt=""><figcaption></figcaption></figure>

The Inspector UI is written with custom editor script, please refer to Manage Puzzle Data section of [Puzzle Editor](../../scenes-details/chesspuzzleeditor#manage-puzzle-scriptable-object-data-start-with-fen-string) page.&#x20;





### ChessObjectManager Component

A component required by GUI as it will provides all the GameObjects information

<figure><img src="https://2079102914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA7OKfIba5xvQF1lhv60z%2Fuploads%2FBLbQCXFWZ5hOCB7bWCTz%2FUnity_1mu9qgTwdq.png?alt=media&#x26;token=0febef5b-2f59-43ce-99a8-38dd0bd34519" alt=""><figcaption><p>ChessObjectManager component</p></figcaption></figure>

_Is 3D_ - Whether the game should start with 3D, if unticked, the game will be started with 2D sprites.&#x20;

**Tiles Game Objects Section** - Containing black and white tiles prefab, the formula to spawn them as a standard 8x8 chess tile pattern is used when game scene with scene gameobject attached with GUI component is loaded.

**Graveyard Game Objects Section** - The prefabs for black and white graveyard tiles, captured pieces will be placed on them if graveyard is enabled from GUI component.

**Pieces 2D Game Objects Section** - All 2D chess pieces prefabs, can be left empty if the game is only available in 3D.

**Pieces 3D Game Objects Section** - All 3D chess pieces prefabs, can be left empty if the game is only available in 2D.

**Adjust Tiles Position Section** - All tiles will be moved by the margin of the X,Y,Z axis set from the origin when the game scene first started.&#x20;

**Adjust Graveyard Position Section** - :&#x20;

{% hint style="info" %}
**The settings of whether to spawn graveyard tiles is on GUIs component**
{% endhint %}

_Space In Between_ - Whether the algorithm to calculate graveyard tiles position should use z-axis length of tile prefab or graveyard tile prefab as the difference. When ticked, Imagine that the algorithm is spawning white tiles instead of graveyard tiles and eventually replaced all those white tiles with graveyard tiles which ended up having spaces in between each of them as the white tile prefab has a wider z-axis than as of graveyard tile.&#x20;

_Graveyard Column/Row Start_ - The algorithm of spawning graveyard tiles is designed to be symmetrical, meaning spawning one graveyard tile at -1.5 x-axis will spawn another at 1.5 x-axis as well.  &#x20;

_Graveyard Column/Row Count_ - How many column/row graveyard tiles should be spawned on each side, just give the number and the algorithm will do the work. The total number of tiles for a side(row x column) cannot be less than the possible number of capture made for the side on the game.

**Camera Position Adjustment Section** - These are preset camera position, the camera will be set at the exact position or auto adjusted when it is 2D/3D/3D that have graveyards.&#x20;





### ChessUIManager Component

{% hint style="info" %}
You may noticed that most of the scenes have their UI scene game object set active even when it is not intended to be shown when game first started, unused UI can be set inactive directly. This is where Chess UI Manager component kick in to decide which UI should be showing and which is not depending on situation. The reasons all UI that's intended to be used during gameplay should be set active is because this package system need all scripts attached to UI prefabs(BaseUI subclassed scripts) to have their OnStart() method being called, setting them inactive would nullify that when the scene first loaded.&#x20;
{% endhint %}

With this component, it is easier to switch the decision of which UI should be shown before start button is pressed or when the quit button is pressed.

<figure><img src="https://2079102914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA7OKfIba5xvQF1lhv60z%2Fuploads%2FrpRg4boOw2ue1gNeX5dU%2FUnity_VdjqlngnrL.gif?alt=media&#x26;token=81677092-46c2-4974-b9eb-92fdddc4afc3" alt=""><figcaption><p>It is possible to just drag UI game object directly into any list of Chess UI Manager</p></figcaption></figure>

<figure><img src="https://2079102914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA7OKfIba5xvQF1lhv60z%2Fuploads%2Fcjfdm8CLpuM8iHlPYryQ%2FUnity_WPb2oUi9dC.png?alt=media&#x26;token=d5b3a683-b3cd-42bb-a631-6943ab8f9539" alt=""><figcaption><p>ChessUIManager component</p></figcaption></figure>

**Show On Start** - When the start button is pressed, the UIs with the script attached will be set active but it will remain inactive before start button is pressed or when quit button is pressed.

**Hide On Start** - UIs in this list will remain active when the scene first loaded or when quit game button is pressed, but hidden otherwise.&#x20;

**Interactable On Start** - Like Show On Start list, but instead of set active or inactive, it sets the UI interactability.

**Non Interactable On Start** - The exact opposite of Interactable On Start list.

**Hide On Play** - This list accept Game Object instead of (BaseUI subclassed scripts) attached to Game Object, Game Object in this list will directly being set inactive when scene first loaded. If this list is not used but instead of setting the game object inactive on scene, the OnStart() method will not get called when scene first loaded, just to repeat in case.





### SoundEffectManager Component

<figure><img src="https://2079102914-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA7OKfIba5xvQF1lhv60z%2Fuploads%2FYCQPCrLr02FiXBLqJAqj%2FUnity_LW2QxTKphQ.png?alt=media&#x26;token=d29987b4-00a9-474a-a669-d323839ed4fc" alt=""><figcaption></figcaption></figure>

**Enable** - No sound will be displayed whenever it is unticked and otherwise.

**Chess Move Sound Effect** - The sound effect when piece move from one tile to another.

**Chess Attack Sound Effect** - The sound effect when piece did make a capture while performing a move.

**Checking Sound Effect** - The sound effect when piece is checking the opponent king, this sound effect will be priorities over any others.

**Check Mate Sound Effect** - The sound effect when chess game result is provided, even when it's a draw. Should have changed it's name to Game Finished Sound Effect instead. This will stop all others sound effect from playing.

Tips : All of the sound effect object fields can be left blank without problems.

