public void AddMissileLaunched() { _missilesLaunched++; if (_myManager is PlayerCityManager) { AICityManager AICity = GameInitializer.GetNextCity(this).GetManager() as AICityManager; AICity.ChangeAnimosity(50, GameInitializer.GetNextCity(this)); } if (_myManager is PlayerCityManager) { GameInitializer.AddKillerScore(20); } if (_missilesLaunched >= Glob.AmountOfMissilesNeededToWin) { CustomTile targetTile = _tileMap[0, 0]; foreach (CustomTile tile in _tileMap) { if (tile.GetBuildingOnTile() is MissileSilo) { targetTile = tile; break; } } GameInitializer.GetCameraManager().MoveCameraTo(targetTile.transform.position + Glob.CameraBuildingOffset, Glob.CameraBuildingZoomTime); //TODO: Zoom in on a digsite if (_myManager is PlayerCityManager) { UIHandler.ShowNotification("AIton has surrendered! He was too afraid of your firepower and decided to run away, leaving his city and inhabitants behind."); } else { UIHandler.ShowNotification("All of your inhabitants have fled your city after all the bombardments AIton launched at you. You have no choice but to surrender."); } GameInitializer.EndGame(false, this); } }
void Update() { if (GameInitializer.GetBuildingHandler().GetCurrentCity() == this && GameInitializer.GetBuildingHandler().IsReadyToBuild()) { if (!GameInitializer.GetPaused()) { if (_currentTurn > Glob.TurnAmount) { GameInitializer.EndGame(); return; } if (!_collectedThisTurn) { if ((_currentTurn - Glob.EventTurnStart) % Glob.EventTurnInterval == 0 && _myManager is PlayerCityManager && _currentTurn >= Glob.EventTurnStart) { if (!_gotEventThisTurn) { _gotEventThisTurn = true; _eventManager.EnableRandomEvent(); return; } } GameInitializer.GetUIHandler().SetTurnText(_currentTurn); UIHandler.ToggleNotificationPanel(false); CollectFromAllBuildings(); if (_myManager is PlayerCityManager) { AICityManager AICity = GameInitializer.GetNextCity(this).GetManager() as AICityManager; AICity.ChangeAnimosity(-Mathf.RoundToInt(GetHappyHouseAmount() * Glob.HappyHouseAnimosityChange), GameInitializer.GetNextCity(this)); } _collectedThisTurn = true; _gotEventThisTurn = false; _mayorOffice.UpdateHatPosition(_budget); BudgetChange(0); //_uiHandler.SetResourcesBars((int)_budget); //Just in case no buildings collected anything if (_currentTurn >= 6 && _currentTurn <= 8 && _myManager is PlayerCityManager) { switch (_currentTurn) { case 6: int scoreTurn6 = Mathf.Clamp(Glob.OptimalBudgetTurn6 - (int)_budget, 0, 10); GameInitializer.AddAchieverScore(10 - scoreTurn6); break; case 7: int scoreTurn7 = Mathf.Clamp(Glob.OptimalBudgetTurn7 - (int)_budget, 0, 20) / 2; GameInitializer.AddAchieverScore(10 - scoreTurn7); break; case 8: int scoreTurn8 = Mathf.Clamp(Glob.OptimalBudgetTurn8 - (int)_budget, 0, 40) / 4; GameInitializer.AddAchieverScore(10 - scoreTurn8); break; default: break; } } } _myManager.HandleTurn(this); } } else if (_collectedThisTurn) { _collectedThisTurn = false; _currentTurn++; } else if (GameInitializer.GetBuildingHandler().GetCurrentCity() == this && !GameInitializer.GetBuildingHandler().IsReadyToBuild()) { BudgetChange(0); // _uiHandler.SetResourcesBars((int)_budget); //Just in case no buildings collected anything } }