public void StoreCarriedMonster(bool secondary = false) { Monster monster = playerInventory.GetMonster(secondary).GetComponent <Monster>(); playerInventory.AddMonsterToPc(monster); playerInventory.carriedMonsters[(secondary) ? 1 : 0] = null; if (!secondary) { playerInventory.SwitchMonsters(); } GenerateEntry(playerInventory.pcStorage.Count - 1); SetPlayerMonstersPC(); }
/// <summary> /// Ends the battle and switches back to the main scene. /// Will show the appropiate text based on whether <c>state</c> is equal to <c>Won</c> or <c>Lost</c>. /// </summary> /// <param name="killedEnemy">Whether or not the player won by killing the enemy. Only applicable if the player won.</param> IEnumerator EndBattle(bool killedEnemy = true) { hudHolder.SetActive(false); playerInventory.wonLastBattle = state == BattleState.Won; if (state == BattleState.Won) { if (killedEnemy) { // Player killed the enemy float moneyFloat = Random.Range(baseMoney + (float)(enemyMonster.monsterLevel + 1) * minMoneyMod, baseMoney + (float)(enemyMonster.monsterLevel + 1) * maxMoneyMod); int money = Mathf.RoundToInt(moneyFloat); playerInventory.money += money; float expFloat = Random.Range(baseExp + (float)(enemyMonster.monsterLevel + 1) * minExpMod, baseExp + (float)(enemyMonster.monsterLevel + 1) * maxExpMod); int oldLevels = playerMonster.monsterLevel; bool leveledUp = playerMonster.AddExp(Mathf.RoundToInt(expFloat)); int levelsGrown = playerMonster.monsterLevel - oldLevels; LoadPlayerMonsterHud(); // Update any quest data playerInventory.UpdateCompletion(GoalType.KillMonsters, 1, enemyMonster.monsterName); dialoogText.text = "You got " + money + " coins and " + Mathf.RoundToInt(expFloat) + " experience!"; yield return(new WaitForSeconds(waitTimeEnd)); if (leveledUp) { audioSource.clip = levelUpSfx; audioSource.Play(); StartCoroutine(FlashColor(playerMonster, Color.cyan)); dialoogText.text = $"Leveled up {levelsGrown} level{((levelsGrown > 1) ? "s" : "")}!"; yield return(new WaitForSeconds(waitTimeEnd)); dialoogText.text = "Damage increased by " + levelsGrown * playerMonster.damageValue.y + "!\n"; dialoogText.text += "Healing increased by " + levelsGrown * playerMonster.healValue.y + "!\n"; dialoogText.text += "Hit points increased by " + levelsGrown * (playerMonster.damageValue.y + playerMonster.healValue.y) + "!\n"; yield return(new WaitForSeconds(waitTimeEnd * 2.0f)); } dialoogText.text = "You won the battle against " + enemyMonster.monsterName + "!"; yield return(new WaitForSeconds(waitTimeEnd)); } else { // Player caught the enemy // Update any quest data playerInventory.UpdateCompletion(GoalType.CatchMonsters, 1, enemyMonster.monsterName); // Check if we can equip them immediately if (!playerInventory.GetMonster(true)) { playerInventory.LoadMonsterIntoParty(enemyMonster, true); dialoogText.text = $"{enemyMonster.monsterName} is now in your party!"; yield return(new WaitForSeconds(waitTimeEnd)); } else { // Send them to the PC playerInventory.AddMonsterToPc(enemyMonster); dialoogText.text = $"{enemyMonster.monsterName} has been sent to your PC!"; yield return(new WaitForSeconds(waitTimeEnd)); } } } else if (state == BattleState.Lost) { dialoogText.text = "You were slain by " + enemyMonster.monsterName + "!"; yield return(new WaitForSeconds(waitTimeEnd)); dialoogText.text = "You return home in shame..."; yield return(new WaitForSeconds(waitTimeEnd)); } ExitScene(); }