Пример #1
0
    //克隆方格
    private PuzzleCell CloneCell(int i, int j, int index)
    {
        PuzzleCell cell = Instantiate(wordCell, wordGroup);

        cell.name = "word" + i.ToString() + j.ToString();
        cell.GetComponent <RectTransform> ().anchoredPosition = new Vector2(cellOri.x + (min + 2) * j, cellOri.y - (min + 2) * i);
        cell.pos.x = i;
        cell.pos.y = j;
        cell.SetText("");
        cell.ClearColor();
        cell.SetSize(min);
        cell.transform.SetSiblingIndex(index);
        cell.gameObject.SetActive(true);

        return(cell);
    }
Пример #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;
    }