示例#1
0
        public static void ResizeLevel(int width, int height, ref LevelConfig config)
        {
            var resizedLayout = new GridNodeLayout[width * height];

            var defaultGridItem = GameConfig.GetDefaultLayoutGridItem(config.category);
            var openNode        = GameConfig.AllGridNodes.First(node => node.IsOpen);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (config.IsInBounds(x, y))
                    {
                        resizedLayout[GetLinearIndex(x, y, width)] = config.GetNodeLayout(x, y);
                    }
                    else
                    {
                        resizedLayout[GetLinearIndex(x, y, width)] = new GridNodeLayout()
                        {
                            nodeId = openNode.ID, itemId = defaultGridItem.ID
                        }
                    };
                }
            }

            config.width  = width;
            config.height = height;
            config.layout = resizedLayout;
        }
示例#2
0
        public void SetNodeLayout(int x, int y, GridNodeLayout nodeLayout)
        {
            Assert.IsTrue(IsInBounds(x, y), $"Tried to set out-of-bounds node type: ({x},{y})={nodeLayout.nodeId}:{nodeLayout.itemId}");

            layout[GetLinearIndex(x, y)] = nodeLayout;
        }
示例#3
0
 public void SetNodeLayout(GridIndex index, GridNodeLayout nodeLayout)
 {
     SetNodeLayout(index.x, index.y, nodeLayout);
 }