/* ========================================================================== * Project Name: Atzimess darbs * Apraksts: CS GO 2 spele veidota konsole parasta simulacija un vienkarsota versija cs go 2 * Autors: Andrejs Šorecs * Grupa: 110 * Datums: 14.05.2026 * Versija: 1.0 * ========================================================================== */ using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; namespace atzimes_darbs { public class Player { // speletaji public string name { get; set; } public int HP { get; set; } public Player(string name, int HP) { this.name = name; this.HP = HP; } } public class Gun { // Abstrakta klase ieroci public int ammo { get; private set; } public string name { get; private set; } public int dmg { get; private set; } public double fire_rate { get; private set; } public double reload_time { get; private set; } public int magazine { get; private set; } 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 GunAction(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++) { if (speletaji.HP <= 0 || misscount >= 3) { return; } int shot = rnd.Next(1, 3); Console.WriteLine("===1 vai 2==="); int rnd_input = Convert.ToInt32(Console.ReadLine()); if (shot == rnd_input) // ja trapija { Console.WriteLine("Trapijaa!!!");//debug Console.Write($"{speletaji.name} HP:{speletaji.HP} - {gun.dmg} = "); speletaji.HP -= gun.dmg; if(speletaji.HP<=0) speletaji.HP = 0; Console.WriteLine($"{speletaji.name} HP:{speletaji.HP}"); Console.WriteLine(); System.Threading.Thread.Sleep(fire_rate2); // gaida tik ilgi kamer vares saut nakosa lode if (speletaji.HP < 0) // ja speletajam ir HP mazaks pa 0 vins ir miris { Console.WriteLine("Player Dead!");//debug return; } } else// cits gadijums { Console.WriteLine("miss!!!");//debug misscount++; Console.WriteLine($"Tu noskeleji {misscount}. reizes");//debug 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");//mini debug return; } System.Threading.Thread.Sleep(fire_rate2); } } if (speletaji.HP > 0 && misscount < 3) { Console.WriteLine("reload!!!"); // mini debug System.Threading.Thread.Sleep(reload_time); } } } } 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) }; Console.WriteLine("=====CS:GO 2(console prototype)====="); Console.WriteLine("Sveiks, tas ir CS GO 2 spele konsolee, ja tu spele pirmo reizi izlasi noteikumus"); System.Threading.Thread.Sleep(5000); Console.Clear(); bool gamerun = true; while (gamerun) { Console.WriteLine("=====CS:GO 2(console prototype)====="); Console.WriteLine("1. Start Game"); Console.WriteLine("2. Read Rule"); Console.WriteLine("3. Exit"); int user_input = Convert.ToInt32 (Console.ReadLine()); switch (user_input) { case 1: Console.WriteLine($"Izvelies ieroci kuru gribi izmantot\n"); for (int i = 0; i < ieroci.Length; i++) { Console.WriteLine($"{i}.{ieroci[i].name} "); } int gun_input = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Tagad otrs speletajs izvelas ieroci"); Console.WriteLine($"Izvelies ieroci kuru gribi izmantot\n"); for (int i = 0; i < ieroci.Length; i++) { Console.WriteLine($"{i}.{ieroci[i].name} "); } int gun_input2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine($"====={speletaji[0].name} sak gajienu====="); Gun.GunAction(speletaji[0], ieroci[gun_input]); Console.WriteLine($"====={speletaji[1].name} sak gajienu====="); Gun.GunAction(speletaji[1], ieroci[gun_input2]); break; case 2: Console.WriteLine("Noteikumi: bla bla bla!!!"); System.Threading.Thread.Sleep(5000); Console.Clear(); break; case 3: gamerun = false; break; } } Console.ReadKey(); } } }