public void OnScore(IEventPayload genericPayload) { if (genericPayload.GetType() == typeof(ScorePayload)) { ScorePayload scorePayload = (ScorePayload)genericPayload; totalScore += scorePayload.Score; UpdateScoreDisplay(); } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.gameObject.tag == "Puck") { // Puck has scored in this goal ScorePayload scorePayload = new ScorePayload(score); scoreEvent.Invoke(scorePayload); // Reset puck back to starting position PuckResetPayload puckResetPayload = new PuckResetPayload(); puckResetEvent.Invoke(puckResetPayload); // If there is no payload, then it would just be // puckResetEvent.Invoke(puckResetPayload); } }