private void UpdateLobbyGUI( bool _firstPass ) { int fighterCount = MenuNetworking.instance.connectionLimit/2 - 1; if ( _firstPass ) { this.commander1Row = this.CreatePlayerRow( TEAM.TEAM_1, 0, fighterCount ); this.commander2Row = this.CreatePlayerRow( TEAM.TEAM_2, 0, fighterCount ); this.fighters1 = new List<PlayerDisplayRow>(); this.fighters2 = new List<PlayerDisplayRow>(); for ( int i = 0; i < fighterCount; ++i ) { this.fighters1.Add( this.CreatePlayerRow( TEAM.TEAM_1, i+1, fighterCount ) ); this.fighters2.Add( this.CreatePlayerRow( TEAM.TEAM_2, i+1, fighterCount ) ); } this.forceFighter1Button = new GUIPlaceholder(); this.forceFighter1Button.rect = new Rect( this.forceTypeButtonOffset.x, this.forceTypeButtonOffset.y, this.buttonScale.x, this.buttonScale.y ); this.forceFighter1Button.text = "Fighter 1"; this.forceFighter2Button = new GUIPlaceholder(); this.forceFighter2Button.rect = new Rect( this.forceTypeButtonOffset.x + this.forceTypeButtonGap.x, this.forceTypeButtonOffset.y, this.buttonScale.x, this.buttonScale.y ); this.forceFighter2Button.text = "Fighter 2"; this.forceCommander1Button = new GUIPlaceholder(); this.forceCommander1Button.rect = new Rect( this.forceTypeButtonOffset.x, this.forceTypeButtonOffset.y + this.forceTypeButtonGap.y, this.buttonScale.x, this.buttonScale.y ); this.forceCommander1Button.text = "Commander 1"; this.forceCommander2Button = new GUIPlaceholder(); this.forceCommander2Button.rect = new Rect( this.forceTypeButtonOffset.x + this.forceTypeButtonGap.x, this.forceTypeButtonOffset.y + this.forceTypeButtonGap.y, this.buttonScale.x, this.buttonScale.y ); this.forceCommander2Button.text = "Commander 2"; this.lobbyBackButton = new GUIPlaceholder(); this.lobbyBackButton.rect = new Rect( this.lobbyControlButtonOffset.x, this.lobbyControlButtonOffset.y, this.buttonScale.x, this.buttonScale.y ); this.lobbyBackButton.text = "Back"; this.lobbyStartButton = new GUIPlaceholder(); this.lobbyStartButton.rect = new Rect( this.lobbyControlButtonOffset.x + this.buttonScale.x + this.lobbyControlButtonGap, this.lobbyControlButtonOffset.y, this.buttonScale.x, this.buttonScale.y ); this.lobbyStartButton.text = "Start"; this.chatDisplayArea = new GUIPlaceholder(); this.chatDisplayArea.rect = new Rect( this.chatOffset.x, this.chatOffset.y, this.chatEnterWidth, this.chatDisplayHeight ); this.chatDisplayArea.text = ""; this.chatEnterField = new GUIPlaceholder(); this.chatEnterField.rect = new Rect( this.chatOffset.x, this.chatOffset.y + this.chatDisplayHeight, this.chatEnterWidth, this.chatEnterHeight ); this.chatSendButton = new GUIPlaceholder(); this.chatSendButton.rect = new Rect( this.chatOffset.x + this.chatEnterWidth, this.chatOffset.y + this.chatDisplayHeight, this.buttonScale.x, this.buttonScale.y ); this.chatSendButton.text = "Send"; this.lobbyGameNameLabel = new GUIPlaceholder(); this.lobbyGameNameLabel.text = MenuNetworking.instance.gameName; this.lobbyGameNameLabel.rect = this.lobbyGameNameRect; this.lobbyGameCommentLabel = new GUIPlaceholder(); this.lobbyGameCommentLabel.text = MenuNetworking.instance.gameComment; this.lobbyGameCommentLabel.rect = this.lobbyGameCommentRect; } UpdatePlayerRow( this.commander1Row, GamePlayerManager.instance.commander1 ); UpdatePlayerRow( this.commander2Row, GamePlayerManager.instance.commander2 ); for ( int i = 0; i < this.fighters1.Count; ++i ) { GamePlayer player = i < GamePlayerManager.instance.fighters1.Count ? GamePlayerManager.instance.fighters1[i] : null; UpdatePlayerRow( this.fighters1[i], player ); player = i < GamePlayerManager.instance.fighters2.Count ? GamePlayerManager.instance.fighters2[i] : null; UpdatePlayerRow( this.fighters2[i], player ); } string chat = ""; for ( int i = MessageManager.instance.messages.Count - 1; i >= 0; --i ) { chat += MessageManager.instance.GetFormattedMessage( i ); } this.chatDisplayArea.text = chat; }
private void UpdatePlayerRow( PlayerDisplayRow _row, GamePlayer _player ) { _row.player = _player; _row.nameGUI.text = _player != null ? _player.name : "----------"; _row.ipGUI.text = _player != null ? _player.networkPlayer.ipAddress : "---.---.---.---"; if ( _player != null ) { if ( _row.ping == null ) { _row.ping = new Ping( _player.networkPlayer.ipAddress ); } if ( _row.ping.isDone ) { _row.pingGUI.text = _row.ping.time + "ms"; _row.ping = null; } } else { _row.pingGUI.text = "-----"; } }
private PlayerDisplayRow CreatePlayerRow( TEAM _team, int _pos, int _fighterCount ) { PlayerDisplayRow row = new PlayerDisplayRow(); float xPos = this.playerRowOffset.x; float yPos = this.playerRowOffset.y + _pos * this.lobbyRowHeight; if ( _team == TEAM.TEAM_2 ) { yPos += this.lobbyTeamGap; } row.nameGUI = new GUIPlaceholder(); row.nameGUI.rect = new Rect( xPos, yPos, this.lobbyNameWidth, this.lobbyRowHeight ); xPos += this.lobbyNameWidth; row.ipGUI = new GUIPlaceholder(); row.ipGUI.rect = new Rect( xPos, yPos, this.lobbyIPWidth, this.lobbyRowHeight ); xPos += this.lobbyIPWidth; row.pingGUI = new GUIPlaceholder(); row.pingGUI.rect = new Rect( xPos, yPos, this.lobbyPingWidth, this.lobbyRowHeight ); return row; }