Beispiel #1
0
 public void RenderLine(ToskaLine c, Color color)
 {
     for (int x = c.start.x; x <= c.end.x; x++)
     {
         for (int y = c.start.y; y <= c.end.y; y++)
         {
             var g = board.FindGraphicAtPosition(x, y);
             if (g != null)
             {
                 g.SetColor(color, 2);
             }
         }
     }
 }
Beispiel #2
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);
        }
    }