Beispiel #1
0
        public override void Apply(Generator gen, LevelGenerator levelGen, Level level)
        {
            for (var x = 0; x < gen.Size; x += Spacing)
            {
                for (var y = 0; y < gen.Size; y += Spacing)
                {
                    if (gen.Random.Next(0, Chance) == 0 && CanBePlantOn.Contains(level.GetTile(x, y)) && PlacingFunction(x, y, gen, levelGen, level) < Threashold && level.GetEntitiesAt(x, y).Count == 0)
                    {
                        level.AddEntityAt(_blueprint.Construct(), x, y, gen.Random.Next(-RandomOffset, RandomOffset), gen.Random.Next(-RandomOffset, RandomOffset));
                    }
                }

                _progress = (x / (float)gen.Size);
            }
        }
        public override void Apply(Generator gen, LevelGenerator levelGen, Level level)
        {
            Logger.Log <Decorator>(GetName());
            for (var x = 0; x < gen.Size; x += Spacing)
            {
                for (var y = 0; y < gen.Size; y += Spacing)
                {
                    var coordinates = new Coordinates(x, y);
                    if (gen.Random.Next(0, Chance) == 0 &&
                        CanBePlantOn.Contains(level.GetTile(coordinates)) &&
                        PlacingFunction(x, y, gen, levelGen, level) < Threashold &&
                        !level.AnyEntityAt(coordinates))
                    {
                        level.AddEntityAt(_blueprint, coordinates, gen.Random.NextVector2(-RandomOffset, RandomOffset));
                    }
                }

                _progress = x / (float)gen.Size;
            }
        }