static void Main(string[] args) { rand = new Random(); int seed = rand.Next(1, int.MaxValue); world = new World(); NetworkManager networkManager = new NetworkManager(seed); GameLoop gameLoop = new GameLoop(seed, networkManager); Thread t = new Thread(gameLoop.Run); t.Start(); networkManager.StartServer(); while (true) { networkManager.Accept(); } t.Join(); }
private bool StartServer(string ServerIP) { //Display a message to the console indicating the server is not being started MessageLog.Print("Starting server on " + ServerIP); //Before connecting to the server we need to load the connection settings from the .xml config file, start by loading the file into memory XmlDocument ConnectionSettings = new XmlDocument(); ConnectionSettings.Load("SQLConnectionSettings.xml"); //Extract all the required values from the file and store each of their into their own variables int NetworkPort = Convert.ToInt32(ConnectionSettings.DocumentElement.SelectSingleNode("/root/NetworkPort").InnerText); string WindowsServiceName = ConnectionSettings.DocumentElement.SelectSingleNode("/root/WindowsServiceName").InnerText; string Username = ConnectionSettings.DocumentElement.SelectSingleNode("/root/Username").InnerText; string Password = ConnectionSettings.DocumentElement.SelectSingleNode("/root/Password").InnerText; //Load all the existing game items from the exported text file ItemInfoDatabase.LoadItemList("Content/MasterItemList.txt"); ItemManager.InitializeItemManager(); //Start listening for new network client connections ConnectionManager.Initialize(ServerIP); //Open a new window for rendering so we can see whats going on while the server is up ApplicationWindow = new Window("Swaelo Server 2.0", new Int2(1024, 768), WindowMode.Windowed); // new Int2(1700, 100), WindowMode.Windowed); LogicLoop = new GameLoop(ApplicationWindow); //Load in the contents needed for the scene to run ContentArchive Content; using (var Stream = typeof(Program).Assembly.GetManifestResourceStream("Server.Content.ServerContents.contentarchive")) Content = ContentArchive.Load(Stream); //Initialize the game world simulation World = new GameWorld(LogicLoop, Content); return(true); }
public async void Wait() { await GameLoop.Wait(5000); AllowAttack = true; }