//Execute assist move method // Pre: Pressed C or V, fighterIndex < numPartners // Post: Do tactical slow down sequence to select move IEnumerator assistMoveExecute(int assistIndex, Vector3 mainPosition) { int mainIndex = (partyIndex > assistIndex) ? partyIndex - 1 : partyIndex; //Store new main index to go back to player after attack PKMNEntity mainFighter = selectedFighter; assistFighter = transform.GetChild(assistIndex).GetComponent <PKMNEntity>(); //Get new assist fighter Transform assist = assistFighter.transform; float assistHealth = assistFighter.accessStat(BaseStat.HEALTH); //Get health statuses float mainHealth = selectedFighter.accessStat(BaseStat.HEALTH); numPartners--; //Enable and detach partyIndex = assistIndex; swapMainCharUI(true); //assist.position = transform.position; //Commence slow down sequence assistSeqOn = true; assistFighter.transform.parent = null; assistTimerUI.gameObject.SetActive(true); Time.timeScale = SLOWED_TIME_SCALE; float curTime = 0.0f; bool moveRan = false; bool notHit = assistHealth <= assistFighter.accessStat(BaseStat.HEALTH) && mainHealth <= mainFighter.accessStat(BaseStat.HEALTH); //Slow down sequence while ((Input.GetKey("c") || Input.GetKey("v")) && !moveRan && curTime < MAX_ASSIST_SEQUENCE_DURATION && notHit) { assistTimerUI.updateProgress((MAX_ASSIST_SEQUENCE_DURATION - curTime) / MAX_ASSIST_SEQUENCE_DURATION); yield return(new WaitForSecondsRealtime(0.01f)); curTime += Time.deltaTime; if (Input.GetMouseButton(1)) { moveRan = moveRan || selectedFighter.executeAssistMove(secMoveIndex); } float curAssistHealth = assistFighter.accessStat(BaseStat.HEALTH); float curMainHealth = mainFighter.accessStat(BaseStat.HEALTH); notHit = assistHealth <= curAssistHealth && mainHealth <= curMainHealth; //Checks if main character OR assist character was hit assistHealth = curAssistHealth; mainHealth = curMainHealth; } //Set main character back as the selected fighter while keeping enemy detached partyIndex = mainIndex; goBackToMain(mainPosition); Time.timeScale = 1f; assistSeqOn = false; bool allowDuration = moveRan || !notHit; canMove = false; yield return(new WaitForSeconds(0.18f)); if (!selectedFighter.isStunned()) { canMove = true; } if (allowDuration) { yield return(StartCoroutine(automatedAssistDuration(assistHealth, moveRan))); } assistTimerUI.gameObject.SetActive(false); if (assistFighter.isAlive()) //If assist fighter is alive, re implement him back in. If not alive, don't reimplement { revertAssist(assistIndex, allowDuration); } else { abilityUIMap[assistFighter].updateStatus(); } assistFighter = null; //Turn assist fighter equal to null to indicate that no assist fighter is present }