Topic: How can i add my logic when game end

Hi, I want to add my custom logic of scoring win counts to playfab leaderboard. How can i do that?

Share

Thumbs up Thumbs down

Re: How can i add my logic when game end

The event system could prove useful to suit your score needs.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    private void OnEnable()
    {
        UFE.OnRoundEnds += OnRoundEnds;
        UFE.OnGameEnds += OnGameEnds;
    }

    private void OnDisable()
    {
        UFE.OnRoundEnds -= OnRoundEnds;
        UFE.OnGameEnds -= OnGameEnds;
    }

    private void OnRoundEnds(ControlsScript winner, ControlsScript loser)
    {
        if (winner != null)
        {
            // Score logic
        }
    }

    private void OnGameEnds(ControlsScript winner, ControlsScript loser)
    {
        if (winner != null)
        {
            // Score logic
        }
    }
}

Share

Thumbs up +1 Thumbs down