Exemple #1
0
    /*
     * IEnumerator Section2Rotation(IEnumerable<IEnumerator> loop, int min=1, int max=1) {
     *  var rotating = new HashSet<GraphicEntity1>();
     *  foreach (var rest in loop) {
     *      var cnt = Random.Range(min, max+1);
     *      for (int i = 0; i < cnt; i++) {
     *          var g = board.FindGraphicAtPosition(Random.Range(0, cols), Random.Range(0, rows));
     *          if (!rotating.Contains(g)) {
     *              g.RotateTo(360, Beat(2));
     *              rotating.Add(g);
     *          }
     *      }
     *      rotating.Clear();
     *      yield return rest;
     *  }
     * }
     */

    IEnumerator Section2Rotation(IEnumerable <IEnumerator> loop, int min = 1, int max = 1, bool rotateLines = false)
    {
        var rotating = new HashSet <GraphicEntity1>();

        foreach (var rest in loop)
        {
            if (rotateLines && Random.value < 0.3f)
            {
                if (Random.value < 0.5f)
                {
                    foreach (var g in board.FindGraphicsForRow(Random.Range(0, rows)))
                    {
                        g.RotateTo(360, Beat(1.9f));
                    }
                }
                else
                {
                    foreach (var g in board.FindGraphicsForColumn(Random.Range(0, cols)))
                    {
                        g.RotateTo(360, Beat(1.9f));
                    }
                }
            }
            else
            {
                var cnt = Random.Range(min, max + 1);
                for (int i = 0; i < cnt; i++)
                {
                    var g = board.FindGraphicAtPosition(Random.Range(0, cols), Random.Range(0, rows));
                    if (g != null && !rotating.Contains(g))
                    {
                        g.RotateTo(360, Beat(1.9f));
                        rotating.Add(g);
                    }
                }
                rotating.Clear();
            }
            yield return(rest);
        }
    }