Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
        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);
        }