StartCreateLogicMultiPlayer

This commit is contained in:
rawer470 2024-08-17 10:50:05 +03:00
parent b1f24ce81b
commit f6663bdd3c
2 changed files with 22 additions and 3 deletions

View file

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Xml;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
@ -62,10 +63,18 @@ public class SelectingServerGUI : AbstractGUI
};
joinButton.LeftButtonPressed += () =>
{
AppManager.Instance.SetGUI(new WaitingForPlayersGUI(false));
// join
// ваш код здесь
Client client = new Client();
var endpoint = ipBox.text.Split(':');
int port;
if (int.TryParse(endpoint[1], out port))
{
client.JoinRoom(endpoint[0], port);
AppManager.Instance.SetClient(client);
AppManager.Instance.SetGUI(new WaitingForPlayersGUI(false));
}
// ваш код здесь
};
Elements.Add(joinButton);
Button hostButton = new Button(Manager)

View file

@ -71,6 +71,16 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
listen.IsBackground = true;
listen.Start();
}
public void JoinRoom(IPEndPoint endPoint) // multyplayer
{
this.endPoint = endPoint;
socket.Connect(endPoint);
SendData();
Thread listen = new Thread(StartListening);
listen.IsBackground = true;
listen.Start();
}
/// <summary>
/// создается одиночная комната к которой ты подключаешься