Word Game Builder 2.0.1f2
Reference Manual
Public Member Functions | Properties | List of all members
TilePool Class Reference

A class that manages an instance pool of letter tiles. More...

+ Inheritance diagram for TilePool:
+ Collaboration diagram for TilePool:

Public Member Functions

void Add (ILetterTile item)
 Adds a tile to the tile pool. If the pool already contains the tile, this does nothing. More...
 
bool AddLetter (Letter letter, int count)
 Add the specified letter and count to the tile distribution dictionary. More...
 
void Clear ()
 Clears all tiles from the tile pool. More...
 
bool Contains (Letter letter)
 Returns true if the tile pool currently contains the specified letter. This method does not look at spawned tiles. More...
 
bool Contains (ILetterTile item)
 Determines if the specified tile is contained within the tile pool. More...
 
void CopyTo (ILetterTile[] array, int arrayIndex)
 Copies the contents of the tile pool to a compatible one-dimensional array, starting at the specified index of the target array. More...
 
void CreateTile (Letter letter)
 Spawns a brand new tile into the pool, based on the specified letter. More...
 
void CreateTilePool (Transform parent)
 Creates the tile pool. More...
 
void CreateTilePool ()
 Creates the tile pool. More...
 
void DestroyAllTiles ()
 Destroys all tiles that were created by this tile pool (whether it is currently in the pool or not). More...
 
void DestroyTile (ILetterTile tile)
 Destroys the tile from the scene, if the tile is associated with the pool. More...
 
void DestroyTiles (IList< ILetterTile > tiles)
 Destroys a list of tiles from the scene, if the tiles are associated with the pool. More...
 
void DistributeTiles (IWordGamePlayer player)
 Distributes the specified amount of tiles to the specified IWordGamePlayer, up to the player's maximum tile count. More...
 
void DistributeTiles (IWordGamePlayer player, int count)
 Distributes the specified amount of tiles to the specified IWordGamePlayer, up to count or the player's maximum tile count (whichever comes first). More...
 
void DistributeTiles (IWordGamePlayer player, Letter letter, int count)
 Distributes the specified amount of tiles, with the specified letter, to the specified IWordGamePlayer, up to count or the player's maximum tile count (whichever comes first). More...
 
void DistributeTiles (IWordGamePlayer player, IList< Letter > letters)
 Distributes the specified list of letters to the specified IWordGamePlayer, up to the length of the specified letter list or the player's maximum tile count (whichever comes first). More...
 
IEnumerator< ILetterTileGetEnumerator ()
 Returns an enumerator that iterates through the tile pool (generic version). More...
 
int GetOccurances (Letter letter)
 Gets the amount of occurances of the specified letter within the tile pool. This method does not look at spawned tiles. More...
 
int IndexOf (Letter letter)
 Determines the index of a specific letter in the ITilePool. More...
 
int IndexOf (ILetterTile item)
 Determines the index of a specific tile in the tile pool. More...
 
void Insert (ILetterTile item)
 Inserts a tile into the pool at a random position, if it does not already contain it. More...
 
void Insert (int index, ILetterTile item)
 Inserts a letter tile into the pool at the specified position, if it does not already contain it. More...
 
int LastIndexOf (Letter letter)
 
bool Remove (ILetterTile item)
 Removes the specified tile from the tile pool. More...
 
void RemoveAt (int index)
 Removes the letter tile at the specified index. More...
 
bool RemoveLetter (Letter letter)
 Remove the specified letter from the tile distribution dictionary. More...
 
void RemoveTiles (IList< ILetterTile > tiles)
 Removes a list of tiles from the pool, if the tiles are associated with the pool. More...
 
void ResetTilePool ()
 Resets the tile pool. More...
 
void SaveTileDistribution ()
 Saves the tile distribution dictionary. More...
 
void SetTiles (IList< ILetterTile > tiles)
 Sets the tile pool. More...
 
- Public Member Functions inherited from WGBBase
GetComponentFromInterface< T > ()
 Gets a component from its interface type. More...
 
GetComponentInChildrenFromInterface< T > ()
 Gets a component from its interface type, searching through this GameObject and all children. More...
 
T[] GetComponentsFromInterface< T > ()
 Gets all components from its interface type. More...
 
T[] GetComponentsInChildrenFromInterface< T > ()
 Gets all components from its interface type, searching through this GameObject and all children. More...
 
- Public Member Functions inherited from IMonoBehaviour
void CancelInvoke ()
 Cancels all Invoke calls on this MonoBehaviour. More...
 
void CancelInvoke (string methodName)
 Cancels all Invoke calls with name methodName on this behaviour. More...
 
int GetInstanceID ()
 Returns the instance id of the object. More...
 
void Invoke (string methodName, float time)
 Invokes the method methodName in time seconds. More...
 
void InvokeRepeating (string methodName, float time, float repeatRate)
 Invokes the method methodName in time seconds. More...
 
bool IsInvoking ()
 Is any invoke pending on this MonoBehaviour? More...
 
bool IsInvoking (string methodName)
 Is any invoke on methodName pending? More...
 
Coroutine StartCoroutine (IEnumerator routine)
 Starts a coroutine. More...
 
Coroutine StartCoroutine (string methodName)
 Starts a coroutine named methodName. More...
 
Coroutine StartCoroutine (string methodName, object value)
 Starts a coroutine named methodName. More...
 
void StopAllCoroutines ()
 Stops all coroutines running on this behaviour. More...
 
void StopCoroutine (string methodName)
 Stops all coroutines named methodName running on this behaviour. More...
 
string ToString ()
 Returns the name of the game object. More...
 

Properties

int blankLetterCount [get, set]
 The amount of blank letters in the tile distribution. More...
 
int Count [get]
 Returns the amount of tiles in the tile pool. More...
 
bool IsReadOnly [get]
 Returns true if the tile is read only. More...
 
WordGameLanguage language [get, set]
 The language associated with the tile pool. More...
 
string languageIdentifier [get, set]
 The language identifier associated with the tile pool. More...
 
int lastDistributionCount [get]
 Gets the last tile distribution count. This value is set before event callbacks. More...
 
WGBEvent onTileDistribution [get, set]
 This event fires when a tile is distributed from the tile pool. More...
 
int poolMultiplier [get, set]
 A multiplier for the tile distribution. Used to easily increase the amount of tiles created. More...
 
ILetterTile this[int index] [get, set]
 Gets or sets the letter tile at the specified index. More...
 
Dictionary< Letter, int > tileDistribution [get]
 Gets the tile distribution dictionary. More...
 
int tileDistributionCount [get, set]
 Gets or sets the amount of elements in the tile distribution. More...
 
GameObject tilePrefab [get, set]
 The tile prefab. This must contain a MonoBehaviour that implements ILetterTile. More...
 
- Properties inherited from WGBBase
object userData [get, set]
 Additional user data associated with this object. This is unused by default. More...
 
- Properties inherited from ITilePool
WordGameLanguage language [get, set]
 The language associated with the tile pool. More...
 
int lastDistributionCount [get]
 Gets the last tile distribution count. This value is set before event callbacks. More...
 
WGBEvent onTileDistribution [get, set]
 This event should fire when a tile is distributed from the tile pool. More...
 
Dictionary< Letter, int > tileDistribution [get]
 Gets the tile distribution dictionary. More...
 
- Properties inherited from IMonoBehaviour
bool enabled [get, set]
 Enabled Behaviours are Updated, disabled Behaviours are not. More...
 
GameObject gameObject [get]
 The game object this component is attached to. A component is always attached to a game object. More...
 
HideFlags hideFlags [get, set]
 Should the object be hidden, saved with the scene or modifiable by the user? More...
 
string name [get, set]
 The name of the object. More...
 
string tag [get, set]
 The tag of this game object. More...
 
Transform transform [get]
 The Transform attached to this GameObject. A component is always attached to a transform. More...
 
object userData [get, set]
 Additional user data associated with this object. This is unused by default. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from WGBBase
static T FindObjectOfTypeFromInterface< T > ()
 Finds the first object of interface type T. More...
 
static T[] FindObjectsOfTypeFromInterface< T > ()
 Finds all objects of interface type T. More...
 
static T InstantiateFromInterface< T > (T original)
 Instantiate a GameObject from interface type T. More...
 
static T InstantiateFromInterface< T > (T original, Vector3 position, Quaternion rotation)
 Instantiate a GameObject from interface type T at the specified position and rotation. More...
 
static void Log (object message, string prefix, string type)
 Logs a prefixed message. More...
 
static void Log (object message, string prefix, string type, Object context)
 Logs a prefixed message, with context. More...
 
static void LogError (object message, string prefix, string type)
 Logs a prefixed erorr. More...
 
static void LogError (object message, string prefix, string type, Object context)
 Logs a prefixed exception, with context. More...
 
static void LogException (System.Exception ex)
 Logs an exception. More...
 
static void LogException (System.Exception ex, Object context)
 Logs an exception, with context. More...
 
static void LogWarning (object message, string prefix, string type)
 Logs a prefixed warning. More...
 
static void LogWarning (object message, string prefix, string type, Object context)
 Logs a prefixed warning, with context. More...
 

Detailed Description

A class that manages an instance pool of letter tiles.

This class creates an instance pool based on a specific letter distribution. It implements IList<ILetterTile>.

Member Function Documentation

void Add ( ILetterTile  item)
inline

Adds a tile to the tile pool. If the pool already contains the tile, this does nothing.

This method is an O(n) operation, where n is the number of tiles in the pool.

Parameters
itemThe tile to add to the pool.
bool AddLetter ( Letter  letter,
int  count 
)
inline

Add the specified letter and count to the tile distribution dictionary.

Parameters
letterThe letter to add.
countThe amount of tiles to add.
Returns
true if the operation was successful; otherwise false.
void Clear ( )
inline

Clears all tiles from the tile pool.

This does not delete or remove any tile objects.

bool Contains ( Letter  letter)
inline

Returns true if the tile pool currently contains the specified letter. This method does not look at spawned tiles.

Parameters
letterThe letter to search for.
Returns
True if the letter exists in the tile pool and is not spawned; otherwise false.

Implements ITilePool.

bool Contains ( ILetterTile  item)
inline

Determines if the specified tile is contained within the tile pool.

Parameters
itemThe tile to search for.
Returns
True if the tile pool contains the specified tile; otherwise, false.
void CopyTo ( ILetterTile[]  array,
int  arrayIndex 
)
inline

Copies the contents of the tile pool to a compatible one-dimensional array, starting at the specified index of the target array.

Parameters
arrayThe one-dimensional array that is the destination of the elements copied from the tile pool.
arrayIndexThe zero-based index in array at which copying begins.
void CreateTile ( Letter  letter)
inline

Spawns a brand new tile into the pool, based on the specified letter.

Parameters
letterThe letter to spawn.

Implements ITilePool.

+ Here is the call graph for this function:

void CreateTilePool ( Transform  parent)
inline

Creates the tile pool.

Parameters
parentThe parent transform for the tile pool.

This destroys any tiles currently created by the pool (whether it is in the pool or not), and instantiates tile pool objects based on the letter distribution.

+ Here is the call graph for this function:

void CreateTilePool ( )
inline

Creates the tile pool.

This destroys any tiles currently created by the pool (whether it is in the pool or not), and instantiates tile pool objects based on the letter distribution.

Implements ITilePool.

void DestroyAllTiles ( )
inline

Destroys all tiles that were created by this tile pool (whether it is currently in the pool or not).

If a tile's parent object is changed, it will not be destroyed with this method and will become unmanaged by the pool.

Implements ITilePool.

+ Here is the call graph for this function:

void DestroyTile ( ILetterTile  tile)
inline

Destroys the tile from the scene, if the tile is associated with the pool.

This will fully destroy the tile and remove it from any player's possession. Beware - this is a destructive operation in edit mode!

Parameters
tileThe tile to destroy.

Implements ITilePool.

+ Here is the call graph for this function:

void DestroyTiles ( IList< ILetterTile tiles)
inline

Destroys a list of tiles from the scene, if the tiles are associated with the pool.

Parameters
tilesThe list of tiles to destroy.

+ Here is the call graph for this function:

void DistributeTiles ( IWordGamePlayer  player)
inline

Distributes the specified amount of tiles to the specified IWordGamePlayer, up to the player's maximum tile count.

This automatically removes the tile from the tile pool, and gives them to the player. The tile must still be spawned.

Parameters
playerThe player to distribute tiles to.

Implements ITilePool.

void DistributeTiles ( IWordGamePlayer  player,
int  count 
)
inline

Distributes the specified amount of tiles to the specified IWordGamePlayer, up to count or the player's maximum tile count (whichever comes first).

This method automatically removes the tile from the tile pool, and gives them to the player. The tile must still be spawned.

Thinksquirrel.WordGameBuilder.ObjectModel.IWordGamePlayer

Parameters
playerThe player to distribute tiles to.
countThe amount of tiles to attempt to distribute.

Implements ITilePool.

void DistributeTiles ( IWordGamePlayer  player,
Letter  letter,
int  count 
)
inline

Distributes the specified amount of tiles, with the specified letter, to the specified IWordGamePlayer, up to count or the player's maximum tile count (whichever comes first).

This method automatically removes the tile from the tile pool, and gives them to the player. The tile must still be spawned.

Thinksquirrel.WordGameBuilder.ObjectModel.IWordGamePlayer

Parameters
playerThe player to distribute tiles to.
letterThe letter to distribute.
countThe amount of tiles to attempt to distribute.

Implements ITilePool.

void DistributeTiles ( IWordGamePlayer  player,
IList< Letter letters 
)
inline

Distributes the specified list of letters to the specified IWordGamePlayer, up to the length of the specified letter list or the player's maximum tile count (whichever comes first).

Letters not currently available will NOT be distributed. This method automatically removes the tile from the tile pool, and gives them to the player. The tile must still be spawned.

Thinksquirrel.WordGameBuilder.ObjectModel.IWordGamePlayer

Parameters
playerThe player to distribute tiles to.
lettersThe letters to attempt to distribute.

Implements ITilePool.

IEnumerator<ILetterTile> GetEnumerator ( )
inline

Returns an enumerator that iterates through the tile pool (generic version).

Returns
An enumerator for the tile pool.
int GetOccurances ( Letter  letter)
inline

Gets the amount of occurances of the specified letter within the tile pool. This method does not look at spawned tiles.

Returns
The number of occurances of the specified letter.
Parameters
letterThe letter to search for.

Implements ITilePool.

int IndexOf ( Letter  letter)
inline

Determines the index of a specific letter in the ITilePool.

Returns
The index of item if found in the list; otherwise, -1.
Parameters
letterThe letter to search for.

Implements ITilePool.

int IndexOf ( ILetterTile  item)
inline

Determines the index of a specific tile in the tile pool.

Returns
The index of item if found in the list; otherwise, -1.
Parameters
itemThe tile to search for.
void Insert ( ILetterTile  item)
inline

Inserts a tile into the pool at a random position, if it does not already contain it.

Parameters
itemThe tile to insert.

Implements ITilePool.

void Insert ( int  index,
ILetterTile  item 
)
inline

Inserts a letter tile into the pool at the specified position, if it does not already contain it.

Parameters
indexThe position at which to insert the tile.
itemThe tile to insert.
int LastIndexOf ( Letter  letter)
inline

Determines the last index of a specific letter in the ITilePool.

Returns
The last index of item if found in the list; otherwise, -1.
Parameters
letterThe letter to search for.

Implements ITilePool.

bool Remove ( ILetterTile  item)
inline

Removes the specified tile from the tile pool.

Parameters
itemThe tile to remove.
Returns
True if the operation was successful; otherwise, false.
void RemoveAt ( int  index)
inline

Removes the letter tile at the specified index.

Parameters
indexThe index at which to remove a letter tile.
bool RemoveLetter ( Letter  letter)
inline

Remove the specified letter from the tile distribution dictionary.

Parameters
letterThe letter to remove.
Returns
true if the operation was successful; otherwise false.
void RemoveTiles ( IList< ILetterTile tiles)
inline

Removes a list of tiles from the pool, if the tiles are associated with the pool.

Parameters
tilesThe list of tiles to remove.
void ResetTilePool ( )
inline

Resets the tile pool.

This will despawn all tiles, reshuffle all tiles, and put all tiles that belong to this object back into the pool.

Implements ITilePool.

+ Here is the call graph for this function:

void SaveTileDistribution ( )
inline

Saves the tile distribution dictionary.

When modifying the tile distribution dictionary, this method must be called to serialize the tile pool. This is usually only needed in the editor.

+ Here is the call graph for this function:

void SetTiles ( IList< ILetterTile tiles)
inline

Sets the tile pool.

This destroys any tiles currently created by the pool, and replaces the entire pool. Used for advanced serialization.

Parameters
tilesA list of tiles to add to the newly created pool.

Property Documentation

int blankLetterCount
getset

The amount of blank letters in the tile distribution.

int Count
get

Returns the amount of tiles in the tile pool.

bool IsReadOnly
get

Returns true if the tile is read only.

In the default tile pool implementation, this will always return false.

WordGameLanguage language
getset

The language associated with the tile pool.

Implements ITilePool.

string languageIdentifier
getset

The language identifier associated with the tile pool.

int lastDistributionCount
get

Gets the last tile distribution count. This value is set before event callbacks.

Implements ITilePool.

WGBEvent onTileDistribution
getset

This event fires when a tile is distributed from the tile pool.

Variables set:

  • WGBEvent.currentLanguage
  • WGBEvent.currentTilePool
  • WGBEvent.currentPlayer

Implements ITilePool.

int poolMultiplier
getset

A multiplier for the tile distribution. Used to easily increase the amount of tiles created.

ILetterTile this[int index]
getset

Gets or sets the letter tile at the specified index.

Parameters
indexThe zero-based index of the letter tile to get or set.
Dictionary<Letter, int> tileDistribution
get

Gets the tile distribution dictionary.

This dictionary is only used at runtime. To add or remove from the dictionary in the editor, call the Add and Remove methods on the TilePool class. Implements ITilePool.

int tileDistributionCount
getset

Gets or sets the amount of elements in the tile distribution.

Used in the editor for serailization.

GameObject tilePrefab
getset

The tile prefab. This must contain a MonoBehaviour that implements ILetterTile.