Partial MatchController that plays audio cues during a penalty shootout. Watches the simulation's shot sequence and kick list and fires kick, goal, save or boo sounds as new events appear.
using Socer;
public sealed partial class MatchController
{
MatchSimulation observedShootoutMatch;
int observedShootoutShot,observedShootoutKicks;
void ObserveShootoutAudio()
{
if(observedShootoutMatch!=Match)
{observedShootoutMatch=Match;observedShootoutShot=Match.ShotSequence;observedShootoutKicks=0;}
if(!Match.ShootoutActive && !Match.ShootoutComplete)return;
if(observedShootoutShot!=Match.ShotSequence)
{observedShootoutShot=Match.ShotSequence;GameAudio.Kick(true,StrikeKind.Driven);}
while(observedShootoutKicks<Match.ShootoutKicks.Count)
{
var kick=Match.ShootoutKicks[observedShootoutKicks++];
if(kick.Scored)GameAudio.Goal();else if(kick.Outcome==PenaltyOutcome.Saved)GameAudio.Save();else GameAudio.Boo();
}
}
}