// Andrejs, Šorecs, 110, cs go spele konsole (prototips), spele cs go 2 kuru var kaut cik spelet konsole, 14-05-2026, Visual Studio 2022. using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; namespace atzimes_darbs { public class Player { // speletaji public string name; public int HP; public Player(string name, int HP) { this.name = name; this.HP = HP; } } public class Gun { // Abstrakta klase ieroci public int ammo; public string name; public int dmg; public double fire_rate; public double reload_time; public int magazine; public Gun(string name, int dmg, int ammo,int magazine,double reload_time, double fire_rate) { this.name = name; this.dmg = dmg; this.ammo = ammo; this.magazine = magazine; this.reload_time = reload_time; this.fire_rate = fire_rate; } public static void GunAcction(Player speletaji, Gun gun) { Random rnd = new Random(); int reload_time = Convert.ToInt32(gun.reload_time*1000); // parladesanas laiks double fire_rate = 1000 / (gun.fire_rate/60); // cik ilgi paiet kamer izsaus nakoso lodi int fire_rate2 = Convert.ToInt32(fire_rate); int misscount = 0; // magazina cikls for (int i = 0; i < gun.magazine; i++) { // lodes cikls for (int j = 0; j < gun.ammo; j++) { int shot = rnd.Next(1, 3); if (shot == 1) // ja trapija { if (speletaji.HP < 0) // ja speletajam ir HP mazaks pa 0 vins ir miris { Console.WriteLine("Player Dead!"); break; } else if (misscount >= 3) // ja speletajs vairak pa 3 reizem noskele tad sauj nakosais speletajs { Console.WriteLine("Tu pa daudz nošķelēji!!! Pretinieks sak uzbrukumu"); break; } else if (speletaji.HP > 0 || misscount < 3) { Console.WriteLine("Trapijaa!!!"); Console.Write($"{speletaji.name} HP:{speletaji.HP} - {gun.dmg} = "); speletaji.HP -= gun.dmg; Console.WriteLine($"{speletaji.name} HP:{speletaji.HP}"); Console.WriteLine(); System.Threading.Thread.Sleep(fire_rate2);// gaida tik ilgi kamer vares saut nakosa lode } } else if (speletaji.HP > 0 || misscount < 3)// cits gadijums { Console.WriteLine("miss!!!"); misscount++; Console.WriteLine($"Tu noskeleji {misscount}. reizes"); System.Threading.Thread.Sleep(fire_rate2); } } Console.WriteLine($"HP {speletaji.HP} un miss {misscount}"); if (speletaji.HP < 0 || misscount == 3) { break; } else if (speletaji.HP > 0 || misscount < 3) { Console.WriteLine("reload!!!"); System.Threading.Thread.Sleep(reload_time); } } Console.WriteLine("Cikls beidzas!!"); } } public class Program { static void Main(string[] args) { // speletaju masivs Player[] speletaji = { new Player("player1",100), new Player("player2",100), }; // ierocu masivs Gun[] ieroci = { new Gun("Desert_eagle",53,7,3,2.2,267) ,new Gun("AK-47",35,30,3,2.4,600) ,new Gun("M4A4",33,30,4,3.1,666) ,new Gun("AWP",115,5,3,3.7,41) ,new Gun("SSG08",88,10,2,3.7,48) ,new Gun("glock_18",24,20,3,2.3,400) ,new Gun("USP-S",35,12,2,2.2,352) }; for (int i = 0; i < ieroci.Length; i++) { Console.WriteLine($"{ieroci[i].name} {i}."); } for (int j = 0; j < speletaji.Length; j++) { Console.WriteLine($"{speletaji[j].name} {j}."); } /* Console.WriteLine("Ievadi kurs tu esi speletajs!!"); int speletaju_ievads = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Izvelies kuru ieroci tu nemsi!"); int ierocu_ievads = Convert.ToInt32(Console.ReadLine()); Gun.GunAcction(speletaji[speletaju_ievads], ieroci[ierocu_ievads] );*/ Console.WriteLine(); Gun.GunAcction(speletaji[0], ieroci[5]); Console.ReadKey(); } } }