Beispiel #1
0
    void onScored(string scoringTeamAlias)
    {
        for (int i = 0; i < matchesList.GetChildCount(); i++)
        {
            MatchInfo match = (MatchInfo)matchesList.GetChild(i);

            if (match.Team1Alias == scoringTeamAlias)
            {
                match.AddScore(scoringTeamAlias);
                return;
            }
            if (match.Team2Alias == scoringTeamAlias)
            {
                match.AddScore(scoringTeamAlias);
                return;
            }
        }
    }
Beispiel #2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     // TODO: find a cleaner way to prevent goal from marking itself
     if (other.transform.tag == "Puck")
     {
         if (other.transform.parent == null || (other.transform.parent.parent != null && other.transform.parent.parent.tag != "GoalKeeper"))
         {
             matchInfo.AddScore(1, opponentTeam);
             audio.PlayOneShot(hornClip);
             // TODO: optimization here
             if (Random.Range(0, 4) == 0)
             {
                 GameObject.Find("Level/Public").audio.PlayOneShot(crowdSound);
             }
             other.rigidbody2D.isKinematic = true;
             faceOff.MakeFaceOff();
         }
     }
 }