Exemple #1
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && isStart)
     {
         if (setColor)
         {
             if (currentItem != null)
             {
                 // blockText = currentItem.letter.text;
                 currentItem.SetColor(currentColor, colors[currentColor]);
             }
             if (currentBlock != null && downItem != null)
             {
                 if (downItem.blockIndex != -1)
                 {
                     currentBlock.SetText(downItem.letter.text);
                     currentBlock.SetColor(downItem.blockIndex, colors[downItem.blockIndex]);
                     downItem = null;
                 }
             }
         }
         else
         {
             if (currentItem != null)
             {
                 currentItem.SetText(letter);
             }
         }
     }
     if (Input.GetMouseButtonDown(1))
     {
         if (setColor)
         {
             if (currentBlock != null)
             {
                 currentBlock.ClearColor();
             }
             if (currentItem != null)
             {
                 currentItem.ClearColor();
             }
         }
         else
         {
             if (currentItem != null)
             {
                 currentItem.SetText("");
             }
         }
     }
 }
Exemple #2
0
    //设置单词格子
    private void SetWordGrid()
    {
        Calculate();
        int index = 0;

        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                if (i == 0 && j == 0)
                {
                    wordCell.ClearColor();
                    wordCell.pos.x = i;
                    wordCell.pos.y = j;
                    wordCell.gameObject.SetActive(true);
                    wordCell.SetSize(min);
                    if (loadData.wordInfo.Count != 0 && loadData.wordColorIndex[i][j] != -1)
                    {
                        wordCell.SetText(loadData.wordInfo[i][j]);
                        wordCell.SetColor(loadData.wordColorIndex[i][j], colors[loadData.wordColorIndex[i][j]]);
                    }
                }
                else
                {
                    PuzzleCell cell = CloneCell(i, j, index);

                    if (loadData.wordInfo.Count != 0 && loadData.wordColorIndex[i][j] != -1)
                    {
                        cell.SetText(loadData.wordInfo[i][j]);
                        cell.SetColor(loadData.wordColorIndex[i][j], colors[loadData.wordColorIndex[i][j]]);
                    }
                }
                index++;
            }
        }
        isStart = true;
    }