public static void Attack(Mage hero, List <Hero> Enemies) { Buff = false; if (hero.Power < 15)//jesli mana mniejsza od 15 to regeneruje { hero.regenerate(); Buff = true; } else//jesli nie atakuje { if (Enemies.Count > 1)//jak jest wrogow iecej niz 1 { DMG = hero.Blizzard(); //to atakuje wszystkich Enemy = -1; //ustawia indeks wroga na -1 co oznacza, ze chodzi o wszystkich } else { int choice = rnd.Next(0, 101); if (choice % 2 == 0)//losowo wybiera atack { DMG = hero.lightningBolt(); } else { DMG = hero.fireBall(); } Enemy = 0; //wybiera pierwszego wroga poniewaz jest tylko jeden } Buff = false; //oznacza ze atakuje } }
private void mage_attack(Mage hero, bool fourthSkill)//tak samo tutaj oraz w przypadku priest_attack i archer_attack { if (fourthSkill) { hero.regenerate(); } else if (radioButton1.Checked) { DMG = hero.lightningBolt(); } else if (radioButton2.Checked) { DMG = hero.fireBall(); } else if (radioButton3.Checked) { DMG = hero.Blizzard(); //z tą różnicą, że tutaj Blizzard zadaje obrazenia wszystkim wrogom if (whichTeam) //jesli jest kolej przyjaciol { for (int i = 0; i < EnemyTeam.Count; i++) { EnemyTeam[i].healthChange(DMG);//wrogowie otrzymuja obrazenia } } else//jesli nie { for (int i = 0; i < AllyTeam.Count; i++) { AllyTeam[i].healthChange(DMG);//to przyjaciele otrzymuja } } //nizej jest zestaw metod które zostaną lepiej wyjaśnione niżej uncheck_buttons_and_markers(); damage_added_correctly = false; set(); check_dead(); if (ArenaGameProject.Menu.AllyWin | ArenaGameProject.Menu.EnemyWin) { Close(); } else { next_turn(); skill_check(); set_marker(); if (current._isAI) { bot_Attack(); } } } }
private void bot_Attack() //atak komputera { if (whichTeam) //jesli druzyna przyajciol { if (AllyTeam[currentAlly] is Warrior) //jesli warrior { AI_Attack.Attack((Warrior)current, EnemyTeam); //metoda losujaca/wybierajaca if (AI_Attack.Buff) //jesli nie byl to atak { Warrior tmp = (Warrior)AllyTeam[currentAlly]; //tutaj tak troche tmp.warShout(); //byle jak, uzywanie skilla, AllyTeam[currentAlly] = tmp; //oraz nowe przypisywanie do obecnie grajacej psotaci MessageBox.Show(current._Name + " used War Shout."); //wiadomosc pokazujaca co sie stalo } else//jesli to byl atack { EnemyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG);//odejmuje wybranemu wrogowi obliczone obrazenia MessageBox.Show(current._Name + " hit " + EnemyTeam[AI_Attack.Enemy]._Name + " for " + AI_Attack.DMG + " damage."); }//wiadomosc pokazujaca co sie stalo } if (AllyTeam[currentAlly] is Mage)//reszta na tej samej zasadzie { AI_Attack.Attack((Mage)current, EnemyTeam); if (AI_Attack.Buff) { Mage tmp = (Mage)AllyTeam[currentAlly]; tmp.regenerate(); AllyTeam[currentAlly] = tmp; MessageBox.Show(AllyTeam[currentAlly]._Name + " regenerated mana."); } else { if (AI_Attack.Enemy != -1) { EnemyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " hit " + EnemyTeam[AI_Attack.Enemy]._Name + " for " + DMG + " damage."); } else//z tym wyjatkiem, ze jesli indeks wroga jest -1 to jest uzywany blizzard {//na wszystkich wrogow for (int i = 0; i < EnemyTeam.Count; i++) { EnemyTeam[i].healthChange(AI_Attack.DMG); } MessageBox.Show(current._Name + " used Blizzard and hit every enemy for " + AI_Attack.DMG + " damage."); } } } if (AllyTeam[currentAlly] is Archer) { AI_Attack.Attack((Archer)current, EnemyTeam); EnemyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " hit " + EnemyTeam[AI_Attack.Enemy]._Name + " for " + AI_Attack.DMG + " damage."); } if (AllyTeam[currentAlly] is Priest) { AI_Attack.Attack((Priest)current, AllyTeam, EnemyTeam); if (AI_Attack.Buff) { if (AI_Attack.Enemy == -1) {//tak samo jesli indeks jest na -1 to leczy samego sieibe AllyTeam[currentAlly].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " healed himself for " + (-AI_Attack.DMG)); } else//jesli nie jest na -1 ale nie jest to rowniez atak to leczy {//przyajciela o wskazanym indeksie AllyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " healed " + AllyTeam[AI_Attack.Enemy]._Name + " for " + (-AI_Attack.DMG)); } } else { EnemyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " hit " + EnemyTeam[AI_Attack.Enemy]._Name + " for " + DMG + " damage."); } } } else//tak samo dal druzyny wrogow { if (EnemyTeam[currentEnemy] is Warrior) { AI_Attack.Attack((Warrior)current, AllyTeam); if (AI_Attack.Buff) { Warrior tmp = (Warrior)EnemyTeam[currentEnemy]; tmp.warShout(); EnemyTeam[currentEnemy] = tmp; MessageBox.Show(current._Name + " used War Shout."); } else { AllyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " hit " + AllyTeam[AI_Attack.Enemy]._Name + " for " + AI_Attack.DMG + " damage."); } } if (EnemyTeam[currentEnemy] is Mage) { AI_Attack.Attack((Mage)current, AllyTeam); if (AI_Attack.Buff) { Mage tmp = (Mage)EnemyTeam[currentEnemy]; tmp.regenerate(); EnemyTeam[currentEnemy] = tmp; MessageBox.Show(EnemyTeam[currentEnemy]._Name + " regenerated mana."); } else { if (AI_Attack.Enemy != -1) { AllyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " hit " + AllyTeam[AI_Attack.Enemy]._Name + " for " + AI_Attack.DMG + " damage."); } else { for (int i = 0; i < AllyTeam.Count; i++) { AllyTeam[i].healthChange(AI_Attack.DMG); } MessageBox.Show(current._Name + " used Blizzard and hit every enemy for " + AI_Attack.DMG + " damage."); } } } if (EnemyTeam[currentEnemy] is Archer) { AI_Attack.Attack((Archer)current, AllyTeam); AllyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " hit " + AllyTeam[AI_Attack.Enemy]._Name + " for " + AI_Attack.DMG + " damage."); } if (EnemyTeam[currentEnemy] is Priest) { AI_Attack.Attack((Priest)current, EnemyTeam, AllyTeam); if (AI_Attack.Buff) { if (AI_Attack.Enemy == -1) { EnemyTeam[currentEnemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " healed himself for " + (-AI_Attack.DMG)); } else { EnemyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " healed " + EnemyTeam[AI_Attack.Enemy]._Name + " for " + (-AI_Attack.DMG)); } } else { AllyTeam[AI_Attack.Enemy].healthChange(AI_Attack.DMG); MessageBox.Show(current._Name + " hit " + AllyTeam[AI_Attack.Enemy]._Name + " for " + AI_Attack.DMG + " damage."); } } } uncheck_buttons_and_markers(); //i tutaj tak samo, odznaczanie damage_added_correctly = false; set(); //ustawianie paskow zyc i many check_dead(); //sprawdza czy ktos umarl if (ArenaGameProject.Menu.AllyWin | ArenaGameProject.Menu.EnemyWin) //sprawdza czy czy ktos wygrał czy nie { Close(); } else//poniewaz musi dokonczyc metode zamin zamknie Form'a, dlatego jest tu else { next_turn();//nastepna tura skill_check(); //ustawia skille, set_marker(); //ustawia znacznik if (current._isAI) { bot_Attack(); } } }