public void BattleManager(GameObject monsterButton) { GameObject[] testButtons = GameObject.FindGameObjectsWithTag("Map Button"); foreach (GameObject obj in testButtons) { obj.GetComponent <TestManager>().currentMonsterButton = monsterButton; } testSuccess = false; //monsterButton.GetComponent<Animator>().Play("bossAnimation"); monsterBiggestDice = 0; playerBiggestDice = 0; if (monsterButton.name.Substring(0, 2) == "01" || monsterButton.name.Substring(0, 2) == "02") { monsterDif = 2; } if (monsterButton.name.Substring(0, 2) == "03" || monsterButton.name.Substring(0, 2) == "04") { monsterDif = 3; } if (monsterButton.name.Substring(0, 2) == "05" || monsterButton.name.Substring(0, 2) == "06" || monsterButton.name.Substring(1, 2) == "07") { monsterDif = 4; } if (monsterButton.name.Substring(0, 2) == "08") { monsterDif = 5; } //Add monster difficult for each monster prefab according to its name print("Dificuldade do Monstro: " + monsterDif); switch (battlingCat) { //Changes the catTested with the parameters from the cat allocated in each cat spot case 0: catTested = ButtonController.cat1; break; case 1: catTested = ButtonController.cat2; break; case 2: catTested = ButtonController.cat3; break; } diceNumber += int.Parse(catTested.Substring(testStat, 1)); //The number of dices will be equal to the cat atb on the atb being tested if (ArtifactsHandler.diceBonus) { diceNumber += ArtifactsHandler.diceBonusValue; } //If there is any dice bonus artifact, add the amount of bonus dice on the total dices which will be rolled print("N de dados: " + diceNumber); bossDiceInfo = ""; for (int i = 0; i < monsterDif; i++) { diceTestRoll = Random.Range(1, 7); bossDiceInfo += diceTestRoll; print("Monster Roll" + diceTestRoll); if (diceTestRoll > monsterBiggestDice) { monsterBiggestDice = diceTestRoll; } } GameObject.Find("Main Camera").GetComponent <DiceRoll>().RollDices("boss", monsterDif, bossDiceInfo, monsterBiggestDice, battleOkButton); diceInfo = ""; for (int i = 0; i < diceNumber; i++) { diceTestRoll += Random.Range(1, 7); //Roll a d6 if (ArtifactsHandler.bonusAtb == testStat) { diceTestRoll += ArtifactsHandler.bonusValue; } //If the atb being tested is equal the current atb getting a bonus, add that bonus on the dice result if (diceTestRoll > 6) { diceTestRoll = 6; } diceInfo += diceTestRoll; if (diceTestRoll > playerBiggestDice) { playerBiggestDice = diceTestRoll; } diceTestRoll = 0; //Resets the value of the rolled number } ArtifactsHandler.resetBonuses(); //Reset all bonus added in this test print("Player Biggest Dice:" + playerBiggestDice + "||| Monster Biggest Dice:" + monsterBiggestDice); if (playerBiggestDice >= monsterBiggestDice) { testSuccess = true; } if (testSuccess) { testResult.color = Color.green; testResult.text = "You win!!"; } else { testResult.color = Color.red; testResult.text = "You lose!!"; } GameObject.Find("Main Camera").GetComponent <DiceRoll>().RollDices("player", diceNumber, diceInfo, monsterBiggestDice, battleOkButton); if (!testSuccess) { switch (battlingCat) { case 0: GameObject.Find("Main Camera").GetComponent <GameplayVariableHandler>().changeLife(false, 0, 1); break; case 1: GameObject.Find("Main Camera").GetComponent <GameplayVariableHandler>().changeLife(false, 1, 1); break; case 2: GameObject.Find("Main Camera").GetComponent <GameplayVariableHandler>().changeLife(false, 2, 1); break; } } else { PlayerPrefs.SetInt("gold", PlayerPrefs.GetInt("gold") + Random.Range(20, 50)); print("Battle Successful!"); } print(currentMonsterButton); diceNumber = 0; }
public void CatSelection(int selectedCat) { testSuccessCounter = 0; battlingCat = selectedCat; //Sets the selected cat as the cat who will be used during battle switch (selectedCat) //Changes the catTested with the parameters from the cat allocated in each cat spot { case 0: catTested = ButtonController.cat1; break; case 1: catTested = ButtonController.cat2; break; case 2: catTested = ButtonController.cat3; break; } diceInfo = ""; diceNumber += int.Parse(catTested.Substring(testStat, 1)); //The number of dices will be equal to the cat atb on the atb being tested if (ArtifactsHandler.diceBonus) { diceNumber += ArtifactsHandler.diceBonusValue; } //If there is any dice bonus artifact, add the amount of bonus dice on the total dices which will be rolled print("N de dados: " + diceNumber); testCard.GetComponent <Animator>().Play("CatSelection"); for (int i = 0; i < diceNumber; i++) { diceTestRoll += Random.Range(1, 7); //Roll a d6 if (ArtifactsHandler.bonusAtb == testStat) { diceTestRoll += ArtifactsHandler.bonusValue; } //If the atb being tested is equal the current atb getting a bonus, add that bonus on the dice result if (diceTestRoll > 6) { diceTestRoll = 6; } diceInfo += diceTestRoll; print("Resultado da Rolagem: " + diceTestRoll); if (diceTestRoll >= testDif) { testSuccessCounter += 1; } diceTestRoll = 0; //Resets the value of the rolled number } ArtifactsHandler.resetBonuses(); //Reset all bonus added in this test if (testSuccessCounter >= diceNumberRandomizer) { testSuccess = true; testResult.color = Color.green; testResult.text = "Success!!"; } if (!testSuccess) { testResult.color = Color.red; testResult.text = "Fail!!"; switch (selectedCat) { case 0: GameObject.Find("Main Camera").GetComponent <GameplayVariableHandler>().changeLife(false, 0, 1); break; case 1: GameObject.Find("Main Camera").GetComponent <GameplayVariableHandler>().changeLife(false, 1, 1); break; case 2: GameObject.Find("Main Camera").GetComponent <GameplayVariableHandler>().changeLife(false, 2, 1); break; } } GameObject.Find("Main Camera").GetComponent <DiceRoll>().RollDices("test", diceNumber, diceInfo, testDif, okButton); GameplayVariableHandler.lastUsedCat = selectedCat; //Sets the disabled cat for the next challenge (the cat used this turn) diceNumber = 0; }