Exemple #1
0
 private void SetPack(Field f, int i)
 {
     int ti = i * 4;
     field[ti] = f;
     LeftRight(field[ti], out left[ti], out right[ti]);
     for (int j = ti + 1; j < ti + 4; j++)
     {
         field[j] = field[j - 1].RotationClone();
         LeftRight(field[j], out left[j], out right[j]);
     }
 }
Exemple #2
0
 public Field RotationClone()
 {
     Field ret = new Field(Height, Width, obs);
     int h = Height - 1;
     for (int x = 0; x < Width; x++)
     {
         for (int y = 0; y < Height; y++)
         {
             ret[h - y, x] = this[x, y];
         }
     }
     return ret;
 }
Exemple #3
0
 public static Field ReadPack(TextReader reader, int t, int s)
 {
     Field f = new Field(t, t, s + 1);
     for (int y = 0; y < f.Height; y++)
     {
         string[] strs = reader.ReadLine().Split(' ');
         for (int x = 0; x < f.Width; x++)
         {
             f[x, y] = byte.Parse(strs[x]);
         }
     }
     if (reader.ReadLine() != "END") throw new ApplicationException();
     return f;
 }
Exemple #4
0
 private void LeftRight(Field f, out int l, out int r)
 {
     l = f.Width; r = 0;
     int w = f.Width, h = f.Height;
     for (int x = 0; x < w; x++)
     {
         for (int y = 0; y < h; y++)
         {
             int temp = f[x, y];
             if (temp <= 0) continue;
             if (l > x)
             {
                 l = x;
             }
             if (r < x)
             {
                 r = x;
             }
         }
     }
 }
Exemple #5
0
 public Rect FixPack(Field pack, int cx)
 {
     Rect rect = CreateReverseRect();
     int w = pack.Width, h = pack.Height;
     for (int x = 0; x < w; x++)
     {
         int tx = x + cx;
         if (tx < 0 || tx >= Width) continue;
         int bottom = earthPoint[tx];
         for (int y = h - 1; y >= 0; y--)
         {
             byte num = pack[x, y];
             if (num <= 0) continue;
             this[tx, earthPoint[tx]--] = num;
         }
         int nowfp = earthPoint[tx] + 1;
         if (bottom < nowfp) continue;
         rect.MaxRect(tx, nowfp, tx, bottom);
         floatPoint[tx] = nowfp;
     }
     return rect;
 }