/// <inheritdoc /> /// <summary> /// Creates a Scoreboard Panel that represents the scores in a SpaceWars client. /// </summary> /// <param name="spaceWarsClient">The SpaceWars client that holds player scores.</param> public ScoreboardPanel(SpaceWarsClient spaceWarsClient) { _spaceWarsClient = spaceWarsClient; _spaceWarsClient.WorldModified += OnWorldModified; DoubleBuffered = true; BackColor = Color.FromArgb(80, 255, 255, 255); CreateHeader(); }
/// <inheritdoc /> /// <summary> /// Creates a new WorldPanel. /// </summary> /// <param name="spaceWarsClient">The SpaceWars client for which this panel is drawing the world.</param> public WorldPanel(SpaceWarsClient spaceWarsClient) { _spaceWarsClient = spaceWarsClient; _spaceWarsClient.WorldModified += OnWorldModified; BackColor = Color.Transparent; DoubleBuffered = true; // Compute scale of world when the size of this panel changes. SizeChanged += (sender, args) => { _scaleMultipliers = new[] { (double)Width / _spaceWarsClient.GameWorld.Size, (double)Height / _spaceWarsClient.GameWorld.Size }; }; }
/// <inheritdoc /> /// <summary> /// Creates a new Game Form that is based on the given Space Wars instance. /// </summary> /// <param name="spaceWarsClient">The connected Space Wars instance.</param> public GameForm(SpaceWarsClient spaceWarsClient) { _spaceWarsClient = spaceWarsClient; InitializeComponent(); InitializeWorldPanel(); InitializeScoreboardPanel(); InitializeDisconnectButton(); _worldPanel.Focus(); // Controls InitializeControls(); StartMusic(); // Subscribe to connection lost event. _spaceWarsClient.Disconnected += OnDisconnected; }