public void PickTile(Vector2Int position) { if (SetTile(position) == true) { if (CheckIfWon(tiles) != TileStatus.None) { Debug.Log(currentPlayer.ToString() + " WON!"); Reset(); return; } else if (GetOpenTiles(tiles) <= 0) { Debug.Log("DRAW!"); Reset(); return; } currentPlayer = currentPlayer == TileStatus.X ? TileStatus.O : TileStatus.X; if (SetTile(AIMove())) { if (CheckIfWon(tiles) != TileStatus.None) { Debug.Log(currentPlayer.ToString() + " WON!"); Reset(); return; } currentPlayer = currentPlayer == TileStatus.X ? TileStatus.O : TileStatus.X; } } }
public static string GetDescription(this TileStatus enumerationValue) { var type = enumerationValue.GetType(); if (!type.IsEnum) { throw new ArgumentException($"{nameof(enumerationValue)} must be of Enum type", nameof(enumerationValue)); } var memberInfo = type.GetMember(enumerationValue.ToString()); if (memberInfo.Length > 0) { var attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false); if (attrs.Length > 0) { return(((DescriptionAttribute)attrs[0]).Description); } } return(enumerationValue.ToString()); }
private bool SetTile(Vector2Int position) { TileStatus tile = tiles[position.x, position.y]; if (tile != TileStatus.None) { Debug.Log("This tile is already taken."); return(false); } tile = currentPlayer; tiles[position.x, position.y] = tile; GetTileGO(position).GetComponentInChildren <Text>().text = tile.ToString(); return(true); }
public string GetEnvironmentStats() { string output = string.Format("Type: {0}\nHuman Pop: {1}\nFlora Pop: {2}\nFauna Pop: {3}\nHealth Status: {4}", type.ToString(), humanPopulation, floraPopulation, faunaPopulation, status.ToString()); return(output); }
public override string ToString() { return(TileStatus.ToString()); }