Increase coins after you have watched the whole ad

I’m trying to increase the amount of coins players get by watching the game’s ads. I want to use two scripts: “Coin Manager” and “ADS”. Coin Manager gives you coins while playing but I also want watching ads to give players more coins. I want players to watch the whole ad and after that to get le’ts say 50 extra coins. How can I combine the two scripts, which I already have, to increase player’s coins? Is there a code that I can use?
Below you can find the two scripts (1. Coin Manager, 2. ADS):
Thank you in advance.

using UnityEngine;
using System;
using System.Collections;

public class CoinManager : MonoBehaviour
{
    public static CoinManager Instance;

    public int Coins { get; private set; }

    public static event Action<int> CoinsUpdated = delegate {};

    [SerializeField]
    int INITIAL_COINS = 100;
    const string COINS = "COINS";   // key name to store high score in PlayerPrefs

    void Awake()
    {
        if (Instance)
        {
            DestroyImmediate(gameObject);
        }
        else
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
    }

    void Start()
    {
        Reset();
    }

    public void Reset()
    {
        // Initialize coins
        Coins = PlayerPrefs.GetInt(COINS, INITIAL_COINS);
    }

    public void AddCoins(int amount)
    {
        Coins += amount;


        // Store new coin value
        PlayerPrefs.SetInt(COINS, Coins);

        // Fire event
        CoinsUpdated(Coins);
    }

    public void RemoveCoins(int amount)
    {
        Coins -= amount;

        // Store new coin value
        PlayerPrefs.SetInt(COINS, Coins);

        // Fire event
        CoinsUpdated(Coins);
    }
}
using UnityEngine;
using UnityEngine.Advertisements;
using System.Collections;

public class ADS : MonoBehaviour
{
    void Awake()
    {
        if (Advertisement.isSupported)
        {
            if(Application.platform == RuntimePlatform.Android)
            {
                Advertisement.Initialize("1201734", false);
            }
        }
    }
    public void ShowAd()
    {
        if (Advertisement.IsReady())
        {
            Advertisement.Show("rewardedVideo", new ShowOptions() {resultCallback = HandleAdResult});
        }
    }

    private void HandleAdResult(ShowResult result)
    {
        switch (result)
        {
            case ShowResult.Finished:
                Debug.Log("Player Gain +50 Gems");
                break;
            case ShowResult.Skipped:
                Debug.Log("Player Skipped The AD");
                break;
            case ShowResult.Failed:
                Debug.Log("Player Failed To Launch The AD");
                break;
        }
    }
}

You have to add something in class ADS:

  • public CoinManager coinManager; // Make a new variable at the beginning
  • In HandleAdResult, where ShowResult.Finished. Add one line: coinManager.AddCoins(50);

NB! Afterwards, dont forget to assign new variable coinManager manually in inspector (drag script CoinManager, that is on the scene, to the field of class ADS).

Thank you very much. I liked your project i and really want to see you finished it.

Thanks a lot! :3