protected override void Execute(List <GameEntity> entities)
        {
            GridSize size = _config.Unique.Get <MapSizeComponent>().Component.Value;

            //foreach (var entity in entities)
            //{
            //    if (entity.HasComponent<PositionComponent>())
            //    {
            //        Debug.Log($"AddElementSystem Collected: Position={entity.Get<PositionComponent>().value}");
            //    }
            //}

            // _game.CreateIndex<PositionComponent>((e,c) => c.Value);

            for (int x = 0; x < size.x; x++)
            {
                var position = new GridPosition(x, size.y - 1);

                //if (!_game.TryFindEntity<PositionComponent>(p => p.Value = position, out var candidate))
                //{
                //    //Debug.Log($"AddElementSystem Index Not Found for position {position}, Adding");

                //    _elementService.CreateRandomElement(position);
                //}

                //var entity = _game.GetSearchIndex<PositionComponent>().FindEntity(position);

                //query.Add

                //_game.GetEntityIndex<PositionComponent>().WithValue();

                if (!_game.TryFindEntity <PositionComponent, GridPosition>(position, out var candidate))
                {
                    //Debug.Log($"AddElementSystem Index Not Found for position {position} - Adding");

                    _elementService.CreateRandomElement(position);
                }

                //if (!_game.TryFindEntity2<PositionComponent>(p => p.value = position, out var candidate))
                //if (!_game.TryFindEntity<PositionComponent, GridPosition>(position, out var candidate))
                //{
                //    Debug.Log($"AddElementSystem Index Not Found for position {position}, Adding");

                //    _elementService.CreateRandomElement(position);
                //}
                //else
                //{
                //    Debug.Log($"AddElementSystem Index Found: Position={position}");
                //}
            }
        }
Exemple #2
0
        private void Fill()
        {
            var size = _config.Unique.Get <MapSizeComponent>().Component.Value;

            for (int row = 0; row < size.y; row++)
            {
                for (int column = 0; column < size.x; column++)
                {
                    float random = (float)Random.Value.NextDouble();
                    //float random = Random.Range(0f, 1f);

                    if (random < 0.1f)
                    {
                        if (random < 0.05f)
                        {
                            if (random < 0.005f)
                            {
                                _elementService.CreateExsplosiveBlock(new GridPosition(column, row));
                            }
                            else
                            {
                                _elementService.CreateNotMovableBlock(new GridPosition(column, row));
                            }
                        }
                        else
                        {
                            _elementService.CreateMovableBlock(new GridPosition(column, row));
                        }
                    }
                    else
                    {
                        _elementService.CreateRandomElement(new GridPosition(column, row));
                    }
                }
            }
        }