コード例 #1
0
ファイル: GridGenerator.cs プロジェクト: namudz/rpg_2d_test
    public IGrid GenerateGrid()
    {
        var rows    = _gridConfig.GetRows();
        var columns = _gridConfig.GetColumns();

        var cellsById          = new Dictionary <int, Cell>(rows * columns);
        var cellsByCoordinates = new Cell[rows, columns];
        var cellId             = 0;

        for (var i = 0; i < rows; ++i)
        {
            for (var j = 0; j < columns; ++j)
            {
                var cell = GetNewCell(rows, columns, cellId, j, i);
                cellsById.Add(cellId, cell);
                ++cellId;
                cellsByCoordinates[i, j] = cell;
            }
        }

        var data = new GridGenerationData(rows, columns, cellsById, cellsByCoordinates, _counterCharacters, _counterEnemies);

        return(new Grid(data));
    }