MudGame added. From within Visual Studio set MudGame as the Startup Project.
Run the Game once, then edit the Settings.ini file generated to enable or disable the network server. Setting ServerEnabled to False will enable the Singleplayer offline mode within the engine.
This commit is contained in:
parent
b4b88cdbd3
commit
cf41436381
5 changed files with 259 additions and 11 deletions
|
@ -5,7 +5,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudEngine", "MudEngine\MudE
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MUDCompiler", "MUDCompiler\MUDCompiler.csproj", "{98E974DA-C650-4B88-B2F8-57AC7AE6C34F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudGame", "MudGame\MudGame.csproj", "{5BA65833-A99D-486C-8E74-C11A0713D44A}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MudGame", "MudGame\MudGame.csproj", "{0C47648F-8751-4A71-98ED-A3D0845627E2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -37,16 +37,16 @@ Global
|
|||
{98E974DA-C650-4B88-B2F8-57AC7AE6C34F}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{98E974DA-C650-4B88-B2F8-57AC7AE6C34F}.Release|x86.ActiveCfg = Release|x86
|
||||
{98E974DA-C650-4B88-B2F8-57AC7AE6C34F}.Release|x86.Build.0 = Release|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Debug|x86.Build.0 = Debug|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Release|x86.ActiveCfg = Release|x86
|
||||
{5BA65833-A99D-486C-8E74-C11A0713D44A}.Release|x86.Build.0 = Release|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Debug|x86.Build.0 = Debug|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Release|x86.ActiveCfg = Release|x86
|
||||
{0C47648F-8751-4A71-98ED-A3D0845627E2}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
2
MudGame/..svnbridge/.svnbridge
Normal file
2
MudGame/..svnbridge/.svnbridge
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:ignore</Name><Value>obj
|
||||
</Value></Property></Properties></ItemProperties>
|
63
MudGame/MudGame.csproj
Normal file
63
MudGame/MudGame.csproj
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0C47648F-8751-4A71-98ED-A3D0845627E2}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MudGame</RootNamespace>
|
||||
<AssemblyName>MudGame</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MudEngine\MudEngine.csproj">
|
||||
<Project>{498943A8-DF5A-4DB0-B506-0BFF44788657}</Project>
|
||||
<Name>MudEngine</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
147
MudGame/Program.cs
Normal file
147
MudGame/Program.cs
Normal file
|
@ -0,0 +1,147 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
|
||||
using MudEngine.FileSystem;
|
||||
using MudEngine.GameManagement;
|
||||
using MudEngine.GameObjects.Characters;
|
||||
using MudEngine.Scripting;
|
||||
|
||||
namespace MudGame
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
const string SettingsFile = "Settings.ini";
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
Log.Write("Launching...");
|
||||
ScriptEngine scriptEngine;
|
||||
Game game;
|
||||
|
||||
//Re-create the settings file if it is missing
|
||||
if (!File.Exists(SettingsFile))
|
||||
{
|
||||
Log.Write("Settings.ini missing!");
|
||||
FileManager.WriteLine(SettingsFile, "Scripts", "ScriptPath");
|
||||
FileManager.WriteLine(SettingsFile, ".cs", "ScriptExtension");
|
||||
FileManager.WriteLine(SettingsFile, "True", "ServerEnabled");
|
||||
Log.Write("Settings.ini re-created with default values");
|
||||
}
|
||||
|
||||
if (FileManager.GetData(SettingsFile, "ServerEnabled").ToLower() == "false")
|
||||
Log.IsVerbose = true;
|
||||
else if (FileManager.GetData(SettingsFile, "ServerEnabled").ToLower() == "")
|
||||
Log.IsVerbose = false;
|
||||
else
|
||||
Log.IsVerbose = false;
|
||||
|
||||
Log.Write("Loading settings...");
|
||||
scriptEngine = new ScriptEngine(new Game(), ScriptEngine.ScriptTypes.SourceFiles);
|
||||
scriptEngine.ScriptPath = FileManager.GetData(SettingsFile, "ScriptPath");
|
||||
scriptEngine.ScriptExtension = FileManager.GetData(SettingsFile, "ScriptExtension");
|
||||
|
||||
//scriptEngine.CompileScripts();
|
||||
Log.Write("Initializing Script Engine for Script Compilation...");
|
||||
scriptEngine.Initialize();
|
||||
|
||||
GameObject obj = scriptEngine.GetObjectOf("Game");
|
||||
Console.WriteLine(Log.GetMessages());
|
||||
Log.FlushMessages();
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
Log.Write("Setting up the Default Engine Game Manager...");
|
||||
game = new Game();
|
||||
obj = new GameObject(game, "Game");
|
||||
scriptEngine = new ScriptEngine((Game)obj.Instance, ScriptEngine.ScriptTypes.Assembly);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Write("Setting up " + obj.GetProperty().GameTitle + " Manager...");
|
||||
game = (Game)obj.Instance;
|
||||
scriptEngine = new ScriptEngine(game, ScriptEngine.ScriptTypes.Assembly);
|
||||
}
|
||||
scriptEngine.ScriptPath = FileManager.GetDataPath(SaveDataTypes.Root);
|
||||
//Force TCP
|
||||
game.ServerType = ProtocolType.Tcp;
|
||||
|
||||
//Setup the scripting engine and load our script library
|
||||
//MUST be called before game.Start()
|
||||
//scriptEngine.Initialize();
|
||||
//game.scriptEngine = scriptEngine; //Pass this script engine off to the game to use now.
|
||||
Log.Write("Starting " + obj.GetProperty().GameTitle + "...");
|
||||
Console.WriteLine(Log.GetMessages());
|
||||
Log.FlushMessages();
|
||||
|
||||
//Server is only enabled if the option is in the settings file
|
||||
//Allows developers to remove the option from the settings file and letting
|
||||
//people host multiplayer games with the singleplayer MUD.
|
||||
//People won't know that it's an option if the option doesn't exist so if no
|
||||
//option is found in the sttings file, then we assume offline play.
|
||||
if (FileManager.GetData(SettingsFile, "ServerEnabled").ToLower() == "false")
|
||||
game.IsMultiplayer = false;
|
||||
else if (FileManager.GetData(SettingsFile, "ServerEnabled").ToLower() == "")
|
||||
game.IsMultiplayer = false;
|
||||
else
|
||||
game.IsMultiplayer = true;
|
||||
|
||||
game.Start();
|
||||
|
||||
//Make sure the Game is in fact running.
|
||||
if (!game.IsRunning)
|
||||
{
|
||||
Console.WriteLine("Error starting game!\nReview Log file for details.");
|
||||
return;
|
||||
}
|
||||
|
||||
//If the game isn't in multiplayer mode, then the server doesn't create an instance of the players
|
||||
//We need to make sure that the Game created one. The default game handles this, but inherited Game
|
||||
//scripts might miss this, so we check for it.
|
||||
if (!game.IsMultiplayer)
|
||||
{
|
||||
if ((game.PlayerCollection[0] == null) || (game.PlayerCollection[0].Name == "New BaseCharacter"))
|
||||
{
|
||||
Console.WriteLine("Error! No player available for creation!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DateTime serverTime = new DateTime();
|
||||
DateTime systemTime = DateTime.Now;
|
||||
|
||||
int lastSaveGap = 0;
|
||||
|
||||
while (game.IsRunning)
|
||||
{
|
||||
if (lastSaveGap == 30)
|
||||
{
|
||||
game.Save();
|
||||
lastSaveGap = 0;
|
||||
}
|
||||
|
||||
if (serverTime.Minute != DateTime.Now.Minute)
|
||||
{
|
||||
serverTime = DateTime.Now;
|
||||
lastSaveGap++;
|
||||
}
|
||||
|
||||
if (game.IsMultiplayer)
|
||||
{
|
||||
Console.Write(Log.GetMessages());
|
||||
Log.FlushMessages();
|
||||
System.Threading.Thread.Sleep(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
game.PlayerCollection[0].ExecuteCommand(Console.ReadLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
36
MudGame/Properties/AssemblyInfo.cs
Normal file
36
MudGame/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("MudGame")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("MudGame")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("716b9b06-926f-432b-a5ff-6fd49b93d000")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
Loading…
Add table
Add a link
Reference in a new issue