private IEnumerator LoadSceneWithDelay(float delay) { canvasAnim.SetTrigger("EnemyEncounter"); yield return(new WaitForSeconds(delay)); for (int index = 0; index < 4; index++) { dataRetainer.SetPlayerXP(index, playerStatus[index].currentXP); dataRetainer.SetPlayerLevel(index, playerStatus[index].playerLevel); } SceneManager.LoadScene("CombatSceneSample"); }
private void Update() { if (endBattleScreen == true) { if (animateXP) { if (xpToAdd <= 0) { animateXP = false; } else { for (int index = 0; index < 4; index++) { playerStatus[index].currentXP += playerStatus[index].xpNeeded / 120f; xpToAdd -= playerStatus[index].xpNeeded / 120f; if (playerStatus[index].currentXP >= playerStatus[index].xpNeeded) { bool cond = false; for (int index2 = 0; index2 < leveledUpPlayersIndex.Count; index2++) { if (leveledUpPlayersIndex[index2].first == index) { cond = true; break; } } if (cond == false) { leveledUpPlayersIndex.Add(new Pair <int, int>(index, playerStatus[index].playerLevel)); } playerStatus[index].currentXP = 0; playerStatus[index].playerLevel++; playerStatus[index].xpNeeded = playerStatus[index].baseStatus.xp + (4 * (playerStatus[index].playerLevel ^ 3)) / 7; } xpBars[index].fillAmount = (float)playerStatus[index].currentXP / playerStatus[index].xpNeeded; xpTexts[index].text = "" + (int)playerStatus[index].currentXP + "/" + playerStatus[index].xpNeeded; animateXP = true; } } } else { if (Input.GetButtonDown("Interact")) { if (leveledUpPlayersIndex.Count == 0) { for (int index = 0; index < 4; index++) { dataRetainer.SetPlayerXP(index, (int)playerStatus[index].currentXP); dataRetainer.SetPlayerLevel(index, playerStatus[index].playerLevel); } if (runAway) { turnBaseScript.StartCoroutine(turnBaseScript.ChangeSceneWithDelay("", 2f)); } else { turnBaseScript.StartCoroutine(turnBaseScript.ChangeSceneWithDelay("", 2f)); } endBattleMenu.SetActive(false); playerLevelUpMenu.SetActive(false); } else { endBattleMenu.SetActive(false); SetLevelUpUI(); leveledUpPlayersIndex.RemoveAt(0); } } } } }