public void UpdateGameWithLoadedData() { UIController.Instance.UpdatePlayerLevel(); UIController.Instance.UpdatePlayerInfoStat(); expManager.UpdateExp(PlayerController.Instance.GetCurrentExp(), PlayerController.Instance.GetMaxExp()); UIController.Instance.UpdateStage(playerData.game_stage); }
//public void Init(string p_name, int p_hp, int p_attk, int p_def) //{ // char_name = p_name; // maxHP = p_hp; // currentHP = maxHP; // attack = p_attk; // defense = p_def; // level = 1; // m_gold = 0; // currentExp = 0; // maxExp = (int)(10 * (Mathf.Log(level, 2) + 1)); // p_inventory = new List<Item>(); //} public void GainGoldAndExp(Enemy enemy) { playerData.player_gold += enemy.getDropGold(); // if given exp allows level up if (playerData.player_currentExp + enemy.getDropExp() >= playerData.player_maxExp) { // TODO player level up float remainExp = enemy.getDropExp() + playerData.player_currentExp - playerData.player_maxExp; LevelUp(); Transform tt = dmgPool.GetFromPool(2); tt.position = transform.position + Vector3.up * 5f; //tt. playerData.player_currentExp += remainExp; expManager.UpdateExp(playerData.player_currentExp, playerData.player_maxExp); while (playerData.player_currentExp >= playerData.player_maxExp) { // levels up multiple time as currentExp exceeds max exp if (playerData.player_currentExp >= playerData.player_maxExp) { float leftExp = playerData.player_currentExp - playerData.player_maxExp; LevelUp(); playerData.player_currentExp += leftExp; } } expManager.UpdateExp(playerData.player_currentExp, playerData.player_maxExp); } else { playerData.player_currentExp += enemy.getDropExp(); expManager.UpdateExp(playerData.player_currentExp, playerData.player_maxExp); } UIController.Instance.UpdatePlayerInfoStat(); ShopController.Instance.CheckEnoughMoney(); GameController.Instance.SaveGame(); }