public NetworkMultiplayer(bool createServer = false) : base(GameModes.Network) { if(createServer) GameServer = new GameServer(); //read network on each update Game.Instance.OnUpdate += ReadNetwork; //server config NetPeerConfiguration config = new NetPeerConfiguration("tank"); config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse); //server creation Client = new NetClient(config); Client.Start(); if (!createServer) { //check whether the user has a known server ListMenu serverMenu = new ListMenu("Do you want to connect to a given IP (if yes, enter in console)?", "tank.Code.YESORNOCHOOSENOW", ConnectionMethodSelectionCallback); Scene.Add(serverMenu); } else//we know that a local server must exist Client.DiscoverLocalPeers(14242); //register handler for receiving data OnClientData += IncomingHandler; //are we client, or are we dancer? if(!createServer) Console.WriteLine("client"); }
public void ShowListMenu(string menuDescription, List<string> values, ListMenu.OnSelection callback) { //save callback _listMenuCallback = callback; //create a list menu, sneakily sneak in the callback that unpauses the game and calls the callback ListMenu m = new ListMenu(menuDescription, values, CallListMenuCallBack); //add menu to scene Scene.Add(m); //pause the rest game Scene.PauseGroup((int)PauseGroups.NotMenu); }
public void ShowListMenu(string menuDescription, List <string> values, ListMenu.OnSelection callback) { //save callback _listMenuCallback = callback; //create a list menu, sneakily sneak in the callback that unpauses the game and calls the callback ListMenu m = new ListMenu(menuDescription, values, CallListMenuCallBack); //add menu to scene Scene.Add(m); //pause the rest game Scene.PauseGroup((int)PauseGroups.NotMenu); }