예제 #1
0
    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;
            }
        }
    }
예제 #2
0
        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());
        }
예제 #3
0
    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);
    }
예제 #4
0
    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);
    }
예제 #5
0
 public override string ToString()
 {
     return(TileStatus.ToString());
 }