Exemplo n.º 1
0
        private void BuildChannel(string bsp, long[,] ps)
        {
            this.channel.AddRegion(bsp);
            int upperBound  = ps.GetUpperBound(0);
            int upperBound2 = ps.GetUpperBound(1);

            for (int i = ps.GetLowerBound(0); i <= upperBound; i++)
            {
                for (int j = ps.GetLowerBound(1); j <= upperBound2; j++)
                {
                    long id = ps[i, j];
                    this.channel.AddPartition(bsp, id);
                }
            }
            for (int k = 0; k < ps.GetLength(0) - 1; k++)
            {
                for (int l = 0; l < ps.GetLength(1) - 1; l++)
                {
                    this.channel.AddLink(bsp, ps[k, l], ps[k + 1, l]);
                    this.channel.AddLink(bsp, ps[k, l], ps[k, l + 1]);
                    this.channel.AddLink(bsp, ps[k, l], ps[k + 1, l + 1]);
                    this.channel.AddLink(bsp, ps[k + 1, l], ps[k, l + 1]);
                }
            }
            for (int m = 0; m < ps.GetLength(0) - 1; m++)
            {
                this.channel.AddLink(bsp, ps[m, ps.GetLength(1) - 1], ps[m + 1, ps.GetLength(1) - 1]);
            }
            for (int n = 0; n < ps.GetLength(1) - 1; n++)
            {
                this.channel.AddLink(bsp, ps[ps.GetLength(0) - 1, n], ps[ps.GetLength(0) - 1, n + 1]);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Is this coordinate out of bounds of the map
 /// </summary>
 /// <param name="boundings">a 2d coordinate x,y,z</param>
 /// <param name="map">the 2d map in question</param>
 /// <returns>whether it is out of bounds of the map</returns>
 public static bool IsOutOfBounds(Tuple <int, int> boundings, long[,] map)
 {
     return(map.GetUpperBound(0) < boundings.Item1 || map.GetLowerBound(0) > boundings.Item1 ||
            map.GetUpperBound(1) < boundings.Item2 || map.GetLowerBound(1) > boundings.Item2);
 }