public bool TryHireCharacter(HireManager hireManager, CharacterInfo characterInfo) { if (Money < characterInfo.Salary) { return(false); } hireManager.availableCharacters.Remove(characterInfo); CrewManager.AddCharacterInfo(characterInfo); Money -= characterInfo.Salary; return(true); }
public Location(Vector2 mapPosition) { this.type = LocationType.Random(); this.name = RandomName(type); this.mapPosition = mapPosition; if (type.HasHireableCharacters) { hireManager = new HireManager(); hireManager.GenerateCharacters(this, HireManager.MaxAvailableCharacters); } Connections = new List <LocationConnection>(); }
public IEnumerable <CharacterInfo> GetHireableCharacters() { if (!Type.HasHireableCharacters) { return(Enumerable.Empty <CharacterInfo>()); } if (hireManager == null) { hireManager = new HireManager(); } if (!hireManager.AvailableCharacters.Any()) { hireManager.GenerateCharacters(location: this, amount: HireManager.MaxAvailableCharacters); } return(hireManager.AvailableCharacters); }
public void SetHireables(Location location, List <CharacterInfo> availableHires) { HireManager hireManager = location.HireManager; if (hireManager == null) { return; } int hireVal = hireManager.AvailableCharacters.Aggregate(0, (curr, hire) => curr + hire.GetIdentifier()); int newVal = availableHires.Aggregate(0, (curr, hire) => curr + hire.GetIdentifier()); if (hireVal != newVal) { location.HireManager.AvailableCharacters = availableHires; UpdateHireables(location); } }