private void UpdateScience() { if (CurrentResearch != null && _science > CurrentResearch.Cost) { GameFacade.getInstance().SendNotification( GameNotification.Message, NotificationType.Science, string.Format(Strings.TXT_KEY_NOTIFICATION_SCIENCE_DISCOVERED, Leader.Title, CurrentResearch.Title), Civilization, MessageFilter.Friends | MessageFilter.Self, CurrentResearch); DiscoverTechnology(CurrentResearch); Technologies.Add(CurrentResearch); CurrentResearch = null; _science = 0; } if (CurrentResearch == null) { List<Tech> possibleTechnologies = PossibleTechnologies; // calculate flavours of city List<Flavour> flavours = Flavours; Tech best = null; float min = float.MaxValue; // calculate flavour difference for each unit/building foreach (Tech tech in possibleTechnologies) { float dist = Flavours.Distance(tech.Flavours, flavours); if (min > dist) { min = dist; best = tech; } } if (best == null) throw new Exception("This can't be!"); CurrentResearch = best; } }
public void DiscoverTechnology(Tech tech) { if (tech.Era > _era) { _era = tech.Era; _eras.Add(tech.Era); GameFacade.getInstance().SendNotification(GameNotification.StartEra, this, _era); bool needToUpdateResources = false; // reveal resources for all players foreach (MapCell cell in Map.Tiles) { if (!cell.RessourceRevealed && cell.Ressource != null && cell.Ressource.RequiredTechName == tech.Name) { cell.RessourceRevealed = true; needToUpdateResources = true; } } if (needToUpdateResources) GameFacade.getInstance().SendNotification(GameNotification.UpdateResources, this); // evtl. enable policies } }