コード例 #1
0
        // Token: 0x0600003F RID: 63 RVA: 0x000023FC File Offset: 0x000005FC
        private static object DehumanizeToPrivate(string input, Type targetEnum, OnNoMatch onNoMatch)
        {
            Enum @enum = Enum.GetValues(targetEnum).Cast <Enum>().FirstOrDefault((Enum value) => string.Equals(value.Humanize(), input, StringComparison.OrdinalIgnoreCase));

            if (@enum == null && onNoMatch == OnNoMatch.ThrowsException)
            {
                throw new NoMatchFoundException("Couldn't find any enum member that matches the string " + input);
            }
            return(@enum);
        }
コード例 #2
0
 /// <summary>
 /// Dehumanizes a string into the Enum it was originally Humanized from!
 /// </summary>
 /// <param name="input">The string to be converted</param>
 /// <param name="targetEnum">The target enum</param>
 /// <param name="onNoMatch">What to do when input is not matched to the enum.</param>
 /// <returns></returns>
 /// <exception cref="NoMatchFoundException">Couldn't find any enum member that matches the string</exception>
 /// <exception cref="ArgumentException">If targetEnum is not an enum</exception>
 public static Enum DehumanizeTo(this string input, Type targetEnum, OnNoMatch onNoMatch = OnNoMatch.ThrowsException)
 {
     return((Enum)DehumanizeToPrivate(input, targetEnum, onNoMatch));
 }
コード例 #3
0
 /// <summary>
 /// Dehumanizes a string into the Enum it was originally Humanized from!
 /// </summary>
 /// <typeparam name="TTargetEnum">The target enum</typeparam>
 /// <param name="input">The string to be converted</param>
 /// <exception cref="ArgumentException">If TTargetEnum is not an enum</exception>
 /// <exception cref="NoMatchFoundException">Couldn't find any enum member that matches the string</exception>
 /// <returns></returns>
 public static TTargetEnum DehumanizeTo <TTargetEnum>(this string input, OnNoMatch onNoMatch = OnNoMatch.ThrowsException)
     where TTargetEnum : struct, IComparable, IFormattable
 {
     return((TTargetEnum)DehumanizeToPrivate(input, typeof(TTargetEnum), onNoMatch));
 }
コード例 #4
0
        private IEnumerator ValidateBoard(UnityAction callback)
        {
            // Check for Matches
            int removedTileCount = 0;

            for (int x = 0; x < tilesDimesions.x; x++)
            {
                for (int y = 0; y < tilesDimesions.y; y++)
                {
                    Vector2Int coordinate = new Vector2Int(x, y);

                    if (ValidateMatch(coordinate, out List <Vector2Int> matchList))
                    {
                        float duration = 0f;

                        // --- Clean Matches ---
                        for (int i = 0; i < matchList.Count; i++)
                        {
                            duration = tiles[matchList[i].x, matchList[i].y].Despawn();
                            tiles[matchList[i].x, matchList[i].y] = null;
                            ++removedTileCount;
                        }

                        // Event
                        if (OnMatch != null)
                        {
                            OnMatch.Invoke(matchList.Count);
                        }

                        if (removedTileCount > 0)
                        {
                            yield return(new WaitForSeconds(tweenMatchTileDelay));
                        }
                    }
                }
            }

            // --- Shifting/Refill ---
            if (removedTileCount > 0)
            {
                Vector3 startPosition = boardOriginPosition;

                for (int x = 0; x < tilesDimesions.x; x++)
                {
                    for (int y = tilesDimesions.y - 1; y >= 0; y--)
                    {
                        if (tiles[x, y] == null)
                        {
                            bool found = false;

                            for (int y2 = y; y2 >= 0; y2--)
                            {
                                if (tiles[x, y2] != null)
                                {
                                    Vector3 position = new Vector3(startPosition.x + (tileSize.x * 0.5f) + (tileSize.x * x),
                                                                   startPosition.y - (tileSize.y * 0.5f) - (tileSize.y * y), 0);

                                    tiles[x, y2].SetPosition(position);
                                    tiles[x, y]  = tiles[x, y2];
                                    tiles[x, y2] = null;
                                    found        = true;
                                    break;
                                }
                            }

                            // Refill
                            if (!found)
                            {
                                // -- Create Tileset --
                                BoardTile[] tilesetLibrary = boardProfile.tilePack.boardTiles; // TileSet
                                //int tileIndex = possibleBoardTiles[Random.Range(0, possibleBoardTiles.Count)];
                                BoardTile prefab   = tilesetLibrary[Random.Range(0, tilesetLibrary.Length)];
                                Vector3   position = new Vector3(startPosition.x + (prefab.size.x * 0.5f) + (prefab.size.x * x),
                                                                 startPosition.y - (prefab.size.y * 0.5f) - (prefab.size.y * y), 0);

                                BoardTile newTile = Instantiate(prefab, position + new Vector3(0f, 10f), prefab.transform.rotation, boardOrigin);
                                tiles[x, y] = newTile;
                                tiles[x, y].SetPosition(position);
                            }
                        }
                    }

                    yield return(new WaitForSeconds(tweenRefillRowDelay));
                }

                // Event
                if (OnRefill != null)
                {
                    OnRefill.Invoke();
                }

                // --- Revalidate Board ---
                StartCoroutine(ValidateBoard(callback));
            }
            else
            {
                if (OnNoMatch != null)
                {
                    OnNoMatch.Invoke();
                }

                callback?.Invoke();
            }
        }