Ejemplo n.º 1
0
 private void Fill(RectInt rect)
 {
     if (rect.height > 1)
     {
         foreach (var y in rect.FromTopToBottom())
         {
             _objectFactory.Create(new Vector2(rect.x, y));
         }
     }
 }
Ejemplo n.º 2
0
        public override RectInt Fill(RectInt area, float difficulty)
        {
            RectInt areaUsed = new RectInt(Vector2Int.one * int.MaxValue, Vector2Int.zero);

            foreach (var y in area.FromTopToBottom())
            {
                var t = Mathf.InverseLerp(-1, 1, Mathf.Sin((y + _offset) * _amplitude.FromNormal(difficulty)));
                if (Mathf.Abs(t - 0.5f) > _spawnThreshold.FromNormal(difficulty))
                {
                    var position = new Vector2(Mathf.Lerp(area.xMin, area.xMax, 1 - Mathf.Round(t)), y);
                    areaUsed = areaUsed.ExtendToCover(position);
                    _objectFactory.Create(position);
                }
            }

            return(areaUsed);
        }