示例#1
0
    public virtual void InitCells()
    {
        cells = new List <List <GameCell> >();

        for (int x = 0; x < size.x; x++)
        {
            List <GameCell> column = new List <GameCell>();
            for (int y = 0; y < size.y; y++)
            {
                GameCell newCell = Instantiate <GameCell>(cellPrefab, this.transform);
                newCell.Init();
                newCell.transform.localPosition = new Vector2(x, y);
                newCell.SetColor((x + y) % 2 == 0 ? color1 : color2);
                newCell.name = "Cell (" + x + ", " + y + ")";
                column.Add(newCell);
            }
            cells.Add(column);
        }
    }