MudEngine:
- GameWorld.AddRealm() method replaced with GameWorld.AddObject(). It accepts any Type passed to it. You can now supply a Zone to it (provided the Zone.Realm property is set first) and the method will add the Zone into the appropriate Realm for you. - Began converting certain enumerated items to LINQ MudGame: - Updated scripts to reflect the GameWorld changes.
This commit is contained in:
parent
c7d227745c
commit
ce910a5fd0
6 changed files with 59 additions and 6 deletions
|
@ -121,11 +121,62 @@ namespace MudEngine.GameManagement
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a object to the game world. Any Game Object can be supplied as a parameter.
|
||||
/// </summary>
|
||||
/// <param name="worldObject"></param>
|
||||
public Boolean AddObject(dynamic worldObject)
|
||||
{
|
||||
//Check if this object is a Realm
|
||||
if (worldObject is Realm)
|
||||
{
|
||||
///Add it to the Worlds Realm collection
|
||||
this.RealmCollection.Add(worldObject);
|
||||
}
|
||||
//Check if this object is a Zone
|
||||
else if (worldObject is Zone)
|
||||
{
|
||||
//Query the Realm collection to find the Realm this Zone belongs to.
|
||||
var realmQuery =
|
||||
from r in RealmCollection
|
||||
where r.Filename == worldObject.Realm
|
||||
select r;
|
||||
//Add the zone to the Realm we found
|
||||
if (realmQuery.FirstOrDefault() != null)
|
||||
realmQuery.FirstOrDefault().AddZone(worldObject);
|
||||
else
|
||||
{
|
||||
Log.Write("Error: Attempted to add Zone " + worldObject.Filename + " to a unspecified Realm.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (worldObject is Room)
|
||||
{
|
||||
var realmQuery =
|
||||
from r in RealmCollection
|
||||
where r.Filename == worldObject.Realm
|
||||
select r;
|
||||
var zoneQuery =
|
||||
from z in realmQuery.FirstOrDefault().ZoneCollection
|
||||
where z.Filename == worldObject.Zone
|
||||
select z;
|
||||
if (zoneQuery.FirstOrDefault() != null)
|
||||
zoneQuery.FirstOrDefault().AddRoom(worldObject);
|
||||
else
|
||||
{
|
||||
Log.Write("Error: Attempted to add Room " + worldObject.Filename + " to a unspecified Realm and/or Zone");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a Realm to the Games current list of Realms.
|
||||
/// </summary>
|
||||
/// <param name="realm"></param>
|
||||
public void AddRealm(Realm realm)
|
||||
private void AddRealm(Realm realm)
|
||||
{
|
||||
//If this Realm is set as Initial then we need to disable any previously
|
||||
//set Realms to avoid conflict.
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
<Compile Include="GameObjects\Characters\BaseAI.cs" />
|
||||
<Compile Include="GameObjects\Characters\BaseCharacter.cs" />
|
||||
<Compile Include="GameObjects\Environment\Door.cs" />
|
||||
<Compile Include="GameObjects\Environment\MyRealm.cs" />
|
||||
<Compile Include="GameObjects\Environment\Realm.cs" />
|
||||
<Compile Include="GameObjects\Environment\Room.cs" />
|
||||
<Compile Include="GameObjects\Environment\StartingLocation.cs" />
|
||||
|
|
|
@ -15,10 +15,11 @@ namespace MudGame
|
|||
static class Program
|
||||
{
|
||||
const String SettingsFile = "Settings.ini";
|
||||
static Game game;
|
||||
|
||||
static void Main(String[] args)
|
||||
{
|
||||
dynamic game = new Game();
|
||||
|
||||
//Re-create the settings file if it is missing. Don't push any log messages until we know that this is
|
||||
//verbose or not
|
||||
Log.Write("Loading Settings...", false);
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
player.ActiveGame.World.AddRealm(realm);
|
||||
player.ActiveGame.World.AddObject(realm);
|
||||
Log.Write(player.Name + " has created a Realm called " + realm.Name);
|
||||
player.Send(realm.Name + " has been created and added to the world.");
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class WorldCalifornia
|
|||
myRealm.Name = "California";
|
||||
myRealm.Description = "The Beaches of California are relaxing and fun to be at.";
|
||||
myRealm.IsInitialRealm = true;
|
||||
_Game.World.AddRealm(myRealm);
|
||||
_Game.World.AddObject(myRealm);
|
||||
|
||||
Zone myZone = new Zone(_Game);
|
||||
myZone.Name = "San Diego";
|
||||
|
|
|
@ -14,7 +14,7 @@ public class WorldCalifornia
|
|||
myRealm.Name = "California";
|
||||
myRealm.Description = "The Beaches of California are relaxing and fun to be at.";
|
||||
myRealm.IsInitialRealm = true;
|
||||
_Game.World.AddRealm(myRealm);
|
||||
_Game.World.AddObject(myRealm);
|
||||
|
||||
Zone myZone = new Zone(_Game);
|
||||
myZone.Name = "San Diego";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue