Пример #1
0
    private LetterTileBinding.State GetStateForResult(WordCheckResult result)
    {
        LetterTileBinding.State state;
        switch (result)
        {
        case WordCheckResult.CONTAINS:
        case WordCheckResult.MATCH:
            state = LetterTileBinding.State.SELECTED;
            break;

        case WordCheckResult.ERROR:
            state = LetterTileBinding.State.ERROR;
            break;

        default:
            throw new InvalidOperationException($"Could not handle unknown result: {result}");
        }

        return(state);
    }
Пример #2
0
 public void Reset()
 {
     BoardWord[] componentsInChildren = wordPod.gameObject.GetComponentsInChildren <BoardWord>();
     for (int i = 0; i < componentsInChildren.Length; i++)
     {
         UnityEngine.Object.Destroy(componentsInChildren[i].gameObject);
     }
     fill.gameObject.SetActive(value: false);
     icon.gameObject.SetActive(value: false);
     wordText.Reset();
     wordText.ResetText();
     wordText.CalculateFill();
     levelWidth           = 0;
     levelHeight          = 0;
     levelScale           = 0f;
     isWordPodScaleUpdate = false;
     wordPodScaleCurrent  = 0f;
     wordPodScaleTarget   = 0f;
     isEnabled            = false;
     IsWordValid          = false;
     Result         = WordCheckResult.None;
     isReset        = true;
     selectedX      = int.MinValue;
     selectedY      = int.MinValue;
     selectedLetter = null;
     selectedIndex  = 0;
     shineDelay     = UnityEngine.Random.Range(5, 10);
     CancelInvoke("EnableInvoke");
     CancelInvoke("ShowFillInvoke");
     CancelInvoke("HideFillInvoke");
     CancelInvoke("ShowIconInvoke");
     CancelInvoke("HideIconInvoke");
     CancelInvoke("ShowWordsInvoke");
     CancelInvoke("HideWordsInvoke");
     CancelInvoke("TipInvoke");
 }
Пример #3
0
    public WordCheckResult CheckWordNormal(bool aIsLevelCompleted)
    {
        Result = WordCheckResult.None;
        BoardWord[] componentsInChildren = wordPod.gameObject.GetComponentsInChildren <BoardWord>();
        for (int i = 0; i < componentsInChildren.Length; i++)
        {
            if (componentsInChildren[i].IsSelected() && string.Equals(wordText.Text, componentsInChildren[i].Word, StringComparison.OrdinalIgnoreCase))
            {
                componentsInChildren[i].IsCompleted = true;
                componentsInChildren[i].MarkLetters(aIsWithAnimation: true);
                componentsInChildren[i].RewardCoins();
                if (i == level.hintTipIndex)
                {
                    ELSingleton <GameWindow> .Instance.tipText.Hide();

                    level.hintTipIndex = -1;
                }
                ELSingleton <LevelsSettings> .Instance.Save();

                Result = WordCheckResult.Valid;
            }
            else
            {
                componentsInChildren[i].UnSelectLetters();
            }
        }
        if (Result == WordCheckResult.None && wordText.Text.Length > 0)
        {
            if (!aIsLevelCompleted && ELSingleton <DictionarySettings> .Instance.CheckWord(wordText.Text.ToLower()))
            {
                if (ELSingleton <LevelsSettings> .Instance.levelSet.IsExtraWord(wordText.Text.ToLower()))
                {
                    Result = WordCheckResult.Repeat;
                }
                else
                {
                    ELSingleton <LevelsSettings> .Instance.levelSet.AddExtraWord(wordText.Text.ToLower());

                    Result = WordCheckResult.ExtraWord;
                }
            }
            else
            {
                Result = WordCheckResult.Invalid;
            }
        }
        if (Result == WordCheckResult.Valid)
        {
            wordText.Valid();
        }
        else if (Result == WordCheckResult.Invalid)
        {
            wordText.Invalid();
        }
        else if (Result == WordCheckResult.ExtraWord)
        {
            wordText.ExtraWord();
        }
        else if (Result == WordCheckResult.Repeat)
        {
            wordText.Repeat();
        }
        return(Result);
    }