Beispiel #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("");
             }
         }
     }
 }
Beispiel #2
0
    private BlockLetter CloneBlock(int i, int j, float offset)
    {
        BlockLetter cell = Instantiate(block, blockGroup);

        cell.name = "block" + i.ToString() + j.ToString();
        cell.GetComponent <RectTransform> ().anchoredPosition = new Vector2(blockOri.x + (min + offset) * j, blockOri.y - (min + offset) * i);
        cell.pos.x = i;
        cell.pos.y = j;
        cell.ClearColor();
        cell.SetSize(min);
        if ((i < row && j >= col) || i >= row)
        {
            Vector2 pos = cell.GetComponent <RectTransform> ().anchoredPosition;
            if (pos.x + min < 720 && pos.y - min > -720)
            {
                cell.gameObject.SetActive(true);
            }
        }
        return(cell);
    }