public Lobby(SessionRole role, string ip, string username) { Input.Text += TextInput; ClearColor = Color.White; ChatBacklog = new List<string>(); chatValue = ""; Client.Name = username; sessionRole = role; sessionIp = ip; }
public SessionRole LoginUser(string login, string password, string userAgent) { var loggingUser = db.Users.Where(user => user.Username == login && user.Password == password).FirstOrDefault(); if (loggingUser != null) { SessionRole sessionRole = new SessionRole(); sessionRole.sessionId = addUserLogin(loggingUser.Id, userAgent); sessionRole.role = GetRole(loggingUser.Id); return(sessionRole); } else { return(null); } }
public Lobby(SessionRole role, string ip, string username) { Input.Text += TextInput; ClearColor = Color.White; ChatBacklog = new List <string>(); chatValue = ""; Client.Name = username; sessionRole = role; sessionIp = ip; cursorVisible = true; Timer.Every(0.65f, () => { cursorVisible = !cursorVisible; return(false); }); }
public Lobby(SessionRole role, string ip, string username) { Input.Text += TextInput; ClearColor = Color.White; ChatBacklog = new List<string>(); chatValue = ""; Client.Name = username; sessionRole = role; sessionIp = ip; cursorVisible = true; Timer.Every(0.65f, () => { cursorVisible = !cursorVisible; return false; }); }
private void InitializeSession(SessionRole role, string ip) { switch (role) { case SessionRole.Server: { // Initialize server try { Server.Initialize(Constants.DefaultPort); } catch (Exception) { Timer.NextFrame(() => Game.SetState(new ErrorMessageScreen("You are already hosting in another instance, moron."))); return; } // Initialize client frontend try { Client.Connect("localhost", Constants.DefaultPort); } catch (Exception) { Timer.NextFrame(() => Game.SetState(new ErrorMessageScreen("Cannot connect to host!"))); return; } // Add start button Button startButton = new Button(new Vector2f(GameOptions.Width - 222.0f / 2.0f - 8.0f - 64.0f + 8.0f, Button.Height / 2.0f + 8.0f + 32.0f + 8.0f), "Begin Game"); startButton.OnClick += () => { // Do not start unless we have enough players if (Players.Count < Constants.MinimalPlayerCount) { ChatBacklog.Add(String.Format("Cannot begin game with less than {0} people!", Constants.MinimalPlayerCount)); return(true); } // Load cards if we're the server Server.LoadCards(); // Begin game Client.SendMessage(new BeginGame()); return(true); }; Entities.Add(startButton); // Add settings button Button settingsButton = new Button(new Vector2f(GameOptions.Width - Button.Width / 2.0f - 8.0f - 64.0f + 8.0f - Button.Width - 4.0f, Button.Height / 2.0f + 8.0f + 32.0f + 8.0f), "Settings"); settingsButton.OnClick += () => { ServerList.Remove(); Game.PushState(new HostSettingsOverlay()); return(true); }; Entities.Add(settingsButton); ServerList.Add(); break; } case SessionRole.Client: try { Client.Connect(ip, Constants.DefaultPort); } catch (Exception) { Timer.NextFrame(() => Game.SetState(new ErrorMessageScreen("Cannot connect to host!"))); } break; } }
public JoinSessionMessage(string sessionID, SessionRole sessionRole) { this._sessionID = sessionID; this._sessionRole = sessionRole; }
private void InitializeSession(SessionRole role, string ip) { switch (role) { case SessionRole.Server: { // Initialize server try { Server.Initialize(Constants.DefaultPort); } catch (Exception) { Timer.NextFrame(() => Game.SetState(new ErrorMessageScreen("You are already hosting in another instance, moron."))); return; } // Initialize client frontend try { Client.Connect("localhost", Constants.DefaultPort); } catch (Exception) { Timer.NextFrame(() => Game.SetState(new ErrorMessageScreen("Cannot connect to host!"))); return; } // Add start button Button startButton = new Button(new Vector2f(GameOptions.Width - 222.0f / 2.0f - 8.0f - 64.0f + 8.0f, Button.Height / 2.0f + 8.0f + 32.0f + 8.0f), "Begin Game"); startButton.OnClick += () => { // Do not start unless we have enough players if (Players.Count < Constants.MinimalPlayerCount) { ChatBacklog.Add(String.Format("Cannot begin game with less than {0} people!", Constants.MinimalPlayerCount)); return true; } // Load cards if we're the server Server.LoadCards(); // Begin game Client.SendMessage(new BeginGame()); return true; }; Entities.Add(startButton); // Add settings button Button settingsButton = new Button(new Vector2f(GameOptions.Width - Button.Width / 2.0f - 8.0f - 64.0f + 8.0f - Button.Width - 4.0f, Button.Height / 2.0f + 8.0f + 32.0f + 8.0f), "Settings"); settingsButton.OnClick += () => { Game.PushState(new HostSettingsOverlay()); return true; }; Entities.Add(settingsButton); break; } case SessionRole.Client: try { Client.Connect(ip, Constants.DefaultPort); } catch (Exception) { Timer.NextFrame(() => Game.SetState(new ErrorMessageScreen("Cannot connect to host!"))); } break; } }