Beispiel #1
0
    /// Handles the response of the Create Team script from ChilliConnect. Will log any
    /// errors returned. On success, will add the new team to the local list of teams and
    /// update the players current team.
    ///
    /// @oaram output
    ///     The output of the create team script
    ///
    private void TeamCreatedCallBack(MultiTypeDictionary output)
    {
        //Check the script returned an error as part of the response
        var wasError = output.GetBool("Error");

        if (wasError)
        {
            UnityEngine.Debug.Log("Error creating team");
            return;
        }

        //Get the Team data returned from the script
        var teamProperties = output.GetDictionary("Team");

        //Construct a new team object
        var team = new Team();

        team.ID          = teamProperties.GetString("TeamID");
        team.Name        = teamProperties.GetString("Name");
        team.PlayerCount = 1;

        //Set this as the players current team
        PlayerTeam = team;

        //Add to the local list of stored teams
        Teams.Insert(0, team);

        //Inform listeners that a new team is created, the players current team
        //has changed and that the team list has been updated
        OnTeamCreated(team);
        OnTeamsRefreshed(Teams);
        OnPlayerTeamRefreshed(PlayerTeam);
    }
Beispiel #2
0
    /// Handles the response of the LeaveTeam script from ChilliConnect. Will log any
    /// any errors returned. If the request was succesfull, will clear the current player
    /// team and notify any listeners.
    ///
    /// @oaram output
    ///     The response from the ChilliConnect script
    ///
    private void LeaveTeamCallBack(MultiTypeDictionary output)
    {
        var wasError = output.GetBool("Error");

        if (wasError)
        {
            UnityEngine.Debug.Log("Error leaving team");
        }
        else
        {
            PlayerTeam = null;
            OnPlayerTeamRefreshed(null);
        }
    }
Beispiel #3
0
    /// Handles the response of the JoinTeam script from ChilliConnect. Will log any
    /// any errors returned. If the request was succesfull, will update the currently
    /// stored player team and notify any listeners
    ///
    /// @oaram output
    ///     The response from the ChilliConnect script
    ///
    /// @oaram team
    ///     The team that the player has joined
    ///
    private void JoinTeamCallBack(MultiTypeDictionary output, Team team)
    {
        var wasError = output.GetBool("Error");

        if (wasError)
        {
            UnityEngine.Debug.Log("Error joining team");
        }
        else
        {
            PlayerTeam = team;
            OnPlayerTeamRefreshed(team);
        }
    }