new API and rematch WIP
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -102,7 +101,12 @@ public class CupidLobby : MonoBehaviour
|
||||
continue;
|
||||
}
|
||||
|
||||
CupidRoom? room = Cupid.ParseRoom(text);
|
||||
Team? teamHint = LoginManager.MatchYourTeam;
|
||||
if (!teamHint.HasValue && GameManager.instance != null)
|
||||
teamHint = GameManager.MyTeam;
|
||||
int userId = LoginManager.CurrentUser != null ? LoginManager.CurrentUser.id : 0;
|
||||
|
||||
CupidRoom? room = Cupid.ParseRoom(text, userId, teamHint);
|
||||
if (room == null)
|
||||
{
|
||||
if (text != null && text.Trim() != "0")
|
||||
@@ -113,29 +117,35 @@ public class CupidLobby : MonoBehaviour
|
||||
CupidRoom _room = (CupidRoom)room;
|
||||
Logger.Log("Got into a room");
|
||||
Logger.Log(text);
|
||||
MatchmadeResponse matchmadeResponse = JsonUtility.FromJson<MatchmadeResponse>(text);
|
||||
if(matchmadeResponse.Players.Length < 2){
|
||||
Debug.Log("Waiting for the other player to show up");
|
||||
MatchmadeResponse env = JsonUtility.FromJson<MatchmadeResponse>(text);
|
||||
MatchmadeTeamPayload branch = MatchmadeResponse.SelectTeamPayload(env, userId, teamHint);
|
||||
if (branch == null || !MatchmadeResponse.TryResolveMyAndOpponent(env, branch, userId, out MatchmadePlayer myPlayer, out MatchmadePlayer opponentPlayer))
|
||||
{
|
||||
Debug.Log("Waiting for the other player to show up (could not resolve roster)");
|
||||
yield return new WaitForSeconds(1);
|
||||
continue;
|
||||
}
|
||||
Team myTeam = matchmadeResponse.your_team == "red" ? Team.Red : Team.Blue;
|
||||
|
||||
MatchmadePlayer myPlayer = matchmadeResponse.Players.First(p => p.UserId == LoginManager.CurrentUser.id);
|
||||
MatchmadePlayer opponentPlayer = matchmadeResponse.Players.First(p => p.UserId != LoginManager.CurrentUser.id);
|
||||
string yt = (branch.your_team ?? "").Trim().ToLowerInvariant();
|
||||
Team myTeam = yt == "blue" ? Team.Blue : Team.Red;
|
||||
|
||||
if(myTeam==Team.Red){
|
||||
if (myTeam == Team.Red)
|
||||
{
|
||||
GameManager.RedPlayer = myPlayer;
|
||||
GameManager.BluePlayer = opponentPlayer;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.BluePlayer = myPlayer;
|
||||
GameManager.RedPlayer = opponentPlayer;
|
||||
}
|
||||
GameManager.MyTeam = myTeam;
|
||||
|
||||
// LevelLoadManager.instance.SetupMatchMade(myTeam, myPlayer.Name, opponentPlayer.Name, $"L10 {myPlayer.l10_wins}-{myPlayer.l10_losses}", $"L10 {opponentPlayer.l10_wins}-{opponentPlayer.l10_losses}");
|
||||
LevelLoadManager.instance.SetupMatchMade(myTeam, myPlayer, opponentPlayer);
|
||||
GameManager.ConfigureDedicatedMatchReporting(matchmadeResponse.match_id);
|
||||
int rcPrizeCoins = env.rc_prize > 0 ? env.rc_prize : branch.rc_prize;
|
||||
GameManager.MatchRcPrizeCoins = rcPrizeCoins;
|
||||
|
||||
LevelLoadManager.instance.SetupMatchMade(myTeam, myPlayer, opponentPlayer, CoinHelper.FormatString(rcPrizeCoins) + " RC");
|
||||
GameManager.ConfigureDedicatedMatchReporting(branch.match_id);
|
||||
Logger.Log("Setting cupid to load game scene");
|
||||
Cupid.RoomPort = _room.Port;
|
||||
LoginManager.SetMatchYourTeam(_room.your_team);
|
||||
|
||||
Reference in New Issue
Block a user