public ServerCtrl(string filePath) { players = new Dictionary <long, Tank>(); playerSockets = new Dictionary <long, SocketState>(); wallsSent = false; SetDefaults(); rand = new Random(); randPowerupTime = rand.Next(0, maxPowerupSpawnTime); projectileCount = 0; beamCount = 0; powerUpTracker = 0; powerUpID = 0; projectileDelay = 0; turretAimx = 0; turretAimy = 0; working = false; world = new TheWorld(worldSize, 0); Load(filePath); Networking.StartServer(NewPlayer, 11000); Console.WriteLine("Server started"); dataBaseView = new DataBaseView(); Thread thread = new Thread(() => SendData()); thread.Start(); }
static void Main(string[] args) { //Set all of the constants to values in the settings document XDocument temp = XDocument.Load(@"..\..\..\Resources\Resources\settings.xml"); serverWorld.worldSize = (int)temp.Root.Element("UniverseSize"); MSFrameRate = (int)temp.Root.Element("MSPerFrame"); FramesPerShot = (int)temp.Root.Element("FramesPerShot"); RespawnRate = (int)temp.Root.Element("RespawnRate"); StartingHitPoints = (int)temp.Root.Element("StartingHitPoints"); ProjectileSpeed = (int)temp.Root.Element("ProjectileSpeed"); EngineStrength = (double)temp.Root.Element("EngineStrength"); MaxPowerups = (int)temp.Root.Element("MaxPowerups"); MaxPowerupDelay = (int)temp.Root.Element("MaxPowerupDelay"); //Counter to assign every wall a unique ID int wallID = 0; //Create all of the walls from the settings document foreach (XElement t in temp.Root.Elements("Wall")) { Vector2D P1 = new Vector2D((double)t.Element("p1").Element("x"), (double)t.Element("p1").Element("y")); Vector2D P2 = new Vector2D((double)t.Element("p2").Element("x"), (double)t.Element("p2").Element("y")); Wall tempWall = new Wall(P1, P2); tempWall.ID = wallID; walls.Add(tempWall.ID, tempWall); wallID++; } //Spawn every powerup into the world for (int i = 0; i < MaxPowerups; i++) { powerRespawn(); } //Start the server Networking.StartServer(ClientHandler, 11000); Console.WriteLine("Server is running: Accepting new Clients"); //Start a new thread for the update method Thread loopThread = new Thread(() => UpdateLoop()); loopThread.Start(); //Start the http server Networking.StartServer(HandleHttpConnection, 80); Console.WriteLine("Database is running"); //Time the game until a key is pressed gameTime.Start(); Console.ReadLine(); gameTime.Stop(); //Upload the game to the database mainDataControl.sendGameToDatabase(allTanksEver, gameTime); }
public static void Main() { //Read settings from file ReadSettingFile(@"..\\..\\..\\Resources\settings.xml"); //Start the server and web server Networking.StartServer(ReceivePlayerName, 11000); Networking.StartServer(HandleHttpConnection, 80); Console.WriteLine("Server is running. Accepting clients."); //Start the main loop Thread MainThread = new Thread(FrameLoop); MainThread.Start(); //Saves the game to the database and waits for an input Console.ReadLine(); MainThread.Abort(); DatabaseController.SaveGameToDatabase(TheWorld); Console.WriteLine("Saved game to database"); Console.ReadLine(); }
/// <summary> /// Starts the server and sets up the walls /// </summary> private void StartServer() { clients = new Dictionary <SocketState, Tank>(); // start accepting clients theServer = Networking.StartServer(HandleNewClient, 11000); }
/// <summary> /// Starts the server with Networking class. /// </summary> private void Start() { Networking.StartServer(HandleNewClient, 11000); Console.WriteLine("Server Is Running. Now Accepting New Clients."); }
/// <summary> /// starts the server on the specified port /// </summary> private static void StartServer() { Networking.StartServer(OnStart, 11000); }