Beispiel #1
0
    public PentaLetter GetLetter()
    {
        PentaLetter item = _letters[0];

        _letters.RemoveAt(0);
        return(item);
    }
Beispiel #2
0
    public IEnumerator SelectWord(string word)
    {
        bool        letterFound    = false;
        PentaLetter previousLetter = null;

        word = word.ToLower();

        foreach (char letter in word)
        {
            letterFound = false;
            foreach (PentaLetter pentaLetter in _pentaLetters)
            {
                if (pentaLetter.GetLetter() == letter)
                {
                    letterFound = true;
                    bool nextLetterIsSelectable = pentaLetter.TryToSelect(previousLetter);
                    yield return(new WaitForSecondsRealtime(0.3f));

                    if (!nextLetterIsSelectable)
                    {
                        yield break;
                    }

                    previousLetter = pentaLetter;
                    break;
                }
            }
            if (!letterFound)
            {
                yield break;
            }
        }
    }
Beispiel #3
0
 private void Store(PentaLetter letter)
 {
     _letters.Add(letter);
     letter.transform.SetParent(_lettersHolder);
     letter.transform.localPosition = Vector2.zero;
     //letter.GetComponent<RectTransform>().offsetMin = Vector2.zero;
     //letter.GetComponent<RectTransform>().offsetMax = Vector2.zero;
 }
Beispiel #4
0
    private void SelectLetter(PentaLetter letter)
    {
        Debug.Log("Scroll: Selected letter " + letter.GetLetter());
        _selectedLetters.Add(letter);
        _currentWord += letter.GetLetter();

        _SelectedWordChangedCallback(_currentWord);
    }
Beispiel #5
0
    public void Clear(PentaLetter lastLetter)
    {
        _nowSelecting = false;

        _lineRenderer.positionCount = 0;

        _lettersCount = 1;
        _lettersPos.Clear();
        _lettersPos.Add(Vector3.zero);
    }
Beispiel #6
0
    private void AddLetter(PentaLetter letter)
    {
        Vector3 letterPos = letter.transform.position;

        letterPos.z = _z;
        _lettersPos[_lettersCount++ - 1] = letterPos;
        _lettersPos.Add(letterPos);

        DrawCurve();
    }
Beispiel #7
0
    public void TryActivate(PentaLetter lastSelectedLetter)
    {
        Debug.Log("TryActivate");
        bool wordIsSelectable = _pentagram.TryToUseWord(_currentWord);

        if (wordIsSelectable)
        {
            OnSpellActivated();
        }
        UnselectLetters();

        _SelectedWordChangedCallback("");
    }
Beispiel #8
0
 public bool TryToSelect(PentaLetter previousLetter)
 {
     if (previousLetter != null)
     {
         if (!previousLetter.AddToNeighbours(this))
         {
             return(false);
         }
         AddToNeighbours(previousLetter);
     }
     _animator.SetInteger(AnimatorChosen, ++_timesChosen);
     OnLetterSelected();
     return(true);
 }
Beispiel #9
0
    public bool AddToNeighbours(PentaLetter letter)
    {
        if (letter == this)
        {
            return(false);
        }

        for (int i = 0; i < _nNeighbourLetters; i++)
        {
            if (_neighbourLetters[i] == letter)
            {
                return(false);
            }
        }

        _neighbourLetters[_nNeighbourLetters++] = letter;
        return(true);
    }