CreateConnectMultiplayer
This commit is contained in:
parent
3849435115
commit
2cce4ea9b9
4 changed files with 11 additions and 10 deletions
|
@ -32,11 +32,11 @@ public class SelectingServerGUI : AbstractGUI
|
|||
{
|
||||
rectangle = new Rectangle(width / 4 - (width / 4) / 2, height / 4, (int)(width / 4), (int)(height / 20)),
|
||||
text = "ip",
|
||||
scale = 0.2f,
|
||||
scale = 0.5f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
textAligment = MonogameLibrary.UI.Enums.TextAligment.Left,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font3"
|
||||
};
|
||||
ipBox.TextChanged += input =>
|
||||
{
|
||||
|
@ -76,8 +76,6 @@ public class SelectingServerGUI : AbstractGUI
|
|||
{
|
||||
client.JoinRoom(endpoint[0], port);
|
||||
AppManager.Instance.SetClient(client);
|
||||
Server server = new Server();
|
||||
AppManager.Instance.SetServer(server);
|
||||
AppManager.Instance.SetGUI(new WaitingForPlayersGUI(false));
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +102,7 @@ public class SelectingServerGUI : AbstractGUI
|
|||
|
||||
// host
|
||||
Server server = new Server(); //Server Logic MultiPlayer
|
||||
server.CreateRoom(5);
|
||||
server.CreateRoom(1);
|
||||
AppManager.Instance.SetServer(server);
|
||||
string key = server.MyIp.ToString();
|
||||
AppManager.Instance.debugHud.Set(key, "MultiPlayer");
|
||||
|
|
|
@ -49,7 +49,7 @@ public class WaitingForPlayersGUI : AbstractGUI
|
|||
startButton.LeftButtonPressed += () =>
|
||||
{
|
||||
// start
|
||||
|
||||
AppManager.Instance.ChangeState(GameState.HostPlaying);
|
||||
// ваш код здесь
|
||||
};
|
||||
Elements.Add(startButton);
|
||||
|
@ -69,7 +69,7 @@ public class WaitingForPlayersGUI : AbstractGUI
|
|||
waitButton.LeftButtonPressed += () =>
|
||||
{
|
||||
// start
|
||||
|
||||
AppManager.Instance.ChangeState(GameState.ClientPlaying);
|
||||
// ваш код здесь
|
||||
};
|
||||
Elements.Add(waitButton);
|
||||
|
|
|
@ -101,7 +101,7 @@ namespace ZoFo.GameCore.GameManagers
|
|||
break;
|
||||
case GameState.HostPlaying:
|
||||
server.Update(gameTime);
|
||||
client.Update(gameTime);
|
||||
// client.Update(gameTime);
|
||||
break;
|
||||
case GameState.ClientPlaying:
|
||||
server.Update(gameTime);
|
||||
|
|
|
@ -142,13 +142,16 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
for (int i = 0; i < playNumber; i++)
|
||||
{
|
||||
Socket client = socket.Accept();
|
||||
AppManager.Instance.debugHud.Set("Connect", client.ToString());
|
||||
Thread thread = new Thread(StartListening);
|
||||
thread.IsBackground = true;
|
||||
thread.Start(client);
|
||||
managerThread.Add(client, thread);
|
||||
clients.Add(client); //добавляем клиентов в лист
|
||||
clients.Add(client);
|
||||
//AppManager.Instance.ChangeState(GameState.HostPlaying);
|
||||
//добавляем клиентов в лист
|
||||
}
|
||||
|
||||
AppManager.Instance.ChangeState(GameState.HostPlaying);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Add table
Reference in a new issue