示例#1
0
        /// <summary>
        /// Changes the <see cref="CitizenTypePivot"/> of the specified <see cref="CitizenPivot"/>;
        /// using a static sequence of type [Regular -> Entertainer -> Scientist -> TaxCollector -> Regular].
        /// </summary>
        /// <param name="citizenSource">The citizen.</param>
        internal void SwitchCitizenType(CitizenPivot citizenSource)
        {
            if (!citizenSource.Type.HasValue)
            {
                ChangeCitizenToSpecialist(citizenSource, CitizenTypePivot.Entertainer);
                CheckCitizensHappiness();
            }
            else
            {
                switch (citizenSource.Type.Value)
                {
                case CitizenTypePivot.Entertainer:
                    ChangeCitizenToSpecialist(citizenSource, CitizenTypePivot.Scientist);
                    CheckCitizensHappiness();
                    break;

                case CitizenTypePivot.Scientist:
                    ChangeCitizenToSpecialist(citizenSource, CitizenTypePivot.TaxCollector);
                    CheckCitizensHappiness();
                    break;

                case CitizenTypePivot.TaxCollector:
                    ChangeCitizenToRegularAtTheBestVacantMapSquare(citizenSource);
                    break;
                }
            }
        }
示例#2
0
        private bool ChangeCitizenToRegularAtTheBestVacantMapSquare(CitizenPivot citizenSource)
        {
            var mapSquare = BestVacantMapSquareLocation();

            if (mapSquare != null)
            {
                AddRegularCitizen(citizenSource, mapSquare);
                return(true);
            }
            return(false);
        }
示例#3
0
        private void ChangeCitizenToSpecialist(CitizenPivot citizenSource, CitizenTypePivot citizenType)
        {
            bool wasSpecialistAlready = _specialistCitizens.Contains(citizenSource);

            citizenSource.ToSpecialist(citizenType);
            if (!wasSpecialistAlready)
            {
                _areaMapSquares.Remove(_areaMapSquares.SingleOrDefault(ams => ams.Citizen == citizenSource));
                _specialistCitizens.Add(citizenSource);
            }
        }
示例#4
0
        private void AddRegularCitizen(CitizenPivot citizenSource, MapSquarePivot location, bool delayHappinessCheck = false)
        {
            var alreadyInArea = _areaMapSquares.SingleOrDefault(ams => ams.Citizen == citizenSource);

            if (alreadyInArea != null)
            {
                _areaMapSquares.Remove(alreadyInArea);
            }
            else
            {
                _specialistCitizens.Remove(citizenSource);
            }
            citizenSource.ToRegular();
            _areaMapSquares.Add(new CityAreaMapSquarePivot(this, location));

            if (!delayHappinessCheck)
            {
                CheckCitizensHappiness();
            }
        }
示例#5
0
 /// <summary>
 /// Constructor (for existing citizen).
 /// </summary>
 /// <param name="mapSquare">The <see cref="MapSquare"/> value.</param>
 /// <param name="citizen">The <see cref="Citizen"/> value.</param>
 internal CityAreaMapSquarePivot(MapSquarePivot mapSquare, CitizenPivot citizen)
 {
     City      = citizen.City;
     MapSquare = mapSquare;
     Citizen   = citizen;
 }