using System; using System.Collections.Generic; using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; namespace RPGspele_st.db { public class Player { public string name; public int MP; public int HP; public int DMG; public float WS; // WS-Walkspeed public Player(string name, int MP, int HP, int DMG, float WS) { //pl - player this.name = name; this.MP = MP; this.HP = HP; this.DMG = DMG; this.WS = WS; } // 1.metode 1.speletaja uzbrukums uz otru speletaju /*static void speletajauzbrukums(Player player1, Player player2, Magic magic1) { if (player1.MP >= magic1.MPC) { player2.HP = player2.HP - magic1.DMG; player1.MP = player1.MP - magic1.MPC; } } // 2.metode 2.speletaja uzbrukums uz pirmo speletaju static void speletaja2uzbrukums(Player player1, Player player2, Magic magic2) { if (player2.MP >= magic2.MPC) { player1.HP = player1.HP - magic2.DMG; player1.MP = player1.MP - magic2.MPC; } }*/ } public interface IUzbrukums { void Battle1(Player speletajs, Player speletajs2, Toxic tx, Lighting lg); } public class Player1_Action : IUzbrukums { public void Battle1(Player speletajs1,Player speletajs2, Toxic tx, Lighting lg) { Console.WriteLine($"{speletajs1.name} HP: {speletajs1.HP} MP: {speletajs1.MP}"); Console.WriteLine($"Izvelies magic spell 1: {tx.name} vai 2: {lg.name} (Uzraksti ievade cipparu!!)"); int izvele = Convert.ToInt32(Console.ReadLine()); if (izvele == 1) { Console.WriteLine($"Speletajs: {speletajs1.name} uzbruk uz speletaja {speletajs2.name}"); Console.WriteLine($"Speletaja: {speletajs2.name} HP pirms uzbrukuma ir {speletajs2.HP}"); tx.SpecialEffect(speletajs2); } if (izvele == 2) { Console.WriteLine($"Speletajs: {speletajs1.name} uzbruk uz speletaja {speletajs2.name}"); Console.WriteLine($"Speletaja: {speletajs2.name} HP pirms uzbrukuma ir {speletajs2.HP}"); lg.SpecialEffect(speletajs2); } } } public abstract class Magic { public int MPC; // MPC = magic point cost public abstract void SpecialEffect(Player speletajs); } public class Toxic : Magic { public string name; public int Poison_DMG; public int Poison_duration; public int CD; // CD = cooldown public int R;//R=radius public int MPC; //MPC-Magic point cost public Toxic(string name, int Poison_DMG, int Poison_duration, int CD, int R, int MPC) { this.name = name; this.Poison_DMG = Poison_DMG; this.Poison_duration = Poison_duration; this.CD = CD; this.R = R; this.MPC = MPC; } public override void SpecialEffect(Player speletajs) { for (int i = Poison_duration; i > 0; i--) { speletajs.HP -= Poison_DMG; Console.WriteLine($"Speletajs: {speletajs.name} sanema Poison_DMG: {Poison_DMG}! Vel ilgs {i} sekundes Tagadnejais Player HP: {speletajs.HP}"); System.Threading.Thread.Sleep(1000); } } } public class Lighting : Magic { public string name; public int Lighting_DMG; public int stun; public int CD; public int R; public int MPC; public Lighting(string name, int Lighting_DMG, int stun, int CD, int R, int MPC) { this.name = name; this.Lighting_DMG = Lighting_DMG; this.stun = stun; this.CD = CD; this.R = R; this.MPC = MPC; } public override void SpecialEffect(Player speletajs) { speletajs.HP -= Lighting_DMG; speletajs.MP -= MPC; Console.WriteLine($"Speletajs: {speletajs.name} sanema Lighting_DMG: {Lighting_DMG}! Tagadnejais HP: {speletajs.HP}"); for (int i = stun; i > 0; i--) { Console.WriteLine($"Speletajs: {speletajs.name} ir vel nekustams {i} sekundes"); System.Threading.Thread.Sleep(1000); } } } public class Program { public static void Main(string[] args) { Player[] player = { new Player("kokorng", 150, 150, 75, 0.5f), new Player("Miguzins", 200, 100, 50, 1.5f), new Player("Burgers",100,100,50, 1f), new Player("Zviedris",100,100,50, 1f), new Player("Renars",100,100,50, 1f), new Player("Katajevs", 100, 100, 50, 1f) }; while (true) { for (int i = 0; i < player.Length; i++) { Console.WriteLine($"{i}. "+player[i].name+$" HP: {player[i].HP} MP: {player[i].MP}"); } Console.WriteLine("Ievadi ciparu no 0 lidz 5"); int ievads1 = Convert.ToInt32(Console.ReadLine()); int ievads2 = Convert.ToInt32(Console.ReadLine()); if(ievads2== ievads1) { Console.WriteLine("Nedrikst uzbrukt pasam sev!!!"); System.Threading.Thread.Sleep(1000); Console.Clear(); continue; } // speletaju parametru piešķiršana // Player player1 = new Player("kokorng", 150, 150, 75, 0.5f); //Player player2 = new Player("Miguzins", 200, 100, 50, 1.5f); Toxic Toxic1 = new Toxic("Toxic_splash", 25, 3, 3, 36, 36); Lighting Lighting1 = new Lighting("Lighting_strike", 37, 5, 4, 15, 50); Player1_Action player1_Action = new Player1_Action(); player1_Action.Battle1(player[ievads1], player[ievads2], Toxic1, Lighting1); Console.WriteLine(); player1_Action.Battle1(player[ievads2], player[ievads1], Toxic1, Lighting1); // Toxic1.SpecialEffect(player1); Console.WriteLine(); //Lighting1.SpecialEffect(player2); System.Threading.Thread.Sleep(1000); Console.Clear(); } } } }