public void AddBridgeBuilt() { _bridgesBuilt++; int index = 0; if (_myManager is AICityManager) { index = 1; } Debug.Log(index); GameInitializer.SetBridgeActive(index); if (_bridgesBuilt <= Glob.AmountOfBridgesNeededToWin && _myManager is PlayerCityManager) { GameInitializer.AddSocializerScore(30); } if (_bridgesBuilt >= Glob.AmountOfBridgesNeededToWin) { if (GameInitializer.GetNextCity(this).GetBridgesBuilt() >= Glob.AmountOfBridgesNeededToWin) { GameInitializer.GetCameraManager().MoveCameraTo(new Vector3(53, 6, 19), Glob.CameraBuildingZoomTime); UIHandler.ShowNotification("Through combined efforts, a bridge connecting both cities has been built. The cities are now at peace, and are even thinking of merging to improve the quality of life for everyone."); GameInitializer.EndGame(true); } } }
public void HandleHappiness(CustomTile pTile, bool pHappy) { int[] tilePos = GetTilePosition(pTile); for (int x = 0; x < 3; x++)//Check all bordering tiles { for (int y = 0; y < 3; y++) { int xCoordinate = tilePos[0] - 1 + x; int yCoordinate = tilePos[1] - 1 + y; if ((xCoordinate < 0 || xCoordinate >= _tileMap.GetLength(0)) || (yCoordinate < 0 || yCoordinate >= _tileMap.GetLength(1))) { continue; } CustomTile borderingTile = _tileMap[xCoordinate, yCoordinate]; if (!borderingTile.GetIsHappy()) { borderingTile.SetIsHappy(pHappy); if (borderingTile.GetBuildingOnTile() is House && _myManager is PlayerCityManager && pHappy) { GameInitializer.AddSocializerScore(2); } } } } }
public bool StartBuilding() { //Can the building get placed. if (currentCity.CanBuild(placementBuilding.GetCost())) { if (placementBuilding is Wonder) { if (currentCity.GetHappyHouseAmount() < Glob.WonderHappyHouseReq) { _soundHandler.PlaySound(SoundHandler.Sounds.ERROR); UIHandler.ShowNotification("The inhabitants are preventing your workers from building this. They don't want you 'wasting' money on this, instead of making them happy. Try building some parks next to houses first."); return(false); } else if (currentCity.GetManager() is PlayerCityManager) { GameInitializer.AddAchieverScore(30); } } _soundHandler.PlaySound(SoundHandler.Sounds.CONFIRM); //Place the building. //Check for building type if there is another building tile near it. If so, upgrade the building to the amount of buildings. //Give the other building an index of +1. placementBuilding = UpgradeBuilding(placementBuilding); if (placementBuilding is Factory) { placementBuilding = Instantiate(placementBuilding); } placementBuilding.SetBuildingPhase(Building.BuildingPhase.DONE); placementBuilding.SetBuildingTile(currentCity.GetSelectedTile()); currentCity.GetSelectedTile().SetBuilding(placementBuilding); currentCity.BudgetChange(-placementBuilding.GetCost()); if (placementBuilding is MissileSilo || placementBuilding is Wonder || placementBuilding is Bridge) { FunctionBuilding building = placementBuilding as FunctionBuilding; building.DoAction(); } if (placementBuilding is House) { if (placementBuilding.GetBuildingTile().GetIsHappy() && placementBuilding.GetBuildingTile().GetCity().GetManager() is PlayerCityManager) { GameInitializer.AddSocializerScore(2); } } DestroyPlacementBuilding(); return(true); } else { _soundHandler.PlaySound(SoundHandler.Sounds.ERROR); UIHandler.ShowNotification("You don't have enough money to build that."); return(false); } }
public void HandleChoice(int choice) { Choice chc = _currentEvent.choices[choice]; effectBox.SetActive(true); string repercussionCostText = chc.repercussion.cost.ToString(); if (chc.repercussion.cost < 0) { repercussionCostText = "+" + (-chc.repercussion.cost); } effectText.text = chc.repercussion.description + "\nCost: " + repercussionCostText; GameInitializer.GetBuildingHandler().GetCurrentCity().ReceiveCollection(-(chc.cost + chc.repercussion.cost)); GameInitializer.AddAchieverScore(chc.achieverValue); GameInitializer.AddExplorerScore(chc.explorerValue); GameInitializer.AddKillerScore(chc.killerValue); GameInitializer.AddSocializerScore(chc.socializerValue); }