/// <inheritdoc /> /// <summary> /// </summary> /// <param name="screen"></param> /// <param name="availableItems"></param> /// <param name="poolSize"></param> /// <param name="poolStartingIndex"></param> /// <param name="size"></param> /// <param name="contentSize"></param> /// <param name="startFromBottom"></param> public LobbyMatchScrollContainer(LobbyScreen screen, List <MultiplayerGame> availableItems, int poolSize, int poolStartingIndex, ScalableVector2 size, ScalableVector2 contentSize, bool startFromBottom = false) : base(availableItems, poolSize, poolStartingIndex, size, contentSize, startFromBottom) { Screen = screen; Tint = Color.Black; Alpha = 0.75f; Scrollbar.Tint = ColorHelper.HexToColor("#eeeeee"); Scrollbar.Width = 6; Scrollbar.X = 14; ScrollSpeed = 150; EasingType = Easing.OutQuint; TimeToCompleteScroll = 1500; NoMatchesFound = new SpriteTextBitmap(FontsBitmap.GothamRegular, "No Matches Found. What are you waiting for? Create one!") { Parent = this, Alignment = Alignment.MidCenter, FontSize = 16, Visible = false }; AddBorder(Color.White, 2); Border.Alpha = 1f; CreatePool(); }
public Game1() { FileHandler.writeToFile(systemOptions, @"Content\Data\system_variables.xml", new XmlSerializer(typeof(SystemOptions))); systemOptions = FileHandler.readFromFile(@"Content\Data\system_variables.xml", new XmlSerializer(typeof(SystemOptions))); new GraphicsDeviceManager(this) { PreferredBackBufferWidth = systemOptions.resolutionWidth, PreferredBackBufferHeight = systemOptions.resolutionHeight, IsFullScreen = systemOptions.fullScreen }; Components.Add(new InputHandler(this)); stateManager = new GameStateManager(this); Components.Add(stateManager); screenRectangle = new Rectangle(0, 0, systemOptions.resolutionWidth, systemOptions.resolutionHeight); startMenuScreen = new StartMenuScreen(this, stateManager); Level1 = new Level1(this, stateManager); Level2 = new Level2(this, stateManager); characterCreationScreen = new CharacterCreationScreen(this, stateManager); pauseScreen = new PauseScreen(this, stateManager); optionsScreen = new OptionsScreen(this, stateManager); loadGameScreen = new LoadGameScreen(this, stateManager); gameLoseScreen = new GameLoseScreen(this, stateManager); lobbyScreen = new LobbyScreen(this, stateManager); highScoreScreen = new HighScoresScreen(this, stateManager); stateManager.ChangeState(startMenuScreen); }
private void OnJoinedLobby() { WelcomeScreen.SetActive(false); LoadingScreen.SetActive(false); LobbyScreen.SetActive(true); Debug.Log("Joined Lobby"); }
private void Refresh() { LobbyScreen current = (LobbyScreen)screen.State; hostOrJoinScreen.SetActive(current == LobbyScreen.PickHostOrClient); hostStartScreen.SetActive(current == LobbyScreen.SetupHost || current == LobbyScreen.SetupClient); preferenceScreen.SetActive(current == LobbyScreen.ClientGamePrefs || current == LobbyScreen.HostGamePrefs); rejoinScreen.SetActive(current == LobbyScreen.Rejoin); }
private void OnEnterScreen(int screen) { LobbyScreen screenState = (LobbyScreen)screen; if (screenState == LobbyScreen.ClientGamePrefs || screenState == LobbyScreen.HostGamePrefs) { RefreshButtonInteractable(); } CheckDisconnect(); }
/// <summary> /// </summary> public LobbyMatchInfo(LobbyScreen screen) { Screen = screen; Size = new ScalableVector2(480, 638); Tint = Color.Black; Alpha = 0f; CreateBackground(); CreateContentContainer(); CreateNoMatchSelectedText(); }
void Awake() { if( mInstance != null ) { Debug.LogError( string.Format( "Only one instance of LobbyScreen allowed! Destroying:" + gameObject.name +", Other:" + mInstance.gameObject.name ) ); return; } mInstance = this; HighlightHost(); }
public ScreenManager(MainGame game, GraphicsDeviceManager graphics) { this.graphics = graphics; gameScreen = new GameScreen(game); menuScreen = new MenuScreen(game); settingScreen = new SettingScreen(game); multiplayerScreen = new MultiplayerScreen(game); loginScreen = new LoginScreen(game); lobbyScreen = new LobbyScreen(game); CurrentScreen = loginScreen; ChangeRes(CurrentScreen.ScreenWidth, CurrentScreen.ScreenHeight, CurrentScreen.IsFullScreen); game.IsMouseVisible = true; }
public void Run() { using (GameConfigurationScreen gameConfigurationScreen = new GameConfigurationScreen(_gameConfiguration)) { gameConfigurationScreen.ShowDialog(); } Lobby lobby = new Lobby(_gameConfiguration); using (LobbyScreen lobbyScreen = new LobbyScreen(lobby)) { lobbyScreen.ShowDialog(); } Game game = new Game(_gameConfiguration.ServerConnection); _gameScreen = new GameScreen(game); Application.Run(_gameScreen); }
// Test Data // public int testIndex = 1; // public string testString = "sadsad"; void Awake() { Instance = this; }
public CreateLevelDialog(Manager manager, LobbyScreen screen) : base(manager) { this.screen = screen; // Setup the window Text = "Create Level"; TopPanel.Visible = false; Resizable = false; Width = 250; Height = 196; Center(); // Add controls lblName = new Label(manager) { Left = 8, Top = 8, Text = "Name:", Width = ClientWidth - 16 }; lblName.Init(); Add(lblName); txtName = new TextBox(manager) { Left = 8, Top = lblName.Bottom + 4, Width = ClientWidth - 16 }; txtName.Init(); txtName.TextChanged += (sender, args) => { // If you're trying to fix this function, please check out line 77 first. if (txtName.Text.Length > CreateLevelMessage.MaxNameLength) { txtName.Text = txtName.Text.Truncate(CreateLevelMessage.MaxNameLength); } createBtn.Enabled = !string.IsNullOrWhiteSpace(txtName.Text); // Makes sure aspects like text selection rendering gets covered by MonoForce args.Handled = false; }; Add(txtName); lblDescription = new Label(manager) { Left = 8, Top = txtName.Bottom + 4, Text = "Description:", Width = ClientWidth - 16 }; lblDescription.Init(); Add(lblDescription); txtDescription = new TextBox(manager) { Left = 8, Top = lblDescription.Bottom + 4, Width = ClientWidth - 16, Height = 40, Mode = TextBoxMode.Multiline, ScrollBars = ScrollBars.None }; txtDescription.Init(); txtDescription.TextChanged += (sender, args) => { // Dear maintainer: // // If you've come here to avoid the truncation and instead // stop the player from typing those characters on the first place // then you're reading the right comment, because I already tried it! // // Here is why it doesn't work: // * NeoForce just straight ignore args.Handled on this function; // * KeyDown works however if you hold down a key it just ignores your code; // * KeyUp is useless, as is KeyPress; // // Once you are done trying to 'fix' this routine, and have realized // what a terrible mistake that was, please increment the following // counter as a warning to the next guy: // // total_hours_wasted_here = 4 if (txtDescription.Text.Length > CreateLevelMessage.MaxDescriptionLength) { txtDescription.Text = txtDescription.Text.Truncate(CreateLevelMessage.MaxDescriptionLength); } var newLines = txtDescription.Text.Count(c => c == '\n') + 1; // There is always one line! if (newLines > CreateLevelMessage.MaxDescriptionLines) { txtDescription.Text = string.Join("\n", txtDescription.Text.Split('\n'), 0, CreateLevelMessage.MaxDescriptionLines); txtDescription.CursorPosition = txtDescription.Text.Length - 1; } // Makes sure aspects like text selection rendering gets covered by MonoForce // Works everytime, 50% of the time. args.Handled = false; }; Add(txtDescription); createBtn = new Button(manager) { Top = 8, Text = "Create", Enabled = false }; createBtn.Init(); createBtn.Left = (Width / 2) - (createBtn.Width / 2); createBtn.Click += CreateBtn_Click; BottomPanel.Add(createBtn); }
public void SetScreen(BaseScreen.Type type, object[] data = null, bool isFadeIn = false, bool keepPrevScreen = false) { if (currentScreen != null) { if (currentScreen.type == type) { return; } if (keepPrevScreen) { previousScreen = currentScreen; previousScreen.Hide(); } else { currentScreen.Close(); } } GameObject tempGameObject; switch (type) { case BaseScreen.Type.LOBBY: tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.SCREEN_PATH + "/LobbyScreen/LobbyScreen", typeof(GameObject)) as GameObject); tempGameObject.name = "LobbyScreen"; LobbyScreen = tempGameObject.GetComponent <LobbyScreen>(); currentScreen = LobbyScreen; LobbyScreen.Init(data); LobbyScreen.Open(); break; case BaseScreen.Type.SELECT_GAME: tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.SCREEN_PATH + "/SelectGameScreen/SelectGameScreen", typeof(GameObject)) as GameObject); tempGameObject.name = "SelectGameScreen"; SelectGameScreen = tempGameObject.GetComponent <SelectGameScreen>(); currentScreen = SelectGameScreen; SelectGameScreen.Init(data); SelectGameScreen.Open(); break; case BaseScreen.Type.SELECT_ROOM: tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.SCREEN_PATH + "/SelectRoomScreen/SelectRoomScreen", typeof(GameObject)) as GameObject); tempGameObject.name = "SelectRoomScreen"; SelectRoomScreen = tempGameObject.GetComponent <SelectRoomScreen>(); currentScreen = SelectRoomScreen; SelectRoomScreen.Init(data); SelectRoomScreen.Open(); break; case BaseScreen.Type.LEADERBOARD: tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.SCREEN_PATH + "/LeaderboardScreen/LeaderboardScreen", typeof(GameObject)) as GameObject); tempGameObject.name = "LeaderboardScreen"; LeaderboardScreen = tempGameObject.GetComponent <LeaderboardScreen>(); currentScreen = LeaderboardScreen; LeaderboardScreen.Init(data); LeaderboardScreen.Open(); break; // when open gamescreen, first element in data will be GameType case BaseScreen.Type.GAME_SCREEN: currentScreen = SetGameScreen((BaseGameScreen.GameType)data[0], data); break; case BaseScreen.Type.SLOT_GAME_SCREEN: currentScreen = SetSlotGameScreen((BaseSlotMachineScreen.GameType)data[0], data); break; } if (isFadeIn) { // currentScreen.FadeIn(); PopupManager.Instance.FadeInScreen(); } }
/// <summary> /// Handles a data message (The bulk of all messages recieved, containing player movements, block places, etc) /// </summary> private void HandleDataMessage(NetIncomingMessage im) { MessageTypes messageType = (MessageTypes)im.ReadByte(); //Find the type of data message sent switch (messageType) { case MessageTypes.Lobby: //Lobby list packet { if (Game.CurrentGameState == GameState.Lobby) { LobbyScreen screen = MainWindow.ScreenManager.Current as LobbyScreen; LobbyMessage msg = new LobbyMessage(im); screen.Name = msg.ServerName; screen.Description = msg.Description; screen.Intro = msg.Intro; screen.Online = msg.Online; screen.Rooms = msg.Rooms; screen.Lobby.LoadRooms(); } break; } case MessageTypes.PlayerJoin: //Player join message { PlayerJoinMessage user = new PlayerJoinMessage(im); //Add player to map Map.Players.Add(new Player(Map, Map.Spawn, user.Username, user.ID) { Tint = user.Color }); //Add user to userlist (MainWindow.ScreenManager.Current as GameScreen).PlayerList.Items.Add(user.Username); if (user.ID != Game.MyID && recievedInit) //Broadcast join message to chat { (MainWindow.ScreenManager.Current as GameScreen).SystemChat(user.Username + " [color:LightGray]has[/color] [color:LightGreen]joined.[/color]"); } if (user.Me) { //Let game know of it's own player Game.MyID = user.ID; Game.MyIndex = (byte)Map.Players.IndexOf(Map.Players.First(x => x.ID == Game.MyID)); Game.Me.Tint = Game.MyColor; } break; } case MessageTypes.PlayerLeave: //Player leave message { PlayerLeaveMessage user = new PlayerLeaveMessage(im); //Remove player if (user.ID != Game.MyID) { Player player = (Player)Map.PlayerFromID(user.ID); Map.Players.Remove((Player)Map.PlayerFromID(user.ID)); (MainWindow.ScreenManager.Current as GameScreen).PlayerList.Items.Remove(player.Username); (MainWindow.ScreenManager.Current as GameScreen).SystemChat(player.Username + " [color:LightGray]has[/color] [color:IndianRed]left.[/color]"); //Rebuild indexes for (int i = 0; i < Map.Players.Count; i++) { Map.Players[i].Index = i; if (Map.Players[i].ID == Game.MyID) { Game.MyIndex = (byte)i; } } } break; } case MessageTypes.PlayerStatus: //Player move message { if (Game.CurrentGameState == GameState.Game) { PlayerStateMessage user = new PlayerStateMessage(im); Player player = (Player)Map.PlayerFromID(user.ID); player.SimulationState.Position = user.Position.ToVector2(); player.SimulationState.Velocity = user.Velocity.ToVector2(); player.SimulationState.Movement = user.Movement.ToVector2(); if (!recievedInit) //If we have not recieved init (meaning we are not in game yet), set the initial positions directly so interpolation doesn't mess with them { player.DisplayState.Position = player.SimulationState.Position; } player.VirtualJump = user.IsJumping; } break; } case MessageTypes.Block: //Block place message { if (Game.CurrentGameState == GameState.Game) { BlockMessage msg = new BlockMessage(im); BlockType block = BlockType.FromID(msg.BlockID); if (Map.CanPlaceBlock(msg.X, msg.Y, msg.Z, block)) { Map.Tiles[msg.X, msg.Y, msg.Z].Block = block; } } break; } case MessageTypes.PlayerSmiley: //Smiley change message { if (Game.CurrentGameState == GameState.Game) { PlayerSmileyMessage msg = new PlayerSmileyMessage(im); Player p = (Player)Map.PlayerFromID(msg.ID); p.Smiley = msg.Smiley; } break; } case MessageTypes.PlayerMode: //Player mode change message { if (Game.CurrentGameState == GameState.Game) { PlayerModeMessage mode = new PlayerModeMessage(im); Map.PlayerFromID(mode.ID).Mode = (PlayerMode)mode.Mode; } break; } case MessageTypes.Chat: //Chat message { if (Game.CurrentGameState == GameState.Game) { ChatMessage chat = new ChatMessage(im); (MainWindow.ScreenManager.Current as GameScreen).AddChat(Map.PlayerFromID(chat.ID).Username, chat.Message); } break; } case MessageTypes.Init: //Initialization message with world data { Game.Map = new Bricklayer.Client.World.Map(game, 1, 1); InitMessage msg = new InitMessage(im, Map); Game.Map.Minimap = new Minimap(Game.Map, msg.Width, msg.Height) { Position = new Microsoft.Xna.Framework.Vector2(8, 8) }; Game.Map.CreateCamera(); Game.CurrentGameState = GameState.Game; (MainWindow.ScreenManager.Current as GameScreen).Show(); (MainWindow.ScreenManager.Current as GameScreen).SystemChat("Connected to [color:LightGray]" + Game.Host + ":" + Game.Port + "[/color]"); recievedInit = true; break; } } }
public LobbyDataControl(LobbyScreen screen, Manager manager, LevelData data, Control parent) : base(manager) { // Setup Passive = false; Height = 60; Width = parent.ClientWidth; this.screen = screen; Data = data; // Background "gradient" image // TODO: Make an actual control. not a statusbar gradient = new StatusBar(manager); gradient.Init(); gradient.Alpha = .8f; Add(gradient); for (var i = 0; i < 5; i++) { imgRating[i] = new ImageBox(Manager) { Top = 4, Width = 16, Height = 16, Left = ClientWidth - (((4 - i) * 18) + 48) }; imgRating[i].Init(); var half = data.Rating > i + .25 && data.Rating < i + .75; var whole = data.Rating >= i + .75; imgRating[i].Image = whole ? screen.Client.Content["gui.icons.full_star"] : half ? screen.Client.Content["gui.icons.half_star"] : screen.Client.Content["gui.icons.empty_star"]; Add(imgRating[i]); } lblStats = new Label(Manager) { Width = 100, Left = ClientWidth - 100 - 16, Top = imgRating[0].Bottom + 4, Alignment = Alignment.TopLeft, TextColor = new Color(160, 160, 160) }; lblStats.Init(); lblStats.Text = $"Online: {data.Online}\nPlays: {"N/A"}"; Add(lblStats); // Add controls lblName = new Label(Manager) { Width = 100, Text = data.Name, Left = 4, Top = 4, Font = FontSize.Default14, Alignment = Alignment.TopLeft }; lblName.Init(); Add(lblName); lblName.Text = data.Name; lblDescription = new Label(Manager) { Width = 200, Text = data.Name, Left = 4, Top = lblName.Bottom + 4, Alignment = Alignment.TopLeft }; lblDescription.Init(); Add(lblDescription); lblDescription.Text = data.Description; }
private void OnDisconnectedFromPhoton() { WelcomeScreen.SetActive(false); LobbyScreen.SetActive(false); DisconnectedScreen.SetActive(true); }
public LobbyWindow(Manager manager, LobbyScreen screen) : base(manager) { lobbyScreen = screen; // Setup the window CaptionVisible = false; TopPanel.Visible = false; Movable = false; Resizable = false; Width = (int)(Manager.ScreenWidth * .9); Height = (int)(Manager.ScreenHeight * .9); Shadow = true; Center(); // Group panels grpServer = new GroupPanel(Manager) { Left = ClientWidth - Globals.Values.MaxBannerWidth - 1, Width = Globals.Values.MaxBannerWidth, Height = ClientHeight - BottomPanel.Height + 2, Text = "Server" }; grpServer.Init(); Add(grpServer); var grpLobby = new GroupPanel(Manager) { Width = ClientWidth - grpServer.Width, // Fill remaining space Height = ClientHeight - BottomPanel.Height + 2, Text = "Levels" }; grpLobby.Init(); Add(grpLobby); // Top controls txtSearch = new TextBox(Manager) { Left = 8, Top = 8, Width = (int)((grpLobby.Width / 2d) - 16) }; txtSearch.Init(); txtSearch.Text = searchStr; txtSearch.TextChanged += (sender, args) => { RefreshLevels(); }; // Show "Search..." text, but make it dissapear on focus txtSearch.FocusGained += (sender, args) => { if (txtSearch.Text.Trim() == searchStr) { txtSearch.Text = string.Empty; } }; txtSearch.FocusLost += (sender, args) => { if (txtSearch.Text.Trim() == string.Empty) { txtSearch.Text = searchStr; } }; grpLobby.Add(txtSearch); cmbSort = new ComboBox(Manager) { Left = txtSearch.Right + 8, Top = 8, Width = (grpLobby.Width / 2) - 16 - 20 }; cmbSort.Init(); cmbSort.Items.AddRange(sortFilters); cmbSort.ItemIndex = 0; cmbSort.ItemIndexChanged += (sender, args) => { RefreshLevels(); }; grpLobby.Add(cmbSort); var btnReload = new Button(Manager) { Left = cmbSort.Right + 8, Top = 8, Width = 20, Height = 20, Text = string.Empty }; btnReload.Init(); btnReload.Glyph = new Glyph(screen.Client.Content["gui.icons.refresh"]); btnReload.ToolTip.Text = "Refresh"; btnReload.Click += (sender, args) => { btnReload.Enabled = false; lobbyScreen.Client.Network.Send(new RequestMessage(MessageTypes.Init)); }; grpLobby.Add(btnReload); // Main level list lstLevels = new ControlList <LobbyDataControl>(Manager) { Left = 8, Top = txtSearch.Bottom + 8, Width = grpLobby.Width - 16, Height = grpLobby.Height - 16 - txtSearch.Bottom - 24 }; lstLevels.Init(); lstLevels.DoubleClick += (sender, args) => { if (lstLevels.ItemIndex < 0) { return; } var ldc = (LobbyDataControl)lstLevels.Items[lstLevels.ItemIndex]; // Make sure the user clicks the item and not the empty space in the list if (ldc.CheckPositionMouse(((MouseEventArgs)args).Position - lstLevels.AbsoluteRect.Location)) { JoinLevel(lstLevels.ItemIndex); } }; grpLobby.Add(lstLevels); // Server info labels lblName = new Label(Manager) { Text = "Loading...", Top = 8, Font = FontSize.Default20, Left = 8, Alignment = Alignment.MiddleCenter, Height = 30, Width = grpServer.ClientWidth - 16 }; lblName.Init(); grpServer.Add(lblName); lblDescription = new Label(Manager) { Text = string.Empty, Top = 8 + lblName.Bottom, Left = 8, Alignment = Alignment.MiddleCenter, Width = grpServer.ClientWidth - 16 }; lblDescription.Init(); grpServer.Add(lblDescription); lblInfo = new Label(Manager) { Text = string.Empty, Top = 8 + lblDescription.Bottom, Left = 8, Alignment = Alignment.TopLeft, Width = grpServer.ClientWidth - 16, Height = grpServer.Height }; lblInfo.Init(); grpServer.Add(lblInfo); // Bottom buttons var btnCreate = new Button(Manager) { Top = 8, Text = "Create" }; btnCreate.Left = (ClientWidth / 2) - (btnCreate.Width / 2); btnCreate.Init(); btnCreate.Click += (sender, args) => { var window = new CreateLevelDialog(manager, screen); window.Init(); Manager.Add(window); window.ShowModal(); }; BottomPanel.Add(btnCreate); var btnJoin = new Button(Manager) { Right = btnCreate.Left - 8, Top = 8, Text = "Join" }; btnJoin.Init(); btnJoin.Click += (sender, args) => { JoinLevel(lstLevels.ItemIndex); }; BottomPanel.Add(btnJoin); var btnDisconnect = new Button(Manager) { Left = btnCreate.Right + 8, Top = 8, Text = "Quit" }; btnDisconnect.Init(); btnDisconnect.Click += (sender, args) => { lobbyScreen.Client.Network.NetClient.Disconnect("Left Lobby"); MainWindow.ScreenManager.SwitchScreen(new LoginScreen()); }; BottomPanel.Add(btnDisconnect); // When client gets banner data from server screen.Client.Events.Network.Game.LobbyBannerReceived.AddHandler(LobbyBannerReceived); // When client receives level data after joining/creating a level screen.Client.Events.Network.Game.LevelDataReceived.AddHandler(LevelDataReceived); // When the lobby data is received (after connecting or on reload) screen.Client.Events.Network.Game.InitReceived.AddHandler(InitReceived); LoadLevels(); screen.Client.Network.Send(new RequestMessage(MessageTypes.Banner)); }
public void BackToSelectorWindow(LobbyScreen screen) { Screen.Screen.HideOrShowScreen(0.5f, screen); //ShowGameModeWindow(); }