예제 #1
0
 /// <summary>
 /// Establish a relation with a neighboring map cell
 /// </summary>
 /// <param name="neighbor">Neighboring map cell</param>
 /// <param name="deltaX">X coordinate offset to the neighbor</param>
 /// <param name="deltaY">Y coordinate offset to the neighbor</param>
 public void SetNeighbor(MapCell neighbor, int deltaX, int deltaY)
 {
     if (neighbor != null)
     {
         int borderIndex = HexBorder.ConvertDeltaToBorderIndex(deltaX, deltaY, _data.x % 2 == 1);
         if (neighbor.GetProvinceId() == GetProvinceId())
         {
             // if the neighboring map cell belongs to the same province,
             // there should be no border between them, so
             // set the corresponding bit to zero
             int index = 1 << borderIndex;
             _provinceBordersIndex = _provinceBordersIndex ^ index;
         }
         else
         {
             _province.AddNeighbor(neighbor.GetProvince());
             neighbor.GetProvince().AddNeighbor(_province);
         }
     }
 }