Tilt Five™ Unity API  1.4.1
TiltFive.Player Class Reference

Provides access to player settings and functionality. More...

Inheritance diagram for TiltFive.Player:
TiltFive.Singleton< Player >

Classes

class  PlayerCore
 
class  WaitUntilPlayerConnected
 Suspends coroutine execution until the provided player has connected. More...
 

Static Public Member Functions

static bool IsConnected (PlayerIndex playerIndex)
 Determines whether the specified player has an associated pair of glasses connected. More...
 
static bool TryGetFriendlyName (PlayerIndex playerIndex, out string friendlyName)
 Attempts to get the friendly name assigned to the specified player's glasses. More...
 
static bool TryGetSettings (PlayerIndex playerIndex, out PlayerSettings playerSettings)
 Obtains the PlayerSettings corresponding to the specified player. More...
 

Private Attributes

Dictionary< PlayerIndex, PlayerCoreplayers = new Dictionary<PlayerIndex, PlayerCore>()
 

Additional Inherited Members

- Protected Member Functions inherited from TiltFive.Singleton< Player >
 Singleton ()
 
- Properties inherited from TiltFive.Singleton< Player >
static T Instance [get]
 

Detailed Description

Provides access to player settings and functionality.

Definition at line 30 of file Player.cs.

Member Function Documentation

◆ IsConnected()

static bool TiltFive.Player.IsConnected ( PlayerIndex  playerIndex)
static

Determines whether the specified player has an associated pair of glasses connected.

Parameters
playerIndex
Returns

Definition at line 48 of file Player.cs.

49  {
50  return playerIndex != PlayerIndex.None && Instance.players.TryGetValue(playerIndex, out var playerCore);
51  }
PlayerIndex
The Player index (e.g. Player One, Player Two, etc)

References TiltFive.Singleton< Player >.Instance.

Referenced by TiltFive.Display.GetGlassesAvailability(), TiltFive.SplitStereoCamera.OnRenderImage(), and TiltFive.Glasses.GlassesCore.Update().

◆ TryGetFriendlyName()

static bool TiltFive.Player.TryGetFriendlyName ( PlayerIndex  playerIndex,
out string  friendlyName 
)
static

Attempts to get the friendly name assigned to the specified player's glasses.

Parameters
playerIndex
friendlyName
Returns

Definition at line 60 of file Player.cs.

61  {
62  if (playerIndex == PlayerIndex.None || !Instance.players.TryGetValue(playerIndex, out var playerCore))
63  {
64  friendlyName = "";
65  return false;
66  }
67 
68  friendlyName = playerCore.FriendlyName;
69  return true;
70  }

References TiltFive.Singleton< Player >.Instance.

◆ TryGetSettings()

static bool TiltFive.Player.TryGetSettings ( PlayerIndex  playerIndex,
out PlayerSettings  playerSettings 
)
static

Obtains the PlayerSettings corresponding to the specified player.

Parameters
playerIndex
playerSettings
Returns
Returns false and sets playerSettings to null if the provided player index is invalid, or if there are no player settings defined in the scene due to the absence of a TiltFiveManager2 or TiltFiveManager.

Definition at line 79 of file Player.cs.

80  {
81  // We need to obtain a TiltFiveManager2 or TiltFiveManager to query for player settings.
82  // Since we don't know which (if either) is available, we'll use TiltFiveSingletonHelper.
83  if (playerIndex == PlayerIndex.None || !TiltFiveSingletonHelper.TryGetISceneInfo(out var sceneInfo))
84  {
85  playerSettings = null;
86  return false;
87  }
88 
89  if (sceneInfo is TiltFiveManager2 tiltFiveManager2
90  && tiltFiveManager2.TryGetPlayerSettings(playerIndex, out var resultingPlayerSettings))
91  {
92  playerSettings = resultingPlayerSettings;
93  return true;
94  }
95 
96  // If we are dealing with a TiltFiveManager, the scene is singleplayer-only; reject other player indices.
97  if (sceneInfo is TiltFiveManager tiltFiveManager && playerIndex == PlayerIndex.One)
98  {
99  playerSettings = tiltFiveManager.playerSettings;
100  return true;
101  }
102 
103  playerSettings = null;
104  return false;
105  }

References TiltFive.TiltFiveSingletonHelper.TryGetISceneInfo(), and TiltFive.TiltFiveManager2.TryGetPlayerSettings().

Referenced by TiltFive.GameBoard.InverseTransformPoint(), TiltFive.GameBoard.InverseTransformPose(), TiltFive.GameBoard.TransformPoint(), and TiltFive.GameBoard.TransformPose().

Member Data Documentation

◆ players

Dictionary<PlayerIndex, PlayerCore> TiltFive.Player.players = new Dictionary<PlayerIndex, PlayerCore>()
private

Definition at line 34 of file Player.cs.


The documentation for this class was generated from the following file: