private void CheckWinCondition(GlobalResourceManager globalResourceManager) { if (globalResourceManager.EnvironmentResource.WinStep >= GameSettings.GameplaySettings.PalastWinSteps) { OnVictory(); } }
public UnlockManager(GlobalResourceManager globalResourceManager, BuildingDescriptionDatabase buildingDescriptionDatabase) { GlobalResourceManager = globalResourceManager; foreach (var buildingDescription in buildingDescriptionDatabase.BuildingDescriptions) { UnlockedStructures.Add(buildingDescription, buildingDescription.UnlockCost == Knowledge.Zero); } }
public void Unlock(BuildingDescription structureDescription) { if (!GlobalResourceManager.EnoughKnowledgeFor(structureDescription.UnlockCost)) { throw new InvalidOperationException("Not enough knowledge aquired"); } GlobalResourceManager.Knowledge -= structureDescription.UnlockCost; UnlockedStructures[structureDescription] = true; NewStructureUnlocked?.Invoke(this, structureDescription); }
public World(GameSettings gameSettings) { GameSettings = gameSettings; StructureManager = new StructureManager(); GlobalResourceManager = new GlobalResourceManager(GameSettings.GameplaySettings); HexagonManager = new HexagonManager(GameSettings.GameplaySettings); ButtonManager = new ButtonManager(GameSettings.LayoutSettings); UnlockManager = new UnlockManager(GlobalResourceManager, gameSettings.BuildingDescriptionDatabase); PathFinder = new CachedPathFinder(HexagonManager, StructureManager, GameSettings.GameplaySettings); ResourceManager = new ResourceManager(this); StructureManager.StructureAdded += StructureAdded; StructureManager.StructureRemoved += StructureRemoved; GlobalResourceManager.OutOfOxygen += grm => OnDefeat(); GlobalResourceManager.ValueChanged += CheckWinCondition; }