Example #1
0
 void OnTriggerEnter(Collider col)
 {
     if (col == leftGoal || col == rightGoal)
     {
         if (OnPlayerScore != null)               // if there are listeners to this event
         {
             var eventArgs = new BallScoreEventArgs(col);
             OnPlayerScore(null, eventArgs);
         }
     }
 }
Example #2
0
    // Called when someone scores
    private void HandlePlayerScore(object sender, BallScoreEventArgs eventArgs)
    {
        if (eventArgs.Collider == leftGoal)
        {
            rightPlayerScore++;
        }
        else
        {
            leftPlayerScore++;
        }

        UpdateScores();
        ball.RestartBall();
    }