Source file unity-csharp/ebook/GameManager.cs from the GDnD code examples. Download raw file

// Demonstrates a small score owner for The Architecture of Play ebook.
// Referenced by: docs/ebook/GDnD-Architecture-of-Play.md
using UnityEngine;
 
public class GameManager : MonoBehaviour
{
    private int score;
 
    public void AddScore(int amount)
    {
        if (amount <= 0)
        {
            return;
        }
 
        score += amount;
        Debug.Log("Score: " + score);
    }
 
    public int GetScore()
    {
        return score;
    }
}