public void Init() { startId = new MockRiderIdUnit("StartId"); endId = new MockRiderIdUnit("EndId"); timer = new MockTimingUnit(); source = new CancellationTokenSource(); TrackerConfig config = new TrackerConfig { EndMatchTimeout = 20, StartTimingGateId = 0, EndTimingGateId = 1 }; //riders are addded in the SimulateRace method tracker = new RaceTracker(timer, startId, endId, config, new List <Rider>()); subject = new RaceManager(); subject.Start(tracker, new List <IDisplayUnit> { timer }); SimulateRace(); //wait for the tracker to process all events Thread.Sleep(2000); subject.Stop(); }
public static RaceTracker Instance; // Singleton void Awake() { if (Instance == null) // NOT initialized { Instance = this; // Initializing the instance DontDestroyOnLoad(gameObject); // Making it available // throughout the game } else { Destroy(gameObject); // Already initialized and } // destroying duplicate }
public void Init() { startId = new MockRiderIdUnit("StartId"); endId = new MockRiderIdUnit("EndId"); timer = new MockTimingUnit(); source = new CancellationTokenSource(); TrackerConfig config = new TrackerConfig { EndMatchTimeout = 10, StartTimingGateId = 0, EndTimingGateId = 1 }; subject = new RaceTracker(timer, startId, endId, config, new List <Rider> { }); race = subject.Run(source.Token); }