using System; using System.Collections.Generic; using System.Runtime.Remoting.Messaging; namespace Inherit { class Program { public static List Characters = new List(); // List of all characters (new characters are added to it in their constructor) static void Main(string[] args) { Fighter Warrior = new Fighter(); Fighter Rogue = new Fighter(); Mage Sage = new Mage(); Mage BattleMage = new Mage(); Console.ForegroundColor = ConsoleColor.DarkCyan; Console.WriteLine($"The AFK Inheritance.TestBed. Please press any button to Continue : ). . ."); Warrior.log(); Sage.log(); Rogue.log(); } } // starting character public class Character { // creating random potition... static Random r = new Random(); public int potitionX = r.Next(0, 8); public int potitionY = r.Next(0, 8); // creating random power... public static Random v = new Random(); public int power = v.Next(1, 11); // Constructor public Character() { Program.Characters.Add(this); } /// /// Find target based on bool StateIsAlive = true; public virtual void Die() { if (true) { StateIsAlive = false; Console.WriteLine("I am ded dude"); return; } } public virtual void Attack() { foreach (Character c in Program.Characters) { if (c == this) continue; if (c.potitionX == potitionX && c.potitionY == potitionY) // if any character is in the same exact potition as another character the character with most power stays alive { if (c.power < power) { Die(); } } } } public void Move(int dX, int dY) { while (true) { dX = r.Next(-1, 2); dY = r.Next(-1, 2); if (potitionX + dX < 0 || potitionY + dY < 0 || potitionX + dX > 7 || potitionY + dY > 7) { break; } potitionX += dX; potitionY += dY; } } } // Base characters... public class Fighter : Character { public virtual void log() { Console.WriteLine(""); } private void WarThirst() { if (potitionX == 4 && potitionY == 4) { power++; } return; } public override void Attack() { // ++ FIGHTER-SPECIFIC ATTACK STUFF BEFORE void Swing() { } // ++ BASE (aka CHARACTER)-SPECIFIC ATTACK STUFF base.Attack(); // ++ FIGHTER-SPECIFIC ATTACK STUFF AFTER } } public class Mage : Character { public void log() { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write($"\nSage says, : "); Console.ForegroundColor = ConsoleColor.Magenta; Console.Write("Hocus Pocus Focus. \n \n"); // placeholder temp spaces REMOVE ME IN THE FUTURE } } // Special character inheritance... public class Warrior : Fighter { public override void log() { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write("Fighter says, : "); Console.ForegroundColor = ConsoleColor.Magenta; Console.Write("I am the K-Night. "); } } public class Sage : Mage { } public class Rogue : Fighter { public void log() { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.Write($"\nRogue says, : "); Console.ForegroundColor = ConsoleColor.Magenta; Console.Write("Sneaky sneaky."); } } public class BattleMage : Mage { } }