Example #1
0
        private void createDots(string groupObjectName, int width, int height, int borderDots)
        {
            displayDots       = new DisplayDot[height, width];
            displayBorderDots = (borderDots > 0?new List <DisplayDot>():null);

            GameObject groupObject = createGroupObject(groupObjectName, this.transform);

            GameObject borderObject = null;

            if (borderDots > 0)
            {
                borderObject = createGroupObject("Border", groupObject.transform);
            }

            for (int y = -borderDots; y < height + borderDots; y++)
            {
                GameObject rowObject = null;
                if (y >= 0 && y < height)
                {
                    rowObject = createGroupObject("Row " + y, groupObject.transform);
                }

                for (int x = -borderDots; x < width + borderDots; x++)
                {
                    GameObject dotObject = (GameObject)(Instantiate(dotPrefab));
                    if (y >= 0 && y < height && x >= 0 && x < width)
                    {
                        dotObject.name = "Col " + x;
                        setParent(dotObject, rowObject.transform);
                    }
                    else
                    {
                        dotObject.name = "Border dot";
                        setParent(dotObject, borderObject.transform);
                    }

                    DisplayDot displayDot = createDisplayDot(dotObject, x, y);
                    setDisplayDotScaleAndPosition(displayDot);
                    displayDot.setNewStateInstantly(0);

                    if (y >= 0 && y < height && x >= 0 && x < width)
                    {
                        displayDots[y, x] = displayDot;
                    }
                    else
                    {
                        displayBorderDots.Add(displayDot);
                    }
                }
            }
        }