private static void Main(string[] args) { Pokemon pokemon1 = PokemonFactory.Create(args[0]); Pokemon pokemon2 = PokemonFactory.Create(args[1]); pokemon1.Attack(pokemon2); pokemon1.Attack(pokemon2); Console.WriteLine(pokemon1.CurrentHp); Console.WriteLine(pokemon2.CurrentHp); }
//Assigned to the different Atack moves in the canvas, Run when one of those buttons is pressed. public void OnAttackButton() { if (state == BattleState.PLAYERTURN) { playerPokemon.Attack(enemyPokemon); enemyHealtbar.value = enemyPokemon.hp; if (enemyPokemon.hp > 0) { state = BattleState.ENEMYTURN; StartCoroutine(Enemyturn()); } else { state = BattleState.WON; StartCoroutine(BattleOver()); } } else { return; } }
//The enemyes turn..Lots of text, apply dmg to the player, and change state/ method denpending on the outcome. IEnumerator Enemyturn() { yield return(PlayerAttackText()); dialogText.text = "Enemy Turn.."; yield return(new WaitForSeconds(1f)); //store the dmg value in an int, to display + damages the player. int damage = enemyPokemon.Attack(playerPokemon); dialogText.text = enemyPokemon.name + " Used " + enemyPokemon.moves[Random.Range(0, enemyPokemon.moves.Count)].name + " for " + damage + " DMG"; playerHealthbar.value = playerPokemon.hp; yield return(new WaitForSeconds(2f)); //if player is still alive set the game to players turn if (playerPokemon.hp > 0) { state = BattleState.PLAYERTURN; PlayerTurn(); } else { //if player is <=0 set state to 0 and start battleOver coroutine. state = BattleState.LOSS; StartCoroutine(BattleOver()); } }
private static void Main(string[] args) { Pokemon pokemon1 = new Pokemon(); Pokemon pokemon2 = new Pokemon(); pokemon1.DisplayInfo(); pokemon2.Attack(pokemon1); pokemon1.DisplayInfo(); }
private void pokemon2Label_Click(object sender, EventArgs e) { pokemon1.Attack(pokemon2); Render(); if (pokemon2.Hp == 0) { gameTimer.Enabled = false; MessageBox.Show("恭喜你打贏" + pokemon2.Name); } }
private void gymTimer_Tick(object sender, EventArgs e) { pokemon1.Attack(pokemon2); this.pokemon2HpLabel.Text = "HP: " + pokemon2.CurrentHP.ToString(); if (pokemon2.CurrentHP <= 0) { MessageBox.Show("很可惜,挑戰失敗"); gymTimer.Enabled = false; } }
private static void Main(string[] args) { Pokemon p1 = PokemonFactory.Generate(); Pokemon p2 = PokemonFactory.Generate(); Console.WriteLine("P1攻擊P2前:"); Console.WriteLine(p1); Console.WriteLine(p2); p1.Attack(p2); Console.WriteLine("P1攻擊P2後:"); Console.WriteLine(p1); Console.WriteLine(p2); }
private void baceAttack_Click(object sender, EventArgs e) { player.Attack(pokemon); pokemon.CurrentHP -= 2; this.pokemonHpLabel.Text = "HP: " + pokemon.CurrentHP + "/" + pokemon.HP; pokemon.Attack(player); this.playerHpLabel.Text = "HP: " + player.CurrentHP.ToString() + "/" + player.HP; if (player.attackType == AttackType.BACE) { FirstorderAttack.Visible = false; SecondorderAttack.Visible = false; FinalorderAttack.Visible = false; } else if (player.attackType == AttackType.FIRST) { FirstorderAttack.Visible = true; SecondorderAttack.Visible = false; FinalorderAttack.Visible = false; } else if (player.attackType == AttackType.SECOND) { FirstorderAttack.Visible = true; SecondorderAttack.Visible = true; FinalorderAttack.Visible = false; } if (pokemon.CurrentHP <= 0 || player.CurrentHP <= 0) { if (player.CurrentHP > pokemon.CurrentHP) { MessageBox.Show("恭喜你戰勝" + pokemon.Name); } else { MessageBox.Show("很可惜,挑戰失敗"); } } }
static void Main(string[] args) { Pokemon pikachu = new Pokemon("Pikachu", "An electrical pokemon", 15, 10, 50, PokemonType.Electric); Pokemon raichu = new Pokemon("Raichu", "Another electrical pokemon", 8, 5, 20, PokemonType.Fire); Console.WriteLine(pikachu.ToString()); pikachu.Fight(); pikachu.Attack(); pikachu.Train(Training.Attack); pikachu.Attack(); pikachu.EndFight(); pikachu.Train(Training.Health); pikachu.Evolve(raichu); Digimon agumon = new Digimon("Agumon", "A rookie digimon", 20, 8, 40, DigimonFamily.DragonsRoar); Digimon devimon = new Digimon("Devimon", "A Fallen Angel type Digimon", 15, 0, 10, DigimonFamily.NightmareSoldiers); Console.WriteLine(agumon.ToString()); agumon.Evolve(devimon); agumon.Fight(); pikachu.Fight(); Battle battle = new Battle(pikachu, agumon); battle.BattleStart(); }
private void pictureBox1_Click(object sender, EventArgs e) { pokemon2.Attack(pokemon1); this.hpLabel.Text = "HP: " + pokemon1.CurrentHP.ToString(); if (pokemon1.CurrentHP <= 0 || pokemon2.CurrentHP <= 0) { gymTimer.Enabled = false; if (pokemon2.CurrentHP > pokemon1.CurrentHP) { MessageBox.Show("恭喜你戰勝" + pokemon1.Name); } else { MessageBox.Show("很可惜,挑戰失敗"); } } }
public void AttackTest() { List <Move> charmenderMoves = new List <Move>(); charmenderMoves.Add(new Move("Ember")); charmenderMoves.Add(new Move("Fire Blast")); Pokemon charmender = new Pokemon("Charmender", 3, 52, 53, 39, Elements.Fire, charmenderMoves); List <Move> squirtleMoves = new List <Move>(); squirtleMoves.Add(new Move("Bubble")); squirtleMoves.Add(new Move("Bite")); Pokemon squirtle = new Pokemon("Squirtle", 2, 48, 65, 44, Elements.Water, squirtleMoves); int d1 = charmender.Attack(squirtle); int d2 = squirtle.Attack(charmender); Assert.AreEqual(d1, 0); Assert.AreEqual(d2, 33); }
private static void Main(string[] args) { int nationalNo1 = 1; int nationalNo2 = 1; if (args.Length == 2) { int.TryParse(args[0], out nationalNo1); int.TryParse(args[1], out nationalNo2); } else if (args.Length == 1) { int.TryParse(args[0], out nationalNo1); } else { Console.WriteLine("未輸入參數,用預設妙蛙種子對戰"); } Pokemon pokemon1 = PokemonFactory.Create(nationalNo1); Pokemon pokemon2 = PokemonFactory.Create(nationalNo2); pokemon1.Attack(pokemon2); }
private void pokemon2PictureBox_Click(object sender, EventArgs e) { pokemon1.Attack(pokemon2); Render(); }
private void gameTimer_Tick(object sender, EventArgs e) { pokemon2.Attack(pokemon1); Render(); }
private void pokemon1Label_Click(object sender, EventArgs e) { pokemon2.Attack(pokemon1); Render(); }
IEnumerator AttackSequence(Button button) { fightLoopOnGoing = true; StartCoroutine(TextTyper(actionText, (player.name + " used " + button.GetComponentInChildren <Text>().text + " and dealt " + player.Attack(enemy) + " damage to " + enemy.name).ToString())); UpdateHp(enemy); yield return(new WaitWhile(() => isTyping == true)); if (enemy.hp <= 0 && isTyping == false) { StartCoroutine(TextTyper(actionText, ("The wild " + enemy.name + " fainted").ToString())); yield return(new WaitWhile(() => isTyping == true)); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1); } StartCoroutine(TextTyper(actionText, (enemy.name + " used " + RandomEnemyAttack() + " and dealt " + enemy.Attack(player) + " damage to " + player.name).ToString())); UpdateHp(player); yield return(new WaitWhile(() => isTyping == true)); if (player.hp <= 0 && isTyping == false) { StartCoroutine(TextTyper(actionText, (player.name + " fainted" + "\nYou are out of Pokémon's").ToString())); yield return(new WaitWhile(() => isTyping == true)); player.Restore(); SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1); } yield return(new WaitWhile(() => isTyping == true)); StartCoroutine(TextTyper(actionText, ("Choose your next move").ToString())); yield return(new WaitWhile(() => isTyping == true)); fightLoopOnGoing = false; }