/// <summary> /// depletes power bars and fades this side out if it now has 0 power /// </summary> /// <param name="initialPower"></param> /// <param name="curPower"></param> /// <returns></returns> public IEnumerator DepletePowerBarAccordingToPower(float initialPower, float curPower) { float elapsedTime = 0, initialFillAmount = factionPowerBarContent.fillAmount; depletingBar = true; //prevent any changes while transition is running bPanel.resolutionBtnsGroup.interactable = false; while (elapsedTime <= BAR_DEPLETION_TIME) { factionPowerBarContent.fillAmount = Mathf.Lerp(initialFillAmount, curPower / initialPower, elapsedTime / BAR_DEPLETION_TIME); elapsedTime += Time.deltaTime; yield return(null); } if (curPower == 0) { elapsedTime = 0; while (elapsedTime <= SIDE_DEFEATED_FADE_TIME) { ourGroup.alpha = Mathf.Lerp(1.0f, 0.0f, elapsedTime / SIDE_DEFEATED_FADE_TIME); elapsedTime += Time.deltaTime; yield return(null); } //this side's been defeated! the battle's resolved then //notify the panel yield return(new WaitForSeconds(SIDE_DEFEATED_NOTIFY_DELAY)); bPanel.BattleResolved(this); } depletingBar = false; bPanel.OnOneSideDoneAnimating(); }