Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C#-Quelltext |
|
1 2 |
ballbesitzA = MannschaftA.gesamtstaerke / (MannschaftA.gesamtstaerke + MannschaftB.gesamtstaerke); ballbesitzB = MannschaftB.gesamtstaerke / (MannschaftA.gesamtstaerke + MannschaftB.gesamtstaerke); |
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
//_prozent_offensive sind ie 30% Annahme public float Berechne_Bonus(float _prozent_offensive) { float bonus = ((_prozent_offensive * 2 * this.prozent_offensive / 100) - (_prozent_offensive)); //bsp 30% return bonus; } public float Berechne_Bonus_offensive(float _prozent_offensive) { float bonus = Berechne_Bonus(_prozent_offensive); float bonus_offensive = (bonus / 100) + 1; //bsp max 1.3; zum rechnen return bonus_offensive; } public float Berechne_Bonus_defensive(float _prozent_offensive) { float bonus = Berechne_Bonus(_prozent_offensive); float bonus_defensive = (-bonus / 100) + 1; //bsp 0.7; zum rechnen return bonus_defensive; } //Als Ergebnis kommt zum weiterrechnen max 1.3 und mind 0.7 raus |
C#-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
public void Berechnung_Ergebnis() { Random rnd = new Random(); float B_A_M = MannschaftB.gesamtstaerke_abwehr * MannschaftB.Berechne_Bonus_defensive(prozent_offensive) + MannschaftB.gesamtstaerke_mittelfeld; float A_M_S = MannschaftA.gesamtstaerke_sturm * MannschaftA.Berechne_Bonus_offensive(prozent_offensive) + MannschaftA.gesamtstaerke_mittelfeld; float B_M_S = MannschaftB.gesamtstaerke_mittelfeld + MannschaftB.gesamtstaerke_sturm * MannschaftB.Berechne_Bonus_offensive(prozent_offensive); float A_A_M = MannschaftA.gesamtstaerke_abwehr * MannschaftA.Berechne_Bonus_defensive(prozent_offensive) + MannschaftA.gesamtstaerke_mittelfeld; float A_S = MannschaftA.gesamtstaerke_sturm * MannschaftA.Berechne_Bonus_offensive(prozent_offensive); float B_S = MannschaftB.gesamtstaerke_sturm * MannschaftB.Berechne_Bonus_offensive(prozent_offensive); float A_T_A = MannschaftA.staerke_torwart + MannschaftA.gesamtstaerke_abwehr * MannschaftA.Berechne_Bonus_defensive(prozent_offensive); float B_T_A = MannschaftB.staerke_torwart + MannschaftB.gesamtstaerke_abwehr * MannschaftB.Berechne_Bonus_defensive(prozent_offensive); //Mannschaft A for (int i = 1; i <= 3; i++) { int random = rnd.Next(1, 10001); //Abwehr zum Mittelfeld if (i == 1) { float x = (A_A_M / (A_A_M + B_M_S)) * 10000; //bsp 55,43 daher nochmals *100, damit Kommastellen mit beachtet werden if (random > x*ballbesitzA) break; //Wenn nicht getroffen, dann break und raus aus schleife, Chance vorbei. } //Mittelfeld zum Sturm else if (i == 2) { float x = (A_M_S / (A_M_S + B_A_M)) * 10000; //bsp 55,43 daher nochmals *100, damit Kommastellen mit beachtet werden if (random > x * ballbesitzA) break; //Wenn nicht getroffen, dann break und raus aus schleife, Chance vorbei. } //Sturm, Tor: ja/nein; else { MannschaftA.torchancen += 1; float x = (A_S / (A_S + B_T_A)) * 10000; //bsp 55,43 daher nochmals *100, damit Kommastellen mit beachtet werden if (random <= x * ballbesitzA) MannschaftA.tore += 1; } } label_A_torchance.Text = MannschaftA.torchancen.ToString(); label_A_tore.Text = MannschaftA.tore.ToString(); //Mannschaft B for (int i = 1; i <= 3; i++) { int random = rnd.Next(1, 10001); //Abwehr zum Mittelfeld if (i == 1) { float x = (B_A_M / (B_A_M + A_M_S)) * 10000; //bsp 55,43 daher nochmals *100, damit Kommastellen mit beachtet werden if (random > x * ballbesitzB) break; //Wenn nicht getroffen, dann break und raus aus schleife, Chance vorbei. } //Mittelfeld zum Sturm else if (i == 2) { float x = (B_M_S / (B_M_S + A_A_M)) * 10000; //bsp 55,43 daher nochmals *100, damit Kommastellen mit beachtet werden if (random > x * ballbesitzB) break; //Wenn nicht getroffen, dann break und raus aus schleife, Chance vorbei. } //Sturm, Tor: ja/nein; else { MannschaftB.torchancen += 1; float x = (B_S / (B_S + A_T_A)) * 10000; //bsp 55,43 daher nochmals *100, damit Kommastellen mit beachtet werden if (random <= x * ballbesitzB) MannschaftB.tore += 1; } } label_B_torchance.Text = MannschaftB.torchancen.ToString(); label_B_tore.Text = MannschaftB.tore.ToString(); } |
Werbeanzeige