Exemplo n.º 1
0
        public void addSpiral()
        {
            try
            {
                for (int i = 0; i < directions.Count; i++)
                {
                    do
                    {
                        currentNum++;
                        coords      += directions[i];
                        base[coords] = currentNum;
                    } while (base[coords + directions[i + 1]] != 0);
                }
                base[coords] = currentNum;
            }

            catch (IndexOutOfRangeException ex)
            {
                Console.WriteLine(ex.Message);
                //Console.WriteLine(ToString());
            }

            currentradius++;

            bottomy++;
            topy--;
            leftx--;
            rightx++;
            //currentNum++;
        }
Exemplo n.º 2
0
        public SpiralGrid(int spiralRadius) : base(spiralRadius * 2 + 1)
        {
            currentNum   = 1;
            center       = new intpair(spiralRadius, spiralRadius);
            coords       = new intpair(center.x, center.y);
            base[coords] = currentNum;
            coords.x++;
            currentNum++;
            base[coords] = currentNum;

            topy  = bottomy = center.y;
            leftx = rightx = center.x;
        }
Exemplo n.º 3
0
        public List <intpair> getDiagonals()
        {
            List <intpair> r = new List <intpair>();

            for (int i = 0; i < Size; i++)
            {
                intpair t = new intpair();
                t.x = base[i, i];
                if (t.y != 1)
                {
                    t.y = base[i, Size - 1 - i];
                }
                r.Add(t);
            }

            return(r);
        }
Exemplo n.º 4
0
 public T this[intpair coords]
 {
     get { return(this[coords.x, coords.y]); }
     set { this[coords.x, coords.y] = value; }
 }