18using System.Collections.Generic;
35 [Tooltip(
"Show/Hide the Board Gizmo in the Editor.")]
38 [Tooltip(
"Show/Hide the Unit Grid on the Board Gizmo in the Editor.")]
48 [Tooltip(
"Sets the Alpha transparency of the Board Gizmo in the Editor.")]
56 [Obsolete(
"Please use Gameboard.TryGetGameboardType() instead.")]
59 #endregion Public Fields
62 #region Private Fields
69 private TableTopGizmo boardGizmo =
new TableTopGizmo();
84 private float currentContentScaleRatio;
89 private Vector3 currentScale;
91 private const float MIN_SCALE = 0.00001f;
95 private static Dictionary<PlayerIndex, GameboardType>
playerGameboards =
new Dictionary<PlayerIndex, GameboardType>();
97 #endregion Private Fields
100 #region Public Structs
118 #endregion Private Structs
121 #region Public Functions
138 if(!
Player.TryGetGlassesHandle(playerIndex, out var glassesHandle)
139 || !
playerGameboards.TryGetValue(playerIndex, out var currentGameboardType))
145 gameboardType = currentGameboardType;
183 new public void Awake()
186 currentScale = transform.localScale;
201 var sceneViewRepaintNecessary = ScaleCompensate(scaleSettings);
202 sceneViewRepaintNecessary |= ContentScaleCompensate(scaleSettings);
204 if(sceneViewRepaintNecessary)
206 boardGizmo.ResetGrid(scaleSettings, gameBoardSettings);
207 UnityEditor.SceneView.lastActiveSceneView.Repaint();
218 return GetDisplayedGameboardType(
PlayerIndex.One, gameBoardSettings);
228 var displayedGameboardType =
playerGameboards.TryGetValue(playerIndex, out var gameboardType)
232 displayedGameboardType = gameBoardSettings.gameboardTypeOverride != GameboardType.GameboardType_None
233 ? gameBoardSettings.gameboardTypeOverride
234 : displayedGameboardType;
236 return displayedGameboardType;
241 #endregion Public Functions
244 #region Internal Functions
256 internal static void SetGameboardType(GlassesHandle glassesHandle,
GameboardType gameboardType)
258 if (
Player.TryGetPlayerIndex(glassesHandle, out var playerIndex))
260 SetGameboardType(playerIndex, gameboardType);
267 #region Private Functions
279 if(currentScale == transform.localScale) {
return false; }
282 if( transform.localScale.x < MIN_SCALE)
284 transform.localScale = Vector3.one * MIN_SCALE;
291 currentScale = transform.localScale;
298 private bool ContentScaleCompensate(
ScaleSettings scaleSettings)
301 && currentContentScaleUnit == scaleSettings.
contentScaleUnit) {
return false; }
316 #endregion Private Functions
Represents the game board.
static bool TryGetGameboardDimensions(GameboardType gameboardType, out GameboardDimensions gameboardDimensions)
Attempts to obtain the physical dimensions for a particular gameboard type.
bool ShowGizmo
Shows the game board gizmo in the editor.
static Dictionary< PlayerIndex, GameboardType > playerGameboards
static bool TryGetGameboardType(out GameboardType gameboardType)
Attempts to check the latest glasses pose for the current gameboard type, such as LE,...
static bool TryGetGameboardType(PlayerIndex playerIndex, out GameboardType gameboardType)
float GizmoOpacity
Sets the opacity of the game board gizmo in the editor.
GameboardType GameboardType
The gameboard configuration, such as LE, XE, or folded XE.
static void Error(string m, params object[] list)
ERROR logging function call.
static int GetGameboardDimensions([MarshalAs(UnmanagedType.I4)] GameboardType gameboardType, ref T5_GameboardSize playableSpaceInMeters)
Provides access to player settings and functionality.
ScaleSettings contains the scale data used to translate between Unity units and the user's physical s...
LengthUnit contentScaleUnit
The real-world unit to be compared against when using .
float contentScaleRatio
The scaling ratio relates physical distances to world-space units.
GameboardType
The type of Gameboard being tracked by the glasses.
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)
GameboardDimensions(T5_GameboardSize gameboardSize)
Physical dimensions of a gameboard, in meters.