예제 #1
0
 /// <summary>
 /// Server only. Fetches are players from ServerManager players map
 /// </summary>
 public void GetAllPlayersData()
 {
     foreach (Player player in GameManager.GetPlayers())
     {
         if (!player.isAI)
         {
             ServerPlayer sp = ServerManager.Singleton.GetPlayer(player.SteamID);
             StartCoroutine(BackendManager.FetchCharacterFromServer(player.SteamID, sp.cid, (cData, status) => {
                 if (status == BackendManager.STATUS_OK)
                 {
                     player.CData = cData;
                     CharacterFetched?.Invoke(player.SteamID, cData);
                 }
                 Debug.LogError(status);
             }));
         }
         else
         {
             // Not implemented in backend yet.
             StartCoroutine(BackendManager.FetchAIFromServer(player.aiPlayerID, (cData, status) => {
                 if (status == BackendManager.STATUS_OK)
                 {
                     player.CData = cData;
                     CharacterFetched?.Invoke(player.SteamID, cData);
                 }
                 Debug.LogError(status);
             }));
         }
     }
 }
예제 #2
0
    private IEnumerator ChangeCharacterCoroutine(int cid)
    {
        yield return(BackendManager.SaveCharacter(SteamID, Cid, CharData));

        yield return(null);

        yield return(BackendManager.FetchCharacterFromServer(SteamID, cid, FetchCharacterCallback));
    }
예제 #3
0
 /// <summary>
 /// Fetches a player's characters stats. Use for Client -> Backend
 /// </summary>
 public void GetClientPlayerStats(ulong steamid, int cid)
 {
     StartCoroutine(BackendManager.FetchCharacterFromServer(steamid, cid, (cData, status) => {
         if (status == BackendManager.STATUS_OK)
         {
             m_focusedPlayer = cData;
             CharacterFetched?.Invoke(steamid, cData);
         }
         Debug.LogError(status);
     }));
 }
예제 #4
0
    // Loads locally
    public IEnumerator Load()
    {
        yield return(null);

        yield return(BackendManager.Login(SteamID, LoginCallback));

        yield return(BackendManager.FetchCharacterFromServer(SteamID, Cid, FetchCharacterCallback));

        yield return(BackendManager.FetchAllCharacters(SteamID, FetchAllCharacterCallback));

        yield return(null);

        //m_gameSetup.hasClientLoaded = true;
        status = 1;
        print("Finished loading client");
    }
예제 #5
0
    /// <summary>
    /// Server only. Fetches a players' character stats. Used for Server -> Backend
    /// </summary>
    public void GetPlayerStats(Player player)
    {
        if (!NetworkingManager.Singleton.IsServer)
        {
            return;
        }

        if (!ServerManager.Singleton.players.TryGetValue(player.SteamID, out ServerPlayer sPlayer))
        {
            return;
        }

        StartCoroutine(BackendManager.FetchCharacterFromServer(player.SteamID, sPlayer.cid, (cData, status) => {
            if (status == BackendManager.STATUS_OK)
            {
                m_focusedPlayer = cData;
                CharacterFetched?.Invoke(player.SteamID, cData);
            }
            Debug.LogError(status);
        }));
    }