Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.38 KB | None | 0 0
  1. //Main.cs
  2. //Main program/loop
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6.  
  7. namespace LilMOO
  8. {
  9.     public class MainClass
  10.     {  
  11.         public static void Main (string[] args)
  12.         {
  13.             Random rand = new Random();
  14.            
  15.             World world = new World();
  16.             Console.WriteLine("\nNew 'World' has been created.\n");
  17.             Console.WriteLine("Creating 20 'Player's...");
  18.             string guid = null;
  19.             string loginName = null;
  20.             for (int i = 0; i < 20; i++) {
  21.                 guid = System.Guid.NewGuid().ToString();
  22.                 loginName = "Login" + rand.Next(11111,99999);
  23.                 world.players.Add(guid, new Player() { Name = loginName, ObjectGUID = guid });
  24.             }
  25.             Console.WriteLine("\nWho's on!?\n");
  26.             foreach (string key in world.players.Keys) {
  27.                 Console.WriteLine(world.players[key].Name + "\t:\t" + world.players[key].ObjectGUID);
  28.                 Console.WriteLine("Type\t\t:\t" + world.players[key].ObjectType);
  29.             }
  30.         }
  31.     }
  32. }
  33.  
  34.  
  35.  
  36.  
  37. //World.cs
  38. //A container object for everything in the world.
  39. //Also does a world setup and runs the world.
  40.  
  41. using System;
  42. using System.Collections.Generic;
  43.  
  44. namespace LilMOO
  45. {
  46.     public class World
  47.     {
  48.         public World ()
  49.         {
  50.         }
  51.        
  52.         public Dictionary<string, Player> players = new Dictionary<string, Player>();
  53.         public Dictionary<string, Room> rooms = new Dictionary<string, Room>();
  54.         public Dictionary<string, Npc> npcs = new Dictionary<string, Npc>();
  55.     }
  56. }
  57.  
  58.  
  59.  
  60.  
  61. //Root.cs
  62. //This is the root of all game objects.
  63. //Also includes object interfaces
  64.  
  65. using System;
  66.  
  67. namespace LilMOO
  68. {
  69.     public abstract class Root
  70.     {
  71.         public Root ()
  72.         {
  73.         }
  74.        
  75.         public EObjectType ObjectType { get; set; }
  76.        
  77.         public string ObjectGUID { get; set; } //unique identifier
  78.         public string Name { get; set; } //short description
  79.         public string Description { get; set; } //long description
  80.        
  81.         public virtual void Heartbeat() {
  82.             //this is object heartbeat, meant to be overridden in each object
  83.         }
  84.     }
  85.    
  86.     public enum EObjectType { PLAYER, NPC, ROOM };
  87. }
  88.  
  89.  
  90.  
  91.  
  92. //Mobile.cs
  93. //The mother of all Players and Npcs.
  94.  
  95. using System;
  96.  
  97. namespace LilMOO
  98. {
  99.     public class Mobile : Root
  100.     {
  101.         public Mobile ()
  102.         {
  103.         }
  104.        
  105.         //Stats
  106.         public byte Strength { get; set; }
  107.         public byte Dexterity { get; set; }
  108.         public byte Constitution { get; set; }
  109.         public byte Intelligence { get; set; }
  110.         public byte Wisdom { get; set; }
  111.        
  112.         //HAM properties. (Health, Action, Mana)
  113.         public int Health { get; set; }
  114.         public int MaxHealth { get; set; }
  115.         public int Mana { get; set; }
  116.         public int MaxMana { get; set; }
  117.         public int Action { get; set; }
  118.         public int MaxAction { get; set; }
  119.        
  120.         //Other properties...
  121.         public long Experience { get; private set; } //experience is read-only, add AddExperience()/RemExperience() functions for admin changes
  122.         public int Level { get; set; }
  123.     }
  124. }
  125.  
  126.  
  127.  
  128.  
  129. //Player.cs
  130. //The Player class.
  131.  
  132. using System;
  133.  
  134. namespace LilMOO
  135. {
  136.     public class Player : Mobile
  137.     {
  138.         public Player ()
  139.         {
  140.             this.ObjectType = EObjectType.PLAYER;
  141.         }
  142.     }
  143. }
  144.  
  145.  
  146.  
  147.  
  148. //Npc.cs
  149. //Defines all those silly nonplayer characters
  150.  
  151. using System;
  152.  
  153. namespace LilMOO
  154. {
  155.     public class Npc : Mobile
  156.     {
  157.         public Npc ()
  158.         {
  159.             this.ObjectType = EObjectType.NPC;
  160.         }
  161.     }
  162. }
  163.  
  164.  
  165.  
  166.  
  167. //Room.cs
  168. //The mother of all rooms in the world.
  169.  
  170. using System;
  171.  
  172. namespace LilMOO
  173. {
  174.     public class Room : Root
  175.     {
  176.         public Room ()
  177.         {
  178.             this.ObjectType = EObjectType.ROOM;
  179.         }
  180.     }
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement