StartCreateLogicMultiPlayer
This commit is contained in:
parent
b1f24ce81b
commit
f6663bdd3c
2 changed files with 22 additions and 3 deletions
|
@ -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,9 +63,17 @@ public class SelectingServerGUI : AbstractGUI
|
|||
};
|
||||
joinButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SetGUI(new WaitingForPlayersGUI(false));
|
||||
// join
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -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>
|
||||
/// создается одиночная комната к которой ты подключаешься
|
||||
|
|
Loading…
Add table
Reference in a new issue