// methods to increment scores public void winSet() { winCount++; //WinHappened(); // you fire events like this, calling them like functions // that will call every subscribed delegate with the parameters. // but you can't do it that way, because if there are no subscribers, the event is null. WinHappened?.Invoke(); // ?. is like . if the thing to the left isn't null. but if it is, it just does nothing. }
// methods to increment scores public void winSet() { winCount++; // fire event like this, call it like a function // call every subscribed delegate with the provided parameters // ?. is like . if the left is not null, if it is null, does nothing WinHappened?.Invoke(); // WinHappened(2); pass on 2 to its subscribers // if there are no subscribers, event is null -> nullexception }