Пример #1
0
 public Block(int[] x, int[] y)
 {
     pos  = new COORC[x.Length + 64];
     used = 0;
     for (int i = 0; i < x.Length; i++)
     {
         if (x[i] >= 0 && y[i] >= 0)
         {
             pos[used]   = new COORC();
             pos[used].x = x[i];
             pos[used].y = y[i];
             used++;
         }
     }
 }
Пример #2
0
        public void Set(int x, int y, bool direct_write = false)
        {
            if (used + 5 > pos.Length)
            {
                Array.Resize(ref pos, (int)(pos.Length * 1.6));
            }

            int free = -1;

            if (!direct_write)
            {
                for (int i = 0; i < pos.Length; i++)
                {
                    if (pos[i] == null)
                    {
                        if (free < 0)
                        {
                            free = i;
                        }
                        continue;
                    }
                    if (pos[i].x == x && pos[i].y == y)
                    {
                        return;
                    }
                }
            }
            else
            {
                free = used;
            }

            if (free < 0)
            {
                throw new Exception("The variable 'used' does not work correctly");
            }

            pos[free]   = new COORC();
            pos[free].x = x;
            pos[free].y = y;
            used++;
        }