Beispiel #1
0
    public void CheckAnswer(string checkWord)
    {
        LineWord line = lines.Find(x => x.answer == checkWord);

        if (line != null)
        {
            if (!line.isShown)
            {
                textPreview.SetAnswerColor();
                line.ShowAnswer();
                CheckGameComplete();

                if (lines.Last() == line)
                {
                    compliment.ShowRandom();
                }

                Sound.instance.Play(Sound.Others.Match);
            }
            else
            {
                textPreview.SetExistColor();
            }
        }
        else if (validWords.Contains(checkWord.ToLower()))
        {
            ExtraWord.instance.ProcessWorld(checkWord);
        }
        else
        {
            textPreview.SetWrongColor();
        }

        textPreview.FadeOut();
    }
Beispiel #2
0
    public void CheckAnswer(string checkWord)
    {
        LineWord line = lines.Find(x => x.answer == checkWord);

        if (line != null)
        {
            if (!line.isShown)
            {
                SetCombo(1);
                textPreview.SetAnswerColor();
                line.ShowAnswer();
                CheckGameComplete();
                Compliment.Instance.ShowRandom(MainController.instance.comboCount);
                //if (lines.Last () == line) {
                //    compliment.ShowRandom ();
                //}
                if (checkWord.ToLower() == "word")
                {
                    PlayerDataManager.Instance.playerData.wordCount++;
                    PlayerDataManager.Instance.JudeReachAchieve(15, PlayerDataManager.Instance.playerData.wordCount);
                }
                if (checkWord.ToLower() == "connect")
                {
                    PlayerDataManager.Instance.playerData.connectCount++;
                    PlayerDataManager.Instance.JudeReachAchieve(16, PlayerDataManager.Instance.playerData.connectCount);
                }
                PlayerDataManager.Instance.playerData.accumulativeLinkWord++;
                PlayerDataManager.Instance.JudeReachAchieve(5, PlayerDataManager.Instance.playerData.accumulativeLinkWord);
                Sound.instance.Play(Sound.Others.Match);
            }
            else
            {
                textPreview.SetExistColor();
            }
        }
        else if (validWords.Contains(checkWord.ToLower()))
        {
            ExtraWord.instance.ProcessWorld(checkWord);
        }
        else
        {
            if (textPreview.text.text.Length != 1)
            {
                SetCombo(0);
            }
            textPreview.SetWrongColor();
        }

        textPreview.FadeOut();
    }
Beispiel #3
0
    public void Load(GameLevel gameLevel)
    {
        this.gameLevel = gameLevel;

        var wordList = CUtils.BuildListFromString <string> (this.gameLevel.answers);

        validWords = CUtils.BuildListFromString <string> (this.gameLevel.validWords);
        numWords   = wordList.Count;

        numCol = numWords <= 4 ? 1 :
                 numWords <= 10 ? 2 : 3;

        numRow = (int)Mathf.Ceil(numWords / (float)numCol);

        int maxCellInWidth = 0;

        for (int i = numRow; i <= numWords; i += numRow)
        {
            maxCellInWidth += wordList[i - 1].Length;
        }

        if (numWords % numCol != 0)
        {
            maxCellInWidth += wordList[numWords - 1].Length;
        }

        if (numCol > 1)
        {
            float coef = (maxCellInWidth + (maxCellInWidth - numCol) * Const.CELL_GAP_COEF + (numCol - 1) * Const.COL_GAP_COEF);
            cellSize = rt.rect.width / coef;
            float maxSize = rt.rect.height / (numRow + (numRow + 1) * Const.CELL_GAP_COEF);
            if (maxSize < cellSize)
            {
                cellSize       = maxSize;
                startFirstColX = (rt.rect.width - cellSize * coef) / 2f;
            }
        }
        else
        {
            cellSize = rt.rect.height / (numRow + (numRow - 1) * Const.CELL_GAP_COEF + 0.8f);
            float maxSize = rt.rect.width / (maxCellInWidth + (maxCellInWidth - 1) * Const.CELL_GAP_COEF);

            if (maxSize < cellSize)
            {
                hasLongLine = true;
                cellSize    = maxSize;
            }
        }

        string[] levelProgress = GetLevelProgress();

        int lineIndex = 0;

        //int levelProgressIndex = 0;
        foreach (var word in wordList)
        {
            LineWord line = Instantiate(MonoUtils.instance.lineWord);
            line.answer   = word.ToUpper();
            line.cellSize = cellSize;
            line.SetLineWidth();
            line.Build();

            if (levelProgress.Length > 0)
            {
                line.SetProgress(levelProgress[lineIndex]);
                //levelProgressIndex++;
            }

            line.transform.SetParent(transform);
            line.transform.localScale    = Vector3.one;
            line.transform.localPosition = Vector3.zero;

            lines.Add(line);
            lineIndex++;
        }

        CheckGameComplete();
        SetLinesPosition();
    }