So, I am new to coding, not just AS3 and I have started over the past couple of days to try and achieve my dream of making a MultiUser Dungeon…or MUD. I want to start off simple though and create the base game for just a single player, then work on patching the engine into a server for multiplayer. So far, I have worked on two class files. An Exit Manager and a Locations Manager.
The Locations Manager is a class file that sets all the variables of the locations in the game, the Exits Manager is a class file that handles exit properties, commands and parsing of Exit information. I will post the two of them below. I was hoping I could get an idea from you if I am heading in the right direction and if there is any advice you can give.
First the Exits Manager:
package {
//Last Modification: July 07, 2014
public class Exit
{
// Numerical codes
static public var UNDEFINED:int = 0;
static public var NORTH:int = 1;
static public var SOUTH:int = 2;
static public var EAST:int = 3;
static public var WEST:int = 4;
static public var UP:int = 5;
static public var DOWN:int = 6;
static public var NORTHEAST:int = 7;
static public var NORTHWEST:int = 8;
static public var SOUTHEAST:int = 9;
static public var SOUTHWEST:int = 10;
static public var IN:int = 11;
static public var OUT:int = 12;
// String codes
var directionNames:Array = new Array("UNDEFINED","NORTH","SOUTH","EAST","WEST","UP","DOWN","NORTHEAST","NORTHWEST","SOUTHEAST","SOUTHWEST","IN","OUT");
var shortDirectionNames:Array = new Array("NULL","N","S","E","W","U","D","NE","NW","SE","SW","I","O");
//Member variables
private var m_leadsTo:Location = null;
private var m_direction:int;
//Full name of that direction
private var m_directionName:String;
//Short version of that direction
private var m_shortDirectionName:String;
//The Default constructor
public function Exit()
{
m_direction = Exit.UNDEFINED;
m_leadsTo = null;
m_directionName = directionNames[UNDEFINED];
m_shortDirectionName = shortDirectionNames[UNDEFINED];
}
//Full constructor
public function Exit(direction:int,Location,leadsTo)
{
m_direction = direction;
//Assign the direction names
if ((direction <= directionNames.length))
{
m_directionName = directionNames[m_direction];
}
if ((direction <= shortDirectionNames.length))
{
m_shortDirectionName = shortDirectionNames[m_direction];
}
//Assigning the location
m_leadsTo = leadsTo;
}
//toString method
public function toString()
{
return m_directionName;
}
//Assign Direction Names
public function setDirectionName(dirname:String):void
{
m_directionName = dirname;
}
//Return direction name
public function getDirectionName()
{
return m_directionName;
}
//Assign Short Direction Name
public function getShortDirectionName():String;
{
return m_shortDirectionName;
};
//Assign Location
public function setLeadsTo(Location,leadsTo):void
{
m_leadsTo = leadsTo;
}
//Returns Location
public function getLeadsTo():Location;
{
return m_leadsTo;
};
S;
}
}
Then the Locations Manager:
package {
//Last Modified: July 07, 2014
public class Location
{
private var _Name:String;
private var _Description:String;
private var _Inventory:Array;
private var _Exits:Vector;
//Initialization
public function Location(name:String,description:String)
{
_Name = name;
_Description = description;
_Inventory = new Array ;
_Exits = new Vector ;
}
//Get Location Name
public function getLocName():String
{
return _Name;
}
//Get Location Description
public function getLocDescription():String
{
return _Description;
}
//return inventory array
public function getLocInventory():Array;
{
return _Inventory;
};
//return location exits
public function getLocExits():Vector;
{
return _Exits;
}
}
};