IEnumerator SetupBattle() { GameObject playerGO = Instantiate(player, playerPos); playerUnit = playerGO.GetComponent <PlayerBattle>(); GameObject bossGO = Instantiate(boss, bossPos); bossUnit = bossGO.GetComponent <FilterController>(); GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); moldUnitTwo.SetLevel(1); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; bossPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "You made a mistake crossing me..."; numEnemies = 2; currEnemies = 2; AdjustAttacks(); AdjustTargets(); PopulateItems(); StartCoroutine(PrintText("If you lose here, you will be lost for good...")); yield return(new WaitForSeconds(10f)); state = BattleState.PLAYERTURN; PlayerTurn(); }
IEnumerator SetupBattle() { GameObject playerGO = Instantiate(player, playerPos); playerUnit = playerGO.GetComponent <PlayerBattle>(); //playerUnit.inBattle = true; if (gm.GetLevel() == 1) { if (firstFight) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); numEnemies = 1; firstFight = false; } else { int moldSpawnChance = Random.Range(1, 100); if (gm.GetExperience() >= 3.0f) { if (moldSpawnChance >= 75) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); moldUnitOne.SetLevel(3); numEnemies = 1; } else if (moldSpawnChance >= 50) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, firstEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); moldUnitOne.SetLevel(3); moldUnitTwo.SetLevel(3); numEnemies = 2; } else if (moldSpawnChance >= 25) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, firstEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, firstEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); moldUnitOne.SetLevel(3); moldUnitTwo.SetLevel(3); moldUnitThree.SetLevel(3); numEnemies = 3; } else { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, firstEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, firstEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); GameObject enemy4 = Instantiate(enemy, firstEnemyPos); moldUnitFour = enemy4.GetComponent <MoldController>(); moldUnitOne.SetLevel(3); moldUnitTwo.SetLevel(3); moldUnitThree.SetLevel(3); moldUnitFour.SetLevel(3); numEnemies = 4; } } else if (gm.GetExperience() >= 2.0f) { if (moldSpawnChance >= 67) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); moldUnitOne.SetLevel(2); numEnemies = 1; } else if (moldSpawnChance >= 37) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, firstEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); moldUnitOne.SetLevel(2); moldUnitTwo.SetLevel(2); numEnemies = 2; } else if (moldSpawnChance >= 17) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, firstEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, firstEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); moldUnitOne.SetLevel(2); moldUnitTwo.SetLevel(2); moldUnitThree.SetLevel(2); numEnemies = 3; } else { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, firstEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, firstEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); GameObject enemy4 = Instantiate(enemy, firstEnemyPos); moldUnitFour = enemy4.GetComponent <MoldController>(); moldUnitOne.SetLevel(2); moldUnitTwo.SetLevel(2); moldUnitThree.SetLevel(2); moldUnitFour.SetLevel(2); numEnemies = 4; } } else if (gm.GetExperience() >= 1.0f) { if (moldSpawnChance >= 50) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); numEnemies = 1; } else if (moldSpawnChance >= 25) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, firstEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); moldUnitTwo.SetLevel(1); numEnemies = 2; } else if (moldSpawnChance >= 5) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, firstEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, firstEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); moldUnitTwo.SetLevel(1); moldUnitThree.SetLevel(1); numEnemies = 3; } else { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, firstEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, firstEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); GameObject enemy4 = Instantiate(enemy, firstEnemyPos); moldUnitFour = enemy4.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); moldUnitTwo.SetLevel(1); moldUnitThree.SetLevel(1); moldUnitFour.SetLevel(1); numEnemies = 4; } } } dialogueText.text = "MOLD has sensed your presence..."; AdjustAttack(); PopulateItems(); } yield return(new WaitForSeconds(4f)); state = BattleState.PLAYERTURN; PlayerTurn(); }
void BossTurn() { if (state != BattleState.BOSSTURN) { return; } float[] attackStats = bossUnit.Attack(currEnemies); //no attack if (attackStats[0] == 0.0f) { StartCoroutine(FitlerSpeaks("Well m-maybe I just don't want to attack...")); StartCoroutine(PrintText("Fitler \"decides\" not to attack")); StartCoroutine(DelayBoss(6f)); } //tear else if (attackStats[0] == 1.0f) { playerUnit.TakeDamage(attackStats[1]); //npc takes damage too StartCoroutine(FitlerSpeaks("Who's holy now?")); StartCoroutine(PrintText("Fitler uses TEAR")); Invoke("PlayerActionDelay", 3f); } //tangle else if (attackStats[0] == 2.0f) { if (attackStats[2] == 0.0f) { StartCoroutine(FitlerSpeaks("Well m-maybe I just don't want to attack...")); StartCoroutine(PrintText("Fitler's attack TANGLE misses")); StartCoroutine(DelayBoss(6f)); } else if (attackStats[2] == 1.0f) { sockCanAttack = false; StartCoroutine(FitlerSpeaks("Tripping over yourself again?")); StartCoroutine(PrintText("Fitler uses TANGLE on SOCK")); StartCoroutine(DelayBoss(6f)); } //TODO else if (attackStats[2] == 2.0f) { hairTiesCanAttack = false; StartCoroutine(FitlerSpeaks("As you were - as I prefer")); StartCoroutine(PrintText("Fitler uses TANGLE on HAIR TIES")); StartCoroutine(DelayBoss(6f)); } } //no minions else if (attackStats[0] == 3.0f) { StartCoroutine(FitlerSpeaks("Well m-maybe I just don't want to attack...")); StartCoroutine(PrintText("Fitler cannot summon more MOLD")); StartCoroutine(DelayBoss(6f)); } //one minion else if (attackStats[0] == 4.0f) { if (firstMinionAlive) { GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); int level = (int)attackStats[1]; moldUnitTwo.SetLevel((int)attackStats[1]); secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL " + level.ToString(); } else if (secondMinionAlive) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); int level = (int)attackStats[1]; moldUnitOne.SetLevel((int)attackStats[1]); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL " + level.ToString(); } StartCoroutine(FitlerSpeaks("FIGHT FOR ME!")); StartCoroutine(PrintText("Fitler summons a minion. He's kinda cute.")); StartCoroutine(DelayBoss(6f)); } //two minion else if (attackStats[0] == 5.0f) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); int level1 = (int)attackStats[1]; moldUnitOne.SetLevel((int)attackStats[1]); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL " + level1.ToString(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); int level2 = (int)attackStats[1]; moldUnitTwo.SetLevel((int)attackStats[1]); secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL " + level2.ToString(); StartCoroutine(FitlerSpeaks("FIGHT FOR ME!")); StartCoroutine(PrintText("Fitler summons two minions. You are \"definitely\" impressed")); StartCoroutine(DelayBoss(6f)); } if (playerUnit.currHealth <= 0.0f) { SceneManager.LoadScene("Game Over"); } }
IEnumerator SetupBattle() { GameObject playerGO = Instantiate(player, playerPos); playerUnit = playerGO.GetComponent <PlayerBattle>(); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = ""; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = ""; thirdEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = ""; forthEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = ""; if (gm.GetLevel() == 1) { if (firstFight) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; numEnemies = 1; firstFight = false; AdjustAttacks(); PopulateItems(); } else { int moldSpawnChance = Random.Range(1, 100); if (gm.GetExperience() >= 3.0f) { if (moldSpawnChance >= 75) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); moldUnitOne.SetLevel(3); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; numEnemies = 1; } else if (moldSpawnChance >= 50) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); moldUnitOne.SetLevel(3); moldUnitTwo.SetLevel(3); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; numEnemies = 2; } else if (moldSpawnChance >= 25) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, thirdEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); moldUnitOne.SetLevel(3); moldUnitTwo.SetLevel(3); moldUnitThree.SetLevel(3); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; thirdEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; numEnemies = 3; } else { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, thirdEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); GameObject enemy4 = Instantiate(enemy, forthEnemyPos); moldUnitFour = enemy4.GetComponent <MoldController>(); moldUnitOne.SetLevel(3); moldUnitTwo.SetLevel(3); moldUnitThree.SetLevel(3); moldUnitFour.SetLevel(3); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; thirdEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; forthEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 3"; numEnemies = 4; } } else if (gm.GetExperience() >= 2.0f) { if (moldSpawnChance >= 67) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); moldUnitOne.SetLevel(2); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; numEnemies = 1; } else if (moldSpawnChance >= 37) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); moldUnitOne.SetLevel(2); moldUnitTwo.SetLevel(2); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; numEnemies = 2; } else if (moldSpawnChance >= 17) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, thirdEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); moldUnitOne.SetLevel(2); moldUnitTwo.SetLevel(2); moldUnitThree.SetLevel(2); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; thirdEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; numEnemies = 3; } else { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, thirdEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); GameObject enemy4 = Instantiate(enemy, forthEnemyPos); moldUnitFour = enemy4.GetComponent <MoldController>(); moldUnitOne.SetLevel(2); moldUnitTwo.SetLevel(2); moldUnitThree.SetLevel(2); moldUnitFour.SetLevel(2); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; thirdEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; forthEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 2"; numEnemies = 4; } } else if (gm.GetExperience() >= 1.0f) { if (moldSpawnChance >= 50) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; numEnemies = 1; } else if (moldSpawnChance >= 25) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); moldUnitTwo.SetLevel(1); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; numEnemies = 2; } else if (moldSpawnChance >= 5) { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, thirdEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); moldUnitTwo.SetLevel(1); moldUnitThree.SetLevel(1); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; thirdEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; numEnemies = 3; } else { GameObject enemy1 = Instantiate(enemy, firstEnemyPos); moldUnitOne = enemy1.GetComponent <MoldController>(); GameObject enemy2 = Instantiate(enemy, secondEnemyPos); moldUnitTwo = enemy2.GetComponent <MoldController>(); GameObject enemy3 = Instantiate(enemy, thirdEnemyPos); moldUnitThree = enemy3.GetComponent <MoldController>(); GameObject enemy4 = Instantiate(enemy, forthEnemyPos); moldUnitFour = enemy4.GetComponent <MoldController>(); moldUnitOne.SetLevel(1); moldUnitTwo.SetLevel(1); moldUnitThree.SetLevel(1); moldUnitFour.SetLevel(1); firstEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; secondEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; thirdEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; forthEnemyPos.GetChild(0).GetComponent <TextMeshProUGUI>().text = "LVL 1"; numEnemies = 4; } } } currEnemies = numEnemies; StartCoroutine(PrintText("MOLD has sensed your presence...")); AdjustTargets(); } yield return(new WaitForSeconds(4f)); state = BattleState.PLAYERTURN; PlayerTurn(); }