Remove Currency

I am needing a simple script that I can attach to items that when the character collide, coin is removed from the currency owner.
I see your instructions:
// Remove Currency
ownerCurrencyCollection.RemoveCurrency(gold, 10);
ownerCurrencyCollection.RemoveCurrency(new CurrencyAmount[] { (10 ,silver), (10 ,gold)});
ownerCurrencyCollection.RemoveCurrency(otherCurrencyCollection);

However, I am not a coder and have no idea how to implement this into the enemies attacking my character.
Can you please direct me to an answer for this?
Or better yet, display a simple script i can attach to enemies that make them remove my characters coin?

Thank you in advance.
Trent
 
Code:
public void RemoveCurrencyFromPlayer(int amount, Collider collider)
{
    if (collider == null || collider.attachedRigidbody == null) {
        return;
    }

    var inventory = collider.GetComponent<Inventory>();
    if(inventory == null){ return;}
    var currencyOwner = inventory.GetCurrencyOwner();
    if(currencyOwner == null){ return;}

    currencyOwner.RemoveCurrency("Gold", amount);
}
Something around those lines should do the trick
 
Code:
public void RemoveCurrencyFromPlayer(int amount, Collider collider)
{
    if (collider == null || collider.attachedRigidbody == null) {
        return;
    }

    var inventory = collider.GetComponent<Inventory>();
    if(inventory == null){ return;}
    var currencyOwner = inventory.GetCurrencyOwner();
    if(currencyOwner == null){ return;}

    currencyOwner.RemoveCurrency("Gold", amount);
}
Something around those lines should do the trick


Thank you
 
Top