public void UpgradeUnitCapWithGold() { costToUpgradeUnitCap = maxDeployedUnitsLimit * 10; if (playerGoldCount >= costToUpgradeUnitCap) { SetPlayerGoldCount(playerGoldCount - (costToUpgradeUnitCap)); SetMaxDeployedUnitsLimit(maxDeployedUnitsLimit + 1); uiController.ChangeCostToUnitCapUpgradeDisplayText((costToUpgradeUnitCap).ToString()); uiController.hudCanvasAudioSource.PlayOneShot(uiController.genericSucessAudioClip); } else { uiController.ChangeCostToUnitCapUpgradeDisplayText((costToUpgradeUnitCap).ToString()); uiController.hudCanvasAudioSource.PlayOneShot(uiController.genericButtonFailureAudioClip); } }
IEnumerator SmoothEndCombatRoundTransition() // smoothly end combat { uiController.combatLogger.parseTime = combatRoundTimer; combatRoundTimer = 0; uiController.combatTimerPanel.gameObject.SetActive(false); uiController.EnableCombatReportPanel(); List <CombatReport> combatReports = uiController.combatLogger.combatReports; foreach (CombatReport combatReport in combatReports) { if (combatReport.dirtyParseTime) { combatReport.parseTime = uiController.combatLogger.parseTime; } } GameObject combatReportBarPrefab = (GameObject)Resources.Load("Combat Report Bar"); foreach (NPC npc in npcController.allyList) { if (!npc.isEnemy && !npc.isCreep && !npc.isBoss && npc.combatReport_DamageDoneThisRound != 0) { uiController.combatLogger.AddCombatReport(new CombatReport(npc.UNIT_TYPE.ToString(), npc.TIER, npc.combatReport_DamageDoneThisRound, uiController.combatLogger.parseTime, false, npc.combatReport_barUnitColor)); npc.combatReport_DamageDoneThisRound = 0; } } uiController.combatLogger.ResetCombatReportBars(); combatReports = uiController.combatLogger.combatReports; List <CombatReport> sortedCombatReports = combatReports.OrderByDescending(o => o.damageDealt).ToList(); float totalDamageDone = 0; foreach (CombatReport combatReport in sortedCombatReports) { totalDamageDone += combatReport.damageDealt; } foreach (CombatReport combatReport in sortedCombatReports) { GameObject go = Instantiate(combatReportBarPrefab, uiController.combatReportEntries.transform); CombatReportBar combatReportBar = go.GetComponent <CombatReportBar>(); combatReportBar.combatReport = combatReport; combatReportBar.totalDamage = totalDamageDone; combatReportBar.unitColor = combatReport.unitColor; if (sortedCombatReports.Count >= 0) { combatReportBar.topDamage = sortedCombatReports[0].damageDealt; } combatReportBar.SetUIElements(); uiController.combatLogger.combatReportBars.Add(go); } uiController.combatLogger.ResetCombatLog(); if (npcController.enemyList.Count == 0) // combat victory { if (npcController.allyList.Count != 0) { foreach (NPC npc in npcController.deployedAllyList) { if (npc.cheering_SoundClip != null && UnityEngine.Random.Range(0, 2) == 1) { npc.npcAudioSource.PlayOneShot(npc.cheering_SoundClip); } } } } yield return(new WaitForSeconds(4)); // wait 2 seconds float goldCount = playerController.playerGoldCount; // fetch the player's current gold playerController.enemyMMR += 5; if (npcController.enemyList.Count == 0) // combat VICTORY { steamAchievements.IncrementRoundsWon(1); sessionLogger.CalculateFIDEMMRChange(true, (float)playerController.playerMMR, (float)playerController.enemyMMR, playerController.FIDE_KFactor); goldCount *= 1.11f; goldCount += 1; if (goldCount < 2) { goldCount = 2; } goldCount = (float)Math.Round(goldCount, 0, MidpointRounding.AwayFromZero); float netGoldReward = goldCount - playerController.playerGoldCount; playerController.sessionLogger.goldRewarded += (long)netGoldReward; playerController.SetPlayerGoldCount((long)goldCount); // reward bonus gold } else // combat DEFEAT { sessionLogger.CalculateFIDEMMRChange(false, (float)playerController.playerMMR, (float)playerController.enemyMMR, playerController.FIDE_KFactor); goldCount *= 1.06f; goldCount += 1; if (goldCount < 2) { goldCount = 2; } float netGoldReward = goldCount - playerController.playerGoldCount; playerController.sessionLogger.goldRewarded += (long)netGoldReward; playerController.SetPlayerGoldCount((long)goldCount); // reward DEFEAT bonus gold bool isCreepRound = false; bool isBossRound = false; foreach (NPC npc in npcController.enemyList) { if (npc.isBoss) { isBossRound = true; } else if (npc.isCreep) { isCreepRound = true; } } if (isCreepRound) { playerController.SetCurrentHP(playerController.currentPlayerHealth - 5); } else if (isBossRound) { playerController.SetCurrentHP(playerController.currentPlayerHealth - 50); } else { playerController.SetCurrentHP(playerController.currentPlayerHealth - 10); } } uiController.hudCanvasAudioSource.PlayOneShot(uiController.shopRefreshAudioClip); int i; for (i = npcController.enemyList.Count - 1; i >= 0; i--) // clean up the board from any enemy units { if (npcController.enemyList[i] != null) { npcController.enemyList[i].RemoveFromBoard(true); } } for (i = npcController.deployedAllyList.Count - 1; i >= 0; i--) // clean up the board from any ally units { if (npcController.deployedAllyList[i] != null) { npcController.deployedAllyList[i].RemoveFromBoard(true); } } for (i = npcController.allyListBackup.Count - 1; i >= 0; i--) // put back all the pre-combat clones into the board { if (npcController.allyListBackup[i] != null) { npcController.allyListBackup[i].gameObject.transform.parent.position = npcController.allyListBackup[i].occupyingTile.transform.position; npcController.allyListBackup[i].enabled = true; chessBoard[npcController.allyListBackup[i].occupyingTile.GetComponent <TileBehaviour>().i, npcController.allyListBackup[i].occupyingTile.GetComponent <TileBehaviour>().j].GetComponent <TileBehaviour>().occupyingUnit = npcController.allyListBackup[i].gameObject; Helper.Increment <Tribe>(playerController.deployedTribesCounter, npcController.allyListBackup[i].PRIMARYTRIBE); Helper.Increment <Tribe>(playerController.deployedTribesCounter, npcController.allyListBackup[i].SECONDARYTRIBE); uiController.RefreshDeployedTribesCounter(); playerController.SetCurrentlyDeployedUnits(playerController.currentlyDeployedUnits + 1);; npcController.deployedAllyList.Add(npcController.allyListBackup[i]); npcController.allyList.Add(npcController.allyListBackup[i]); selectedNPC = npcController.deployedAllyList.ToArray()[0].gameObject; } } if (gameStatus != GameStatus.ReportDefeat || gameStatus != GameStatus.GameOver || gameStatus != GameStatus.ReportVictory) { ChangeCurrentRound(currentGameRound + 1); } playerController.ShuffleNewShopingOptions(true); // shuffle the player shop for free with new options to buy if (gameStatus != GameStatus.ReportDefeat || gameStatus != GameStatus.ReportVictory) { ChangeGameStatus(GameStatus.Shopping); // finally, change the game status to shopping phase } if (currentGameRound % 3 == 0) // only once every 3 rounds { playerController.SetMaxDeployedUnitsLimit(playerController.maxDeployedUnitsLimit + 1); // increment the max deployed unit limit playerController.costToUpgradeUnitCap = 10 * playerController.maxDeployedUnitsLimit; uiController.ChangeCostToUnitCapUpgradeDisplayText((10 * playerController.maxDeployedUnitsLimit).ToString()); } }