Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Main.cs
- //Main program/loop
- using System;
- using System.Collections.Generic;
- namespace LilMOO
- {
- public class MainClass
- {
- public static void Main (string[] args)
- {
- Random rand = new Random();
- World world = new World();
- Console.WriteLine("\nNew 'World' has been created.\n");
- Console.WriteLine("Creating 20 'Player's...");
- string guid = null;
- string loginName = null;
- for (int i = 0; i < 20; i++) {
- guid = System.Guid.NewGuid().ToString();
- loginName = "Login" + rand.Next(11111,99999);
- world.players.Add(guid, new Player() { Name = loginName, ObjectGUID = guid });
- }
- Console.WriteLine("\nWho's on!?\n");
- foreach (string key in world.players.Keys) {
- Console.WriteLine(world.players[key].Name + "\t:\t" + world.players[key].ObjectGUID);
- Console.WriteLine("Type\t\t:\t" + world.players[key].ObjectType);
- }
- }
- }
- }
- //World.cs
- //A container object for everything in the world.
- //Also does a world setup and runs the world.
- using System;
- using System.Collections.Generic;
- namespace LilMOO
- {
- public class World
- {
- public World ()
- {
- }
- public Dictionary<string, Player> players = new Dictionary<string, Player>();
- public Dictionary<string, Room> rooms = new Dictionary<string, Room>();
- public Dictionary<string, Npc> npcs = new Dictionary<string, Npc>();
- }
- }
- //Root.cs
- //This is the root of all game objects.
- //Also includes object interfaces
- using System;
- namespace LilMOO
- {
- public abstract class Root
- {
- public Root ()
- {
- }
- public EObjectType ObjectType { get; set; }
- public string ObjectGUID { get; set; } //unique identifier
- public string Name { get; set; } //short description
- public string Description { get; set; } //long description
- public virtual void Heartbeat() {
- //this is object heartbeat, meant to be overridden in each object
- }
- }
- public enum EObjectType { PLAYER, NPC, ROOM };
- }
- //Mobile.cs
- //The mother of all Players and Npcs.
- using System;
- namespace LilMOO
- {
- public class Mobile : Root
- {
- public Mobile ()
- {
- }
- //Stats
- public byte Strength { get; set; }
- public byte Dexterity { get; set; }
- public byte Constitution { get; set; }
- public byte Intelligence { get; set; }
- public byte Wisdom { get; set; }
- //HAM properties. (Health, Action, Mana)
- public int Health { get; set; }
- public int MaxHealth { get; set; }
- public int Mana { get; set; }
- public int MaxMana { get; set; }
- public int Action { get; set; }
- public int MaxAction { get; set; }
- //Other properties...
- public long Experience { get; private set; } //experience is read-only, add AddExperience()/RemExperience() functions for admin changes
- public int Level { get; set; }
- }
- }
- //Player.cs
- //The Player class.
- using System;
- namespace LilMOO
- {
- public class Player : Mobile
- {
- public Player ()
- {
- this.ObjectType = EObjectType.PLAYER;
- }
- }
- }
- //Npc.cs
- //Defines all those silly nonplayer characters
- using System;
- namespace LilMOO
- {
- public class Npc : Mobile
- {
- public Npc ()
- {
- this.ObjectType = EObjectType.NPC;
- }
- }
- }
- //Room.cs
- //The mother of all rooms in the world.
- using System;
- namespace LilMOO
- {
- public class Room : Root
- {
- public Room ()
- {
- this.ObjectType = EObjectType.ROOM;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement