Ejemplo n.º 1
0
        public static GridEventItem Create(GridNodeState nodeState, int points = 0, GridIndex?refIndex = null)
        {
            var item = new GridEventItem()
            {
                ReferenceIndex = refIndex,
                Index          = nodeState.Index,
                ItemId         = nodeState.ItemId,
                Points         = points
            };

            return(item);
        }
Ejemplo n.º 2
0
        public LevelState(int levelIndex, LevelConfig config)
        {
            LevelIndex = levelIndex;
            Config     = config;
            Grid       = null;

            var includedItems = GameConfig.GetAllGridItemsInCategory(config.category, config.excludeItemIds);

            GridItemDrops = new GridItemDropDistribution(config.category, includedItems);

            if (config.width > 0 && config.height > 0)
            {
                var defaultGridItem = GameConfig.GetDefaultLayoutGridItem(config.category);

                // initialize the grid
                Grid = new GridNodeState[config.width, config.height];
                for (int y = 0; y < config.height; y++)
                {
                    for (int x = 0; x < config.width; x++)
                    {
                        var    layout = config.GetNodeLayout(x, y);
                        string itemId = null;
                        if (!string.IsNullOrEmpty(layout.itemId))
                        {
                            if (layout.itemId != defaultGridItem.ID)
                            {
                                itemId = layout.itemId;
                            }
                            else
                            {
                                itemId = GridItemDrops.Next();
                            }
                        }
                        Grid[x, y] = new GridNodeState(x, y, layout.nodeId, itemId);
                    }
                }
            }
        }