Пример #1
0
        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);
        }
Пример #2
0
        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>();
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
            }
        }