// Update is called once per frame void Update() { if (isActiveAndEnabled) { GameObject pokemon = GameObject.FindGameObjectWithTag(name); pokemon_controller script = pokemon.GetComponent <pokemon_controller>(); GetComponent <Text>().text = script.stats[6] + "/" + script.stats[0]; } }
public void OnButtonPress() { //After fight is won ui resets if (this.buttonType == ButtonType.Fight) { fightButtonContainer.gameObject.SetActive(false); moveButtonContainer.gameObject.SetActive(true); battleTextPlayer.SetActive(false); } else if (this.buttonType == ButtonType.Run) { battleCamera.SetActive(false); overworldCamera.SetActive(true); battleUI.SetActive(false); battleTextPlayer.SetActive(false); } else if (this.buttonType == ButtonType.Move) { GameObject pokemonPlayer = GameObject.FindGameObjectWithTag("PlayerPokemon"); pokemon_controller pokemonScript = pokemonPlayer.GetComponent <pokemon_controller>(); move.useMove(pokemonScript.allyPokemon, pokemonScript.enemyPokemon, 0); //Enable Battle Text battleTextPlayer.SetActive(true); if (pokemonScript.allyPokemon.m_stats[6] <= 0) { battleCamera.SetActive(false); overworldCamera.SetActive(false); battleUI.SetActive(false); endCamera.SetActive(true); endUI.SetActive(true); //Show gameover } else if (pokemonScript.enemyPokemon.m_stats[6] <= 0) { pokemonScript.allyPokemon.m_experience += 40; pokemonScript.allyPokemon.checkLevelUp(); //Win UI showing exp gained //Ends battle Battle.defeatedPokemon++; battleCamera.SetActive(false); overworldCamera.SetActive(true); battleTextPlayer.SetActive(false); battleUI.SetActive(false); if (Battle.defeatedPokemon == 26) { Battle.winScreen.SetActive(true); overworldCamera.SetActive(false); } } //Random number to choose enemy attack int enemyMovePosistion = random.Next(1, 4); Move enemyMove = pokemonScript.enemyPokemon.m_moveList[enemyMovePosistion]; battleTextPlayer.GetComponentInChildren <Text>().text = pokemonScript.enemyPokemon.m_name + " has used " + pokemonScript.enemyPokemon.m_moveList[enemyMovePosistion].m_name; enemyMove.useMove(pokemonScript.allyPokemon, pokemonScript.enemyPokemon, 1); if (pokemonScript.allyPokemon.m_stats[6] <= 0) { battleCamera.SetActive(false); overworldCamera.SetActive(false); battleUI.SetActive(false); endCamera.SetActive(true); endUI.SetActive(true); //Show gameover } fightButtonContainer.gameObject.SetActive(true); moveButtonContainer.gameObject.SetActive(false); } //Gives Starter to Player if depending which pokemon they choose else if (this.buttonType == ButtonType.StarterFire) { GameObject player = GameObject.FindGameObjectWithTag("Player"); player_controller script = player.GetComponent <player_controller>(); script.starter = Battle.starters[0]; starterButtonContainer.SetActive(false); starterCamera.SetActive(false); overworldCamera.SetActive(true); } else if (this.buttonType == ButtonType.StarterWater) { GameObject player = GameObject.FindGameObjectWithTag("Player"); player_controller script = player.GetComponent <player_controller>(); script.starter = Battle.starters[1]; starterButtonContainer.SetActive(false); starterCamera.SetActive(false); overworldCamera.SetActive(true); } else if (this.buttonType == ButtonType.StarterGrass) { GameObject player = GameObject.FindGameObjectWithTag("Player"); player_controller script = player.GetComponent <player_controller>(); script.starter = Battle.starters[2]; starterButtonContainer.SetActive(false); starterCamera.SetActive(false); overworldCamera.SetActive(true); } else if (this.buttonType == ButtonType.Quit) { Application.Quit(); } else if (this.buttonType == ButtonType.Pause) { if (isPaused) { pauseUI.SetActive(false); nonPauseUI.SetActive(true); nonPauseCamera.SetActive(true); Time.timeScale = 1f; this.GetComponentInChildren <Text>().text = "Pause"; isPaused = false; } else { pauseUI.SetActive(true); nonPauseUI.SetActive(false); nonPauseCamera.SetActive(false); this.GetComponentInChildren <Text>().text = "Resume"; Time.timeScale = 0f; isPaused = true; } } }
// Start is called before the first frame update void Start() { pokemon = GameObject.FindGameObjectWithTag(name); script = pokemon.GetComponent <pokemon_controller>(); }
public void startBattle() { //Change starter to actual pokemon battleCamera.SetActive(true); overworldCamera.SetActive(false); battleUI.SetActive(true); //Changing starterpokemon to GameObject GameObject player = GameObject.FindGameObjectWithTag("Player"); player_controller script = player.GetComponent <player_controller>(); GameObject Playerpokemon = GameObject.FindGameObjectWithTag("PlayerPokemon"); pokemon_controller pokemonScript = Playerpokemon.GetComponent <pokemon_controller>(); Playerpokemon.GetComponent <Image>().overrideSprite = script.starter.m_sprite; pokemonScript.name = script.starter.m_name; pokemonScript.level = script.starter.m_level; pokemonScript.stats = script.starter.m_stats; pokemonScript.experience = script.starter.m_experience; pokemonScript.maxExperience = script.starter.m_maxExperience; pokemonScript.moveList = script.starter.m_moveList; pokemonScript.type = script.starter.m_type; //Changing Enemy to GameObject //Checks what wave it is depending on the wave it changes the enemy EnemyPokemon enemyPokemon = new EnemyPokemon(); //Wave 1 //Pokemon Level 20-25 //Types Normal, Bug, and Fighting if (defeatedPokemon < 5) { wave = 1; int choosePokemon = random.Next(1, 4); int lvl = random.Next(20, 26); if (choosePokemon == 1) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[30], moveList[31] }, new Type(Type.type.Bug), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Wormy", battle_controller.pokemonStaticSprites[3]); } else if (choosePokemon == 2) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[21], moveList[20] }, new Type(Type.type.Fighting), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Fighter Joe", battle_controller.pokemonStaticSprites[4]); } else if (choosePokemon == 3) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[36], moveList[37] }, new Type(Type.type.Normal), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Sciuridae", battle_controller.pokemonStaticSprites[5]); } } //Wave 2 //Pokemon Level 25-30 //Types Rock, Steel, and Ground else if (defeatedPokemon < 10 && defeatedPokemon >= 5) { wave = 2; if (defeatedPokemon == 5 && startWave) { pokemonScript.stats[6] = pokemonScript.stats[0]; for (int i = 0; i < 7; i++) { pokemonScript.stats[i] += 10; } pokemonScript.allyPokemon.m_experience += 100; pokemonScript.allyPokemon.checkLevelUp(); startWave = false; } int choosePokemon = random.Next(1, 4); int lvl = random.Next(25, 31); if (choosePokemon == 1) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[28], moveList[29] }, new Type(Type.type.Rock), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Rock Man", battle_controller.pokemonStaticSprites[6]); } else if (choosePokemon == 2) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[34], moveList[35] }, new Type(Type.type.Steel), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Roboto", battle_controller.pokemonStaticSprites[7]); } else if (choosePokemon == 3) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[26], moveList[27] }, new Type(Type.type.Ground), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Agent Turtle", battle_controller.pokemonStaticSprites[8]); } } //Wave 3 //Pokemon Level 30-35 //Types Ice, Electric, and Flying else if (defeatedPokemon < 15 && defeatedPokemon >= 10) { wave = 3; if (defeatedPokemon == 10 && !startWave) { pokemonScript.stats[6] = pokemonScript.stats[0]; for (int i = 0; i < 7; i++) { pokemonScript.stats[i] += 10; } pokemonScript.allyPokemon.m_experience += 100; pokemonScript.allyPokemon.checkLevelUp(); startWave = true; } int choosePokemon = random.Next(1, 4); int lvl = random.Next(30, 36); if (choosePokemon == 1) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[12], moveList[13] }, new Type(Type.type.Ice), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Icy King", battle_controller.pokemonStaticSprites[9]); } else if (choosePokemon == 2) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[7], moveList[8] }, new Type(Type.type.Electric), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Batteroid", battle_controller.pokemonStaticSprites[10]); } else if (choosePokemon == 3) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[22], moveList[23] }, new Type(Type.type.Flying), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Porkeet", battle_controller.pokemonStaticSprites[11]); } } //Wave 4 //Pokemon Level 35-40 //Types Ghost, Dark, and Poison else if (defeatedPokemon < 20 && defeatedPokemon >= 15) { wave = 4; if (defeatedPokemon == 15 && startWave) { pokemonScript.stats[6] = pokemonScript.stats[0]; for (int i = 0; i < 7; i++) { pokemonScript.stats[i] += 10; } pokemonScript.allyPokemon.m_experience += 100; pokemonScript.allyPokemon.checkLevelUp(); startWave = false; } int choosePokemon = random.Next(1, 4); int lvl = random.Next(35, 41); if (choosePokemon == 1) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[32], moveList[33] }, new Type(Type.type.Ghost), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Tablooo", battle_controller.pokemonStaticSprites[12]); } else if (choosePokemon == 2) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[16], moveList[17] }, new Type(Type.type.Dark), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Dark Wizard", battle_controller.pokemonStaticSprites[13]); } else if (choosePokemon == 3) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[24], moveList[25] }, new Type(Type.type.Poison), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Aranid", battle_controller.pokemonStaticSprites[14]); } } //Wave 5 //Pokemon Level 40-45 //Types Fairy and Psychic else if (defeatedPokemon < 25 && defeatedPokemon >= 20) { wave = 5; if (defeatedPokemon == 20 && !startWave) { pokemonScript.stats[6] = pokemonScript.stats[0]; for (int i = 0; i < 7; i++) { pokemonScript.stats[i] += 10; } pokemonScript.allyPokemon.m_experience += 100; pokemonScript.allyPokemon.checkLevelUp(); startWave = true; } int choosePokemon = random.Next(1, 3); int lvl = random.Next(40, 46); if (choosePokemon == 1) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[18], moveList[19] }, new Type(Type.type.Fairy), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Cuppy", battle_controller.pokemonStaticSprites[15]); } else if (choosePokemon == 2) { enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[10], moveList[11] }, new Type(Type.type.Psychic), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Monka", battle_controller.pokemonStaticSprites[16]); } } //Wave 6 //Pokemon Level 50 //Types Dragon else if (defeatedPokemon == 25) { wave = 6; if (defeatedPokemon == 25 && startWave) { pokemonScript.stats[6] = pokemonScript.stats[0]; for (int i = 0; i < 7; i++) { pokemonScript.stats[i] += 10; } pokemonScript.allyPokemon.m_experience += 100; pokemonScript.allyPokemon.checkLevelUp(); startWave = false; } int lvl = 60; enemyPokemon = new EnemyPokemon(new Move[] { moveList[0], moveList[1], moveList[14], moveList[15] }, new Type(Type.type.Dragon), new int[] { lvl * 4, lvl * 2 - 10, lvl * 2, lvl * 2 - 10, lvl * 2, lvl * 2, lvl * 4 }, lvl, "Kaito Dragoon", battle_controller.pokemonStaticSprites[17]); } //Win GameScreen //otherwaves GameObject Enemypokemon = GameObject.FindGameObjectWithTag("EnemyPokemon"); pokemon_controller enemyPokemonScript = Enemypokemon.GetComponent <pokemon_controller>(); Enemypokemon.GetComponent <Image>().overrideSprite = enemyPokemon.m_sprite; enemyPokemonScript.name = enemyPokemon.m_name; enemyPokemonScript.level = enemyPokemon.m_level; enemyPokemonScript.stats = enemyPokemon.m_stats; enemyPokemonScript.moveList = enemyPokemon.m_moveList; enemyPokemonScript.type = enemyPokemon.m_type; pokemonScript.allyPokemon = script.starter; pokemonScript.enemyPokemon = enemyPokemon; }