Hlavní menu, synchronizace jmen hráčů. Client hru spustí až ve chvíli kdy dostane správný packet. Oprava bugu v se scalováním UIElementu
This commit is contained in:
parent
e6128dc9f5
commit
7656707177
19 changed files with 315 additions and 53 deletions
37
FNAF_Clone/GUI/LoadingUIElement.cs
Normal file
37
FNAF_Clone/GUI/LoadingUIElement.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace FNAF_Clone.GUI;
|
||||
|
||||
public class LoadingUIElement : TextUIElement {
|
||||
private string expectedEndpoint;
|
||||
private Client.ConnectionState lastState = Client.ConnectionState.IDLE;
|
||||
|
||||
public LoadingUIElement(Point corner1, SpriteFont font, string expectedEndpoint, Alignment alignment = Alignment.CENTER, bool autoBounds = true) : base(corner1, font, alignment, autoBounds) {
|
||||
this.expectedEndpoint = expectedEndpoint;
|
||||
Active = true;
|
||||
// Color = Color.LightGray;
|
||||
}
|
||||
|
||||
public override void Update() {
|
||||
if(lastState == Client.State) return;
|
||||
lastState = Client.State;
|
||||
|
||||
switch (Client.State){
|
||||
case Client.ConnectionState.CONNECTING:
|
||||
Text = "Connecting to " + expectedEndpoint;
|
||||
break;
|
||||
case Client.ConnectionState.CONNECTED:
|
||||
Text = "Connected to " + expectedEndpoint;
|
||||
break;
|
||||
case Client.ConnectionState.ACCEPTED:
|
||||
Text = "Waiting for opponent...";
|
||||
break;
|
||||
case Client.ConnectionState.GAME_STARTING:
|
||||
Text = "Opponent: " + Client.Opponent.username;
|
||||
Color = Color.White;
|
||||
// ScaleMultiplier = 1.5f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue