/// <summary> /// Constructor /// </summary> /// <param name="parent">A local event handler to send messages to</param> /// <param name="network">The network connection to use for handling events</param> public NetLogic(IHandleEvent parent, NetPlayer network) : base(parent, null, null) { _network = network; network.parent = this; _map = new Map(); }
public Lobby(Backend.IHandleEvent parent, SpriteBatch spriteBatch, ContentManager content, Rectangle displayRect, NetPlayer netplayer = null) : base(parent, spriteBatch, content, displayRect) { string myGUID = ""; if (Properties.Settings.Default.guid != "NONE") { myGUID = Properties.Settings.Default.guid; } else { myGUID = Guid.NewGuid().ToString(); Properties.Settings.Default.guid = myGUID; Properties.Settings.Default.Save(); } AddChild(_ipEntry = new TextInput(this, spriteBatch, content, new Rectangle(_displayRect.Left + 5, _displayRect.Top + 5, _displayRect.Width - 250, 30), "Server:", "localhost", "Enter a server to connect to or localhost to test locally", -1, true)); AddChild(_playerName = new TextInput(this, spriteBatch, content, new Rectangle(_displayRect.Left + 5, _displayRect.Top + 50, _displayRect.Width - 250, 30), "Computer-ID:", myGUID, "Enter a unique ID for your computer", -1, true)); AddChild(_listPlayers = new Statusbox(this, spriteBatch, content, new Rectangle(_displayRect.Left + 5, _displayRect.Top + 100, _displayRect.Width - 10, _displayRect.Height - 160), true, true)); //_ok = new Button(this, spriteBatch, content, new Rectangle(_displayRect.Right - 90, _displayRect.Bottom - 50, 80, 40), "Ok", (int)Backend.Buttons.Close); AddChild(_launchServer = new Button(this, spriteBatch, content, new Rectangle(_displayRect.Right - 210, _displayRect.Top + 5, 200, 40), "Launch Server", (int)Backend.Buttons.StartServer)); AddChild(_cancel = new Button(this, spriteBatch, content, new Rectangle(_displayRect.Left + 10, _displayRect.Bottom - 50, 80, 40), "Cancel", (int)Backend.Buttons.Cancel)); AddChild(_connect = new Button(this, spriteBatch, content, new Rectangle(_displayRect.Right - 160, _displayRect.Top + 50, 150, 40), "Connect", (int)Backend.Buttons.Connect)); if (netplayer == null) { _network = new NetPlayer(this); _network.playername = _playerName.text; } else { _launchServer.Hide(); _network = netplayer; _network.parent = this; _ipEntry.text = _network.server; _playerName.text = _network.playername; if (netplayer.connected) { _connect.label = "Disconnect"; _listPlayers.AddLine("Connected.", Color.Green); } else { _connect.label = "Connect"; _listPlayers.AddLine("Disconnected.", Color.Red); } } // IP-Entry-Field (Dropdown?) // Button to launch server // Entry fField for player name // List of players }
private void _ShowLANWindow(NetPlayer network = null) { if (_focus is Window) { _focus.Dispose(); _interfaceElements.Remove(_focus); _toolbar.HandleEvent(true, Backend.Events.ContinueGame, 13); _status = Backend.GameStatus.Running; } _status = Backend.GameStatus.Paused; Lobby _lobby = new Lobby(this, _spriteBatch, Content, new Rectangle((GraphicsDevice.Viewport.Width - 340) / 2, (GraphicsDevice.Viewport.Height - 200) / 2, 680, 400), network); _interfaceElements.Add(_lobby); _focus = _interfaceElements[_interfaceElements.Count - 1]; }