Beispiel #1
0
 public void Unmount()
 {
     if (this.embark != UnitEmbarkTypes.EMBARK_GROUND) return;
     /* set prop pointer */
     this.sel_prop = this.prop;
     this.embark = UnitEmbarkTypes.EMBARK_NONE;
     /* adjust pic offset */
     this.AdjustIcon();
     /* no entrenchment when mounting */
     this.entr = 0;
 }
Beispiel #2
0
 /*
 ====================================================================
 Check if unit may air/sea embark/debark at x,y.
 If 'init' != 0, used relaxed rules for deployment
 ====================================================================
 */
 public bool map_check_unit_embark(Unit unit, int x, int y, UnitEmbarkTypes type, bool init)
 {
     int i, nx, ny;
     if (x < 0 || y < 0 || x >= map_w || y >= map_h)
         return false;
     if (type == UnitEmbarkTypes.EMBARK_AIR) {
         if ((unit.sel_prop.flags & UnitFlags.FLYING) == UnitFlags.FLYING)
             return false;
         if ((unit.sel_prop.flags & UnitFlags.SWIMMING) == UnitFlags.SWIMMING)
             return false;
         if (Engine.cur_player.air_trsp == null)
             return false;
         if (unit.embark != UnitEmbarkTypes.EMBARK_NONE)
             return false;
         if (!init && map [x, y].a_unit == null)
             return false;
         if (unit.player.air_trsp_used >= unit.player.air_trsp_count)
             return false;
         if (!init && !unit.unused)
             return false;
         if (!init && ((map [x, y].terrain.flags [Scenario.cur_weather] & Terrain_flags.SUPPLY_AIR) != Terrain_flags.SUPPLY_AIR))
             return false;
         if (init && ((unit.sel_prop.flags & UnitFlags.PARACHUTE) != UnitFlags.PARACHUTE) && ((map [x, y].terrain.flags [Scenario.cur_weather] & Terrain_flags.SUPPLY_AIR) != Terrain_flags.SUPPLY_AIR))
             return false;
         if (((unit.sel_prop.flags & UnitFlags.AIR_TRSP_OK) != UnitFlags.AIR_TRSP_OK))
             return false;
         if (init && (unit.trsp_prop.flags & UnitFlags.TRANSPORTER) == UnitFlags.TRANSPORTER)
             return false;
         return true;
     }
     if (type == UnitEmbarkTypes.EMBARK_SEA) {
         if ((unit.sel_prop.flags & UnitFlags.FLYING) == UnitFlags.FLYING)
             return false;
         if ((unit.sel_prop.flags & UnitFlags.SWIMMING) == UnitFlags.SWIMMING)
             return false;
         if (Engine.cur_player.sea_trsp == null)
             return false;
         if (unit.embark != UnitEmbarkTypes.EMBARK_NONE || (!init && unit.sel_prop.mov == 0))
             return false;
         if (!init && map [x, y].g_unit != null)
             return false;
         if (unit.player.sea_trsp_used >= unit.player.sea_trsp_count)
             return false;
         if (!init && !unit.unused)
             return false;
         if (Terrain.GetMovementCost (map [x, y].terrain, unit.player.sea_trsp.mov_type, Scenario.cur_weather) == 0)
             return false;
         /* basically we must be close to an harbor but a town that is just
            near the water is also okay because else it would be too
            restrictive. */
         if (!init) {
             if ((map [x, y].terrain.flags [Scenario.cur_weather] & Terrain_flags.SUPPLY_GROUND) == Terrain_flags.SUPPLY_GROUND)
                 return true;
             for (i = 0; i < 6; i++)
                 if (Misc.get_close_hex_pos (x, y, i, out nx, out ny))
                 if ((map [nx, ny].terrain.flags [Scenario.cur_weather] & Terrain_flags.SUPPLY_GROUND) == Terrain_flags.SUPPLY_GROUND)
                     return true;
         }
         return init;
     }
     return false;
 }
Beispiel #3
0
 /*
 ====================================================================
 Mount/unmount unit to ground transporter.
 ====================================================================
 */
 public void Mount()
 {
     if (this.trsp_prop == null || string.IsNullOrEmpty(this.trsp_prop.id) || this.embark != UnitEmbarkTypes.EMBARK_NONE) return;
     /* set prop pointer */
     this.sel_prop = this.trsp_prop;
     this.embark = UnitEmbarkTypes.EMBARK_GROUND;
     /* adjust pic offset */
     this.AdjustIcon();
     /* no entrenchment when mounting */
     this.entr = 0;
 }
Beispiel #4
0
 public bool map_check_unit_debark(Unit unit, int x, int y, UnitEmbarkTypes type, bool init)
 {
     if (x < 0 || y < 0 || x >= map_w || y >= map_h)
         return false;
     if (type == UnitEmbarkTypes.EMBARK_SEA) {
         if (unit.embark != UnitEmbarkTypes.EMBARK_SEA)
             return false;
         if (!init && map [x, y].g_unit != null)
             return false;
         if (!init && !unit.unused)
             return false;
         if (!init && Terrain.GetMovementCost (map [x, y].terrain, unit.prop.mov_type, Scenario.cur_weather) == 0)
             return false;
         return true;
     }
     if (type == UnitEmbarkTypes.EMBARK_AIR) {
         if (unit.embark != UnitEmbarkTypes.EMBARK_AIR)
             return false;
         if (!init && map [x, y].g_unit != null)
             return false;
         if (!init && !unit.unused)
             return false;
         if (!init && Terrain.GetMovementCost (map [x, y].terrain, unit.prop.mov_type, Scenario.cur_weather) == 0)
             return false;
         if (!init && ((map [x, y].terrain.flags [Scenario.cur_weather] & Terrain_flags.SUPPLY_AIR) != Terrain_flags.SUPPLY_AIR)
             && ((unit.prop.flags & UnitFlags.PARACHUTE) != UnitFlags.PARACHUTE))
             return false;
         return true;
     }
     return false;
 }