public FormationPosition GetPositionForUnit(GameConstants.UnitType unitType, HashSet <GameConstants.Role> roleList) { try { foreach (var fp in FormationPositions) { if (!fp.IsAssigned) { if (fp.UnitType != null && fp.UnitType == unitType) { return(fp); } if (fp.Role != null && roleList.Contains((GameConstants.Role)fp.Role)) { return(fp); } if (fp.Role == null && fp.UnitType == null) { return(fp); } } } return(null); //not found } catch (Exception ex) { Logger log = new Logger(); log.LogError( "GetPositionForUnit failed for UnitType=" + unitType + ". " + ex.ToString()); return(null); } }
/// <summary> /// If no position is available for unit, create a new position somewhat sensibly /// </summary> /// <param name="unitInfo"></param> /// <returns></returns> public FormationPosition CreateNewPositionForUnit(GameConstants.UnitType unitType) { FormationPosition fpos = new FormationPosition(); double distanceM = 500; if (unitType == GameConstants.UnitType.FixedwingAircraft || unitType == GameConstants.UnitType.Helicopter) { distanceM = 150; } //TODO: Make this more sensible distanceM = distanceM * this.FormationPositions.Count; fpos.PositionOffset = new PositionOffset(distanceM / 3, (-1 * distanceM) / 2, 0); return(fpos); }
public static int GetDefaultHitpoints(GameConstants.UnitType unitType) { switch (unitType) { case GameConstants.UnitType.SurfaceShip: return(1000); case GameConstants.UnitType.FixedwingAircraft: return(50); case GameConstants.UnitType.Helicopter: return(50); case GameConstants.UnitType.Submarine: return(200); case GameConstants.UnitType.Missile: return(10); case GameConstants.UnitType.Torpedo: return(50); case GameConstants.UnitType.Mine: return(10); case GameConstants.UnitType.Decoy: return(10); case GameConstants.UnitType.Sonobuoy: return(10); case GameConstants.UnitType.BallisticProjectile: return(10); case GameConstants.UnitType.Bomb: return(10); case GameConstants.UnitType.LandInstallation: return(10000); default: return(1000); } }
public UnitClass(string unitClassCode, GameConstants.UnitType unitType) : this() { Id = unitClassCode; UnitType = unitType; }