start game can get called now
This commit is contained in:
Родитель
88c07fa391
Коммит
5c72eb5ade
|
@ -211,6 +211,41 @@ PrefabInstance:
|
|||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 8193837056937481125, guid: f6820ab1e68494ee6ab947b3f14bcd57,
|
||||
type: 3}
|
||||
propertyPath: m_Users.Array.size
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8193837056937481125, guid: f6820ab1e68494ee6ab947b3f14bcd57,
|
||||
type: 3}
|
||||
propertyPath: m_Users.Array.data[2].email
|
||||
value: four@four.four
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8193837056937481125, guid: f6820ab1e68494ee6ab947b3f14bcd57,
|
||||
type: 3}
|
||||
propertyPath: m_Users.Array.data[2].password
|
||||
value: fourfour
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8193837056937481125, guid: f6820ab1e68494ee6ab947b3f14bcd57,
|
||||
type: 3}
|
||||
propertyPath: m_Users.Array.data[3].email
|
||||
value: four@four.four
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8193837056937481125, guid: f6820ab1e68494ee6ab947b3f14bcd57,
|
||||
type: 3}
|
||||
propertyPath: m_Users.Array.data[3].password
|
||||
value: fourfour
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8193837056937481125, guid: f6820ab1e68494ee6ab947b3f14bcd57,
|
||||
type: 3}
|
||||
propertyPath: m_Users.Array.data[1].email
|
||||
value: four@four.four
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8193837056937481125, guid: f6820ab1e68494ee6ab947b3f14bcd57,
|
||||
type: 3}
|
||||
propertyPath: m_Users.Array.data[1].password
|
||||
value: fourfour
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8579451657641387261, guid: f6820ab1e68494ee6ab947b3f14bcd57,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
|
@ -271,7 +306,8 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedComponents:
|
||||
- {fileID: 8579451657641387260, guid: f6820ab1e68494ee6ab947b3f14bcd57, type: 3}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: f6820ab1e68494ee6ab947b3f14bcd57, type: 3}
|
||||
--- !u!1001 &1501938911
|
||||
PrefabInstance:
|
||||
|
|
|
@ -98,20 +98,6 @@ namespace FootRoids
|
|||
var newState = new Dictionary<string, string> {{"hello", "world"}}.ToJson();
|
||||
socket.SendMatchStateAsync(m_Match.Id, 1, newState);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator LoadGame(IMatchmakerMatched matched)
|
||||
{
|
||||
AsyncOperation asyncLoad = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("MatchScene", UnityEngine.SceneManagement.LoadSceneMode.Additive);
|
||||
|
||||
while (!asyncLoad.isDone)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync("FakeMatchmaker");
|
||||
MatchCommunicationManager.Instance.JoinMatchAsync(matched);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Multiplayer
|
|||
{
|
||||
public class MatchCommunicationManager : Singleton<MatchCommunicationManager>
|
||||
{
|
||||
[SerializeField] private int _playerCount = 2;
|
||||
[SerializeField] private int _playerCount = 1;
|
||||
|
||||
public event Action OnGameStarted;
|
||||
public event Action<MatchMessageGameEnded> OnGameEnded;
|
||||
|
@ -78,7 +78,6 @@ namespace Multiplayer
|
|||
|
||||
public async void JoinMatchAsync(IMatchmakerMatched matched)
|
||||
{
|
||||
Debug.Log("HERE");
|
||||
ChooseHost(matched);
|
||||
|
||||
Players = new List<IUserPresence>();
|
||||
|
@ -96,8 +95,13 @@ namespace Multiplayer
|
|||
MatchId = match.Id;
|
||||
Debug.Log("Joined match with id: " + match.Id + "; presences count: " + match.Presences.Count());
|
||||
|
||||
// TODO: deal with duplicate users (probably not in scope for this)
|
||||
StartGame();
|
||||
|
||||
bool playersJoin = AddConnectedPlayers(match);
|
||||
if(playersJoin)
|
||||
{
|
||||
matchJoined = true;
|
||||
StartGame();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -124,6 +128,10 @@ namespace Multiplayer
|
|||
StartGame();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Already found this player");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,6 +184,33 @@ namespace Multiplayer
|
|||
IMatchmakerUser hostUser = matched.Users.First(x => x.Presence.SessionId == hostSessionId);
|
||||
CurrentHostId = hostUser.Presence.UserId;
|
||||
}
|
||||
|
||||
private bool AddConnectedPlayers(IMatch match)
|
||||
{
|
||||
foreach(IUserPresence user in match.Presences)
|
||||
{
|
||||
if(Players.FindIndex(x => x.UserId == user.UserId) == -1)
|
||||
{
|
||||
Debug.Log("User +" + user.Username + " joined match");
|
||||
|
||||
Players.Add(user);
|
||||
|
||||
// TODO: need to set opponent id?
|
||||
|
||||
if(AllPlayersJoined == true)
|
||||
{
|
||||
allPlayersAdded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Not allowed!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче