IEnumerator SetupBattle() { playerGO = Instantiate(PlayerPrefab, PlayerShadow.GetChild(0)); playerUnit = playerGO.GetComponent <Unit>(); playerGO.GetComponent <CharacterAnimator>().idleFrames = levelScript.playerIdleFrames; playerGO.GetComponent <CharacterAnimator>().baseAttackFrames = levelScript.playerBaseAttackFrames; playerGO.GetComponent <CharacterAnimator>().specialAttackFrames = levelScript.playerSpecialAttackFrames; playerGO.GetComponent <CharacterAnimator>().ultimateAttackFrames = levelScript.playerUltimateAttackFrames; playerGO.GetComponent <CharacterAnimator>().defendFrames = levelScript.playerDefendFrames; enemyGo = Instantiate(EnemyPrefab, EnemyShadow.GetChild(0)); enemyUnit = enemyGo.GetComponent <Unit>(); playerGO.AddComponent(levelScript.GetPlayersEffectsAnimator()); playerGO.GetComponent <CharacterAnimator>().opponentEF = enemyGo.GetComponent <EffectsAnimator>(); enemyGo.GetComponent <CharacterAnimator>().opponentEF = playerGO.GetComponent <EffectsAnimator>(); if (transform.parent.Find("BattleUI").childCount < 3) { attackButtons = Instantiate(levelScript.GetPlayersAttackButtons(), transform.parent.Find("BattleUI")); attackButtons.transform.SetAsLastSibling(); attackButtons.name = "Attacks"; attackButtons.SetActive(true); } else { attackButtons.SetActive(true); } attacksUnlocker = transform.parent.Find("BattleUI").GetComponentInChildren <AttacksUnlocker>(); turnText.CrossFadeAlpha(0, 0f, false); nameText.text = enemyUnit.unitName; usc = transform.parent.Find("BattleUI").Find("Attacks").GetComponentInChildren <UltimateSliderController>(true); playerHUD.SetHUD(playerUnit); enemyHUD.SetHUD(enemyUnit); StartCoroutine(TurnIndicatorShowHide()); yield return(new WaitForSeconds(2f)); state = BattleState.PLAYERTURN; Note.SetActive(false); attacking = false; battling = true; }
public void addXP(int amount, AttacksUnlocker au) { int xp = PlayerPrefs.GetInt("xp"); int requiredXP = PlayerPrefs.GetInt("requiredXP"); for (int i = 0; i < amount; i++) { xp++; if (xp == requiredXP) { LevelUp(); requiredXP = requiredXP + 2; xp = 0; } } print("xp is now " + xp); PlayerPrefs.SetInt("xp", xp); PlayerPrefs.SetInt("requiredXP", requiredXP); au.CheckUnlocks(); }