/// <summary> /// The client's last part of the 3-way handshake. Change the callMe delegate to its final /// incarnation, to continue receiving and processing the World from the Server. If something went wrong /// in the NetworkingLibrary, the SocketState will have an error, and the user will have /// another chance to connect. /// </summary> /// <param name="state"></param> private void ReceiveStartup(SocketState state) { if (state.hasError) { NetworkError(); } if (state.sBuilder == null) { return; } // get the player ID and world size out of state.sBuilder string info = state.sBuilder.ToString(); string[] infoArray = info.Split('\n'); if (infoArray.Length < 2) { return; } if (!(Int32.TryParse(infoArray[0], out playerID) && Int32.TryParse(infoArray[1], out worldSize))) { return; } // recreate the World theWorld = new World(worldSize); // create the drawingPanel, based on the new World. drawingPanel = new DrawingPanel(theWorld); drawingPanel.Location = new Point(0, menuStrip.Height); drawingPanel.Size = new Size(worldSize, worldSize); // create the scoreboardPanel, based on the new World. scoreboardPanel = new ScoreboardPanel(theWorld); scoreboardPanel.Location = new Point(worldSize, menuStrip.Height); // Ask the form to Invoke Methods to add the drawingPanel and resize the form MethodInvoker addDrawingPanel = new MethodInvoker(() => this.Controls.Add(drawingPanel)); MethodInvoker addScorePanel = new MethodInvoker(() => this.Controls.Add(scoreboardPanel)); MethodInvoker resizeClientForm = new MethodInvoker(() => ClientSize = new Size(worldSize + scoreboardPanel.Width, worldSize + menuStrip.Height)); try { this.Invoke(resizeClientForm); this.Invoke(addDrawingPanel); this.Invoke(addScorePanel); } catch (Exception) { } state.sBuilder.Clear(); // Update the action to take when network events happen state.callMe = ReceiveWorld; // Start waiting for data Networking.GetData(state); }
private void CreateUI() { // Pause button this.b_pause = new Button() { IsBorder = false, Text = string.Empty, BackgroundImage = WaveContent.Assets.Textures.pause_bt_PNG, PressedBackgroundImage = WaveContent.Assets.Textures.pause_bt_pressed_PNG, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, WaveServices.ViewportManager.TopEdge + 10, 10, 0), }; this.b_pause.Click += (s, o) => { SoundsManager.Instance.PlaySound(SoundsManager.SOUNDS.Button); WaveServices.ScreenContextManager.Push(new ScreenContext(new PauseScene(this))); }; EntityManager.Add(this.b_pause); // Ready! Go! Timeout! this.messagePanel = new MessagePanel(MessagePanel.MessageType.HurryUp) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; EntityManager.Add(this.messagePanel); // Stadistics this.stadisticsPanel = new StadisticsPanel() { HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(0, WaveServices.ViewportManager.TopEdge, 0, 0), }; EntityManager.Add(this.stadisticsPanel); // HighScore this.highScorePanel = new HighScorePanel() { HorizontalAlignment = HorizontalAlignment.Right, Margin = new Thickness(0, 100, 0, 0), }; EntityManager.Add(this.highScorePanel); // Combo this.comboPanel = new ComboPanel(new Vector2(WaveServices.ViewportManager.VirtualWidth / 2, WaveServices.ViewportManager.TopEdge + 150)); EntityManager.Add(this.comboPanel); // Scoreboard this.scoreboardPanel = new ScoreboardPanel(this.comboPanel) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, WaveServices.ViewportManager.TopEdge, 0, 0), }; EntityManager.Add(this.scoreboardPanel); }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { this.gamePlayScene = this.Scene as GamePlayScene; this.scoreboardPanel = this.gamePlayScene.EntityManager.Find <ScoreboardPanel>("scoreboardPanel"); this.target = this.gamePlayScene.EntityManager.Find <Entity>("BallTarget"); this.targetTransform = this.target.FindComponent <Transform2D>(); this.start = this.gamePlayScene.EntityManager.Find <Entity>("BallStart"); this.startTransform = this.start.FindComponent <Transform2D>(); }
void Awake() { if (ScoreboardPanel.instance != null) { Destroy(gameObject); } else { ScoreboardPanel.instance = this; } }
private void SetActiveScoreboard(bool isActive) { ScoreboardTimer.SetActive(isActive); ScoreboardPanel.SetActive(isActive); }
/// <summary> /// Resolves the dependencies needed for this instance to work. /// </summary> protected override void ResolveDependencies() { base.ResolveDependencies(); this.scoreboardPanel = ((GamePlayScene)this.Owner.Scene).scoreboardPanel; }