Пример #1
0
 public void map_get_merge_units(Unit unit, out Unit[] partners, out int count)
 {
     Unit partner;
     int i, next_x, next_y;
     count = 0;
     map_clear_mask (MAP_MASK.F_MERGE_UNIT);
     partners = new Unit[MAP_MERGE_UNIT_LIMIT];
     /* check surrounding tiles */
     for (i = 0; i < 6; i++)
         if (Misc.get_close_hex_pos (unit.x, unit.y, i, out next_x, out next_y)) {
             partner = null;
             if (map [next_x, next_y].g_unit != null && unit.CheckMerge (map [next_x, next_y].g_unit))
                 partner = map [next_x, next_y].g_unit;
             else if (map [next_x, next_y].a_unit != null && unit.CheckMerge (map [next_x, next_y].a_unit))
                 partner = map [next_x, next_y].a_unit;
             if (partner != null) {
                 partners [(count)++] = partner;
                 mask [next_x, next_y].merge_unit = partner;
             }
         }
 }
Пример #2
0
 /// <summary>
 /// Check if unit may transfer strength to unit (if not NULL) or create
 /// a stand alone unit (if unit NULL) on the coordinates.
 /// </summary>
 /// <param name="unit"></param>
 /// <param name="str"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="dest"></param>
 /// <returns></returns>
 public bool map_check_unit_split(Unit unit, int str, int x, int y, Unit dest)
 {
     if (unit.str - str < 4)
         return false;
     if (dest != null) {
         int old_str;
         bool ret;
         old_str = unit.str;
         unit.str = str;
         ret = unit.CheckMerge (dest); /* is equal for now */
         unit.str = old_str;
         return ret;
     } else {
         if (str < 4)
             return false;
         if (!Misc.is_close (unit.x, unit.y, x, y))
             return false;
         if (((unit.sel_prop.flags & UnitFlags.FLYING) == UnitFlags.FLYING) && map [x, y].a_unit != null)
             return false;
         if (((unit.sel_prop.flags & UnitFlags.FLYING) != UnitFlags.FLYING) && map [x, y].g_unit != null)
             return false;
         if (Terrain.GetMovementCost (map [x, y].terrain, unit.sel_prop.mov_type, Scenario.cur_weather) == 0)
             return false;
     }
     return true;
 }