/* Veidoja: Roberts Onzuls, Edgars Katajevs Grupa: 110 Praktiskais darbs: C# RPG spēle Izmantotais compiler: www.onlinegdb.com (C# .NET) */ using System; namespace RPGSpele { abstract class Instrumenti { protected double _dmg; protected string _rarity = ""; } abstract class Magic : Instrumenti { protected int _cooldown; protected string _Mname = ""; protected int _mpc; public string GetName() { return _Mname; } public int GetMPC() { return _mpc; } public double GetDMG() { return _dmg; } } class Fire_Magic : Magic { private int _Fradius; private int _Fduration; private double _dps; public Fire_Magic(string name, string rar, int cd, int mpc, int radius, double dmg, int dur, double dps) { _Mname = name; _rarity = rar; _cooldown = cd; _mpc = mpc; _Fradius = radius; _dmg = dmg; _Fduration = dur; _dps = dps; } } class Lightning_Magic : Magic { private int _Lradius; private int _Lduration; public Lightning_Magic(string name, string rar, int cd, int mpc, int radius, double dmg, int dur) { _Mname = name; _rarity = rar; _cooldown = cd; _mpc = mpc; _Lradius = radius; _dmg = dmg; _Lduration = dur; } } /* class Magic { private string _magicName; private int _cooldown; private int _mpc; //magic point cost private int _radius; private double _dmg; public Magic(string name, int cd, int mpc, int radius, double dmg) { _magicName = name; _cooldown = cd; _mpc = mpc; _radius = radius; _dmg = dmg; } public string GetName() { return _magicName; } public int GetMPC() { return _mpc; } public double GetDMG() { return _dmg; } } */ class Wizard { private string _name; private double _hp; private int _mp; private double _defence; private int _level; public Wizard(string name, double hp, int mp, double def, int lvl) { _name = name; _hp = hp; _mp = mp; _defence = def; _level = lvl; } public void CastMagic(Wizard target, Magic spell) { Console.WriteLine(this._name + " izmanto " + spell.GetName() + " uz " + target._name); if (this._mp >= spell.GetMPC()) { double damageDealt = spell.GetDMG() * (target._defence / 100.0); this._mp -= spell.GetMPC(); target._hp -= damageDealt; Console.WriteLine("Rezultats: " + damageDealt.ToString("F2") + " bojājumi nodarīti."); Console.WriteLine(target._name + " HP tagad: " + target._hp.ToString("F2")); SpecialEffect(this, target, spell); } else { Console.WriteLine("Kļūda: " + this._name + "Nepietiek MP!"); } Console.WriteLine("--------------------------------------"); } public void SpecialEffect(Wizard caster, Wizard enemy, Magic spell) { } public void Dati() { Console.WriteLine("Tēls: " + _name + " | HP: " + _hp + " | MP: " + _mp); } } class Program { static void Main(string[] args) { Wizard w1 = new Wizard("Wizard", 190.0, 100, 69.0, 1); Wizard w2 = new Wizard("Electro Wizard", 150.0, 80, 67.0, 1); Fire_Magic fireball = new Fire_Magic("Fireball", "Rare", 10, 20, 4, 22.0, 3, 4.0); Lightning_Magic lightning = new Lightning_Magic("Lightning", "Epic", 12, 24, 1, 45.0, 5); Console.WriteLine("=== RPG SIMULACIJA ==="); w1.Dati(); w2.Dati(); Console.WriteLine("--------------------------------------"); Console.WriteLine("Nospiediet Enter lai uzsāktu simulaciju"); Console.ReadKey(); w1.CastMagic(w2, fireball); w2.CastMagic(w1, lightning); Console.WriteLine("Simulācija pabeigta. Nospiediet Enter..."); Console.ReadKey(); } } }