void Start() { RecordIndicator.gameObject.SetActive(false); if (Managers.Game.Preferences.EnableReplay) { ReplayControl.ActivateReplay(); } else { ReplayControl.DeActivateReplay(); } Messenger.AddListener(Globals.GameEvents.MemekoLaunching, () => FSMGameLogic.RaiseEvent("Playing")); Messenger.AddListener(Globals.GameEvents.PauseGame, () => FSMGameLogic.RaiseEvent("Pause")); Messenger.AddListener(Globals.GameEvents.ResumeGame, OnResumeGame); Messenger.AddListener(Globals.GameEvents.RetryButtonPressed, OnExitScene); Messenger.AddListener(Globals.GameEvents.BackButtonPressed, OnExitScene); starttime = Time.time; globalSeconds = 0; CurrenTopScore = Managers.GameData.GetLevelTopScore(Managers.Game.Preferences.CurrentPackName, Managers.Game.Preferences.CurrentLevelName, Managers.Game.Preferences.GameType); //Load the level from the pack-#.xml the base class has the implementation base.LoadLevelObjects(); MAXTURNS = Managers.Game.CurrentLevelXmlInfo.Maxturns; // Messenger.AddListener(CurrentMemeko.gameObject.GetInstanceID() + "EnterSelected", () => FSMGameLogic.RaiseEvent("Selecting")); Messenger.AddListener(CurrentMemeko.gameObject.GetInstanceID() + "EnterSelected", () => FSMGameLogic.RaiseEvent("Selecting")); Messenger.AddListener(CurrentMemeko.gameObject.GetInstanceID() + "UnSelectPlayer", () => FSMGameLogic.RaiseEvent("ReadyToPlay")); }
/// <summary> /// Creates a new instance of the SdkWrapper. /// </summary> public Sdk() { context = SynchronizationContext.Current; sdk = new iRacingSDK(); EventRaiseType = EventRaiseTypes.CurrentThread; readMutex = new Mutex(false); TelemetryUpdateFrequency = 60; Replay = new ReplayControl(this); Camera = new CameraControl(this); PitCommands = new PitCommandControl(this); Chat = new ChatControl(this); Textures = new TextureControl(this); TelemetryRecording = new TelemetryRecordingControl(this); deserializer = new DeserializerBuilder() .IgnoreUnmatchedProperties() .WithTypeConverter(new NumericTypeConverter()) .WithTypeConverter(new DoubleUnitTypeConverter()) .WithTypeConverter(new BooleanTypeConverter()) .WithTypeConverter(new EnumTypeConverter()) .WithTypeConverter(new ColorTypeConverter()) .WithTypeConverter(new TimeSpanTypeConverter()) .Build(); }
public void OnClickGraphTab() { if (graph) { return; } if (buttonAudio != null) { buttonAudio.Play(); } graph = true; graphTab.transform.SetAsLastSibling(); graphTab.GetComponent <Image>().color = Util.GraphTabOnColor; propertiesTab.GetComponent <Image>().color = Util.PropertiesTabOffColor; grapharea.SetActive(true); propertiesarea.SetActive(false); if (focusedObject == null) { grapharea.SetActive(false); return; } ReplayControl rc = focusedObject.GetComponent <ReplayControl>(); if (rc == null) { grapharea.SetActive(false); } }
void Awake() { discreteQueued = GetComponent<QueuedControl>(); continousControl = GetComponent<ContinuousControl>(); hexesControl = GetComponent<HexToHexControl>(); discreteControl = GetComponent<DiscreteMovement>(); hexQueuedControl = GetComponent<HexQueuedCntrl>(); turnControl = GetComponent<TurnBasedControl>(); simulatedControl = GetComponent<SimulatedControl>(); replayControl = GetComponent<ReplayControl>(); }
// Have external be listening for events- depending on the string attached? void Awake() { mv = GetComponent <MovementType>(); hexQueuedMovement = GetComponent <HexQueuedCntrl>(); discreteMovement = GetComponent <DiscreteMovement>(); hexhexControl = GetComponent <HexToHexControl>(); disQueuedMovement = GetComponent <QueuedControl>(); turnControl = GetComponent <TurnBasedControl>(); simulatedControl = GetComponent <SimulatedControl>(); replayControl = GetComponent <ReplayControl>(); }
/// <summary> /// Occurs when the main form is loading /// </summary> private void MainWindow_OnLoaded(object sender, RoutedEventArgs e) { if (!(DataContext is MainWindowViewModel viewModel)) return; viewModel.InitViewModel(DialogCoordinator.Instance); ObjectControl.InitControl(); ReplayControl.InitControl(); viewModel.SelectionChanged += ViewModel_SelectionChanged; viewModel.SearchStarted += ViewModel_SearchStarted; }
void ApplyFirstLapCameraDirection(IEnumerable <DataSample> samples, ReplayControl replayControl) { iRacing.Replay.MoveToFrame(raceStartFrameNumber); iRacing.Replay.SetSpeed(1); iRacing.Replay.Wait(); Thread.Sleep(1000); replayControl.Process(samples.First()); iRacing.Replay.Wait(); Thread.Sleep(1000); }
/// <summary> /// Occurs when the user selects another tab /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (!(DataContext is MainWindowViewModel viewModel)) return; if (viewModel.SelectedTrack == null) return; if (TabControl.SelectedIndex == 2) // Replay tab { ReplayControl.LoadData(viewModel.SelectedTrack.TrackId); } else if (TabControl.SelectedIndex == 3) // Object tab { ObjectControl.LoadData(viewModel.SelectedTrack.TrackId); } }
// Update is called once per frame void Update() { if (PropertiesControlAreaScript.focusedObject == null) { return; } ReplayControl rc = PropertiesControlAreaScript.focusedObject.GetComponent <ReplayControl>(); if (rc == null) { return; } buttonAccelerationX.SetSelected(rc.graphOptions.Contains(GraphOptions.accelerationX)); buttonAccelerationY.SetSelected(rc.graphOptions.Contains(GraphOptions.accelerationY)); buttonVelocityX.SetSelected(rc.graphOptions.Contains(GraphOptions.velocityX)); buttonVelocityY.SetSelected(rc.graphOptions.Contains(GraphOptions.velocityY)); buttonPositionX.SetSelected(rc.graphOptions.Contains(GraphOptions.positionX)); buttonPositionY.SetSelected(rc.graphOptions.Contains(GraphOptions.positionY)); }
public void OnClickDisplacementY() { if (PropertiesControlAreaScript.focusedObject == null) { return; } ReplayControl rc = PropertiesControlAreaScript.focusedObject.GetComponent <ReplayControl>(); if (rc == null) { return; } buttonAudio.Play(); buttonPositionY.SetSelected(!buttonPositionY.selected); if (buttonPositionY.selected) { rc.graphOptions.Add(GraphOptions.positionY); } else { rc.graphOptions.Remove(GraphOptions.positionY); } }
public void OnClickVelocityX() { if (PropertiesControlAreaScript.focusedObject == null) { return; } ReplayControl rc = PropertiesControlAreaScript.focusedObject.GetComponent <ReplayControl>(); if (rc == null) { return; } buttonAudio.Play(); buttonVelocityX.SetSelected(!buttonVelocityX.selected); if (buttonVelocityX.selected) { rc.graphOptions.Add(GraphOptions.velocityX); } else { rc.graphOptions.Remove(GraphOptions.velocityX); } }
/// <summary> /// Occurs when the user selects another track /// </summary> private void ViewModel_SelectionChanged() { if (!(DataContext is MainWindowViewModel viewModel)) return; if (viewModel.SelectedTrack == null) return; if (TabControl.SelectedIndex == 2) { if (viewModel.SelectedTrack.ReplayCount == 0) TabControl.SelectedIndex = 0; else ReplayControl.LoadData(viewModel.SelectedTrack.TrackId); } else if (TabControl.SelectedIndex == 3) { if (viewModel.SelectedTrack.EmbeddedObjectsCount == 0) TabControl.SelectedIndex = 0; else ObjectControl.LoadData(viewModel.SelectedTrack.TrackId); } }
private bool?RaiseReplayControlEvent(PlayStatus status) { return(ReplayControl?.Invoke(status)); }
public void OnDrop(PointerEventData eventData) { if (eventData.pointerDrag == null) { return; } Vector3 pos = eventData.position; //check if pos is inside of scrollViewRect if (Util.OnCanvas(pos)) { //this is the object being dropped //instantiate a new object in the canvass GameObject ui = eventData.pointerDrag; ObjectDragHandler draghandler = ui.GetComponent <ObjectDragHandler>(); if (draghandler == null) { return; } GameObject reference = draghandler.spritePreFab; GameObject newObj = Instantiate(reference) as GameObject; newObj.SetActive(true); Vector3 worldPos = Camera.main.ScreenToWorldPoint(eventData.position); worldPos.z = 0; newObj.transform.position = worldPos; //Check for spring SpringControl spring = newObj.GetComponent <SpringControl>(); ForceControl force = newObj.GetComponent <ForceControl>(); VelocityControl velocity = newObj.GetComponent <VelocityControl>(); PropertiesEditable edit = newObj.GetComponent <PropertiesEditable>(); ReplayControl replay = newObj.GetComponent <ReplayControl>(); Name name = newObj.GetComponent <Name>(); if (spring != null) //if this is a spring { spring.attachPoint1 = worldPos + new Vector3(0, SpringControl.defaultHeight / 2f, 0); spring.attachPoint2 = worldPos - new Vector3(0, SpringControl.defaultHeight / 2f, 0); } if (force != null) //if this is a force arrow { force.attachPoint1 = worldPos + new Vector3(0, ForceControl.defaultHeight / 2f, 0); force.attachPoint2 = worldPos - new Vector3(0, ForceControl.defaultHeight / 2f, 0); } if (velocity != null) { velocity.attachPoint1 = worldPos + new Vector3(0, VelocityControl.defaultHeight / 2f, 0); velocity.attachPoint2 = worldPos - new Vector3(0, VelocityControl.defaultHeight / 2f, 0); } if (replay != null) { ReplayControl.focusedObject = newObj; } if (edit != null) { PropertiesEditable.focusedObject = newObj; } //if (name.objectname == "FixedRectangle" || name.objectname == "MoveableRectangle" || name.objectname == "Circle") //{ // Collider2D col = newObj.GetComponent<Collider2D>(); // PhysicsMaterial2D material = new PhysicsMaterial2D(); // material.friction = 0.4f; // material.bounciness = 0.4f; // col.sharedMaterial = material; //} } //otherwise do nothing; }
internal void _CaptureRaceTest(Action <string> onComplete, IEnumerable <DataSample> samples) { var overlayData = new OverlayData(); var removalEdits = new RemovalEdits(overlayData.RaceEvents); var commentaryMessages = new CommentaryMessages(overlayData); var videoCapture = new VideoCapture(); var recordPitStop = new RecordPitStop(commentaryMessages); var fastestLaps = new RecordFastestLaps(overlayData); var replayControl = new ReplayControl(samples.First().SessionData, incidents, removalEdits, TrackCameras); var sessionDataCapture = new SessionDataCapture(overlayData); var captureLeaderBoardEveryHalfSecond = new SampleFilter(TimeSpan.FromSeconds(0.5), new CaptureLeaderBoard(overlayData, commentaryMessages, removalEdits).Process); var captureCamDriverEveryQuaterSecond = new SampleFilter(TimeSpan.FromSeconds(0.25), new CaptureCamDriver(overlayData).Process); var captureCamDriverEvery4Seconds = new SampleFilter(TimeSpan.FromSeconds(4), new LogCamDriver().Process); TraceDebug.WriteLine("Cameras:"); TraceDebug.WriteLine(TrackCameras.ToString()); ApplyFirstLapCameraDirection(samples, replayControl); samples = samples .VerifyReplayFrames() .WithCorrectedPercentages() .WithCorrectedDistances() .WithFastestLaps() .WithFinishingStatus() .WithPitStopCounts() .TakeUntil(3.Seconds()).Of(d => d.Telemetry.LeaderHasFinished && d.Telemetry.RaceCars.All(c => c.HasSeenCheckeredFlag || c.HasRetired || c.TrackSurface != TrackLocation.OnTrack)) .TakeUntil(3.Seconds()).AfterReplayPaused(); if (shortTestOnly) { samples = samples.AtSpeed(Settings.Default.TimingFactorForShortTest); Settings.AppliedTimingFactor = 1.0 / Settings.Default.TimingFactorForShortTest; } videoCapture.Activate(workingFolder); var startTime = DateTime.Now; overlayData.CapturedVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); foreach (var data in samples) { var relativeTime = DateTime.Now - startTime; replayControl.Process(data); sessionDataCapture.Process(data); captureLeaderBoardEveryHalfSecond.Process(data, relativeTime); captureCamDriverEveryQuaterSecond.Process(data, relativeTime); recordPitStop.Process(data, relativeTime); fastestLaps.Process(data, relativeTime); removalEdits.Process(data, relativeTime); captureCamDriverEvery4Seconds.Process(data, relativeTime); } var files = videoCapture.Deactivate(); removalEdits.Stop(); var overlayFile = SaveOverlayData(overlayData, files); //terminate iRacing after video capture completed try { //ToBe added: Option to select/deselect termination of iRacing after capturing video in new settings Dialog Process[] iRacingProc = Process.GetProcessesByName("iRacingSim64DX11"); iRacingProc[0].Kill(); } catch { throw new Exception("Could not terminate iRacing Simulator".F(workingFolder)); } iRacing.Replay.SetSpeed(0); AltTabBackToApp(); if (files.Count == 0) { throw new Exception("Unable to find video files in '{0}' - possible wrong working folder".F(workingFolder)); } _WithOverlayFile(overlayFile); onComplete(overlayFile); }
private void OnExitScene() { ReplayControl.StopRecording(); }
//Analyse race situations at maximum replay speed w/o recording. void AnalyseRaceSituations(IEnumerable <DataSample> samples) { int iReplaySpeedForAnalysis = (int)replaySpeeds.FF16x; //set speed for analysis phase to FF16x //Start iRacing Replay from the beginning with maximum speed (16x) iRacing.Replay.MoveToFrame(raceStartFrameNumber); //---------------------------- // copied from iRacing.Capturing because race events in app V1.0.x.x are identified during capturing the whole video. // necessity of classes in analysis phase to be reviewed //---------------------------- //var overlayData = new OverlayData(); removalEdits = new RemovalEdits(overlayData.RaceEvents); commentaryMessages = new CommentaryMessages(overlayData); recordPitStop = new RecordPitStop(commentaryMessages); fastestLaps = new RecordFastestLaps(overlayData); replayControl = new ReplayControl(samples.First().SessionData, incidents, removalEdits, TrackCameras); sessionDataCapture = new SessionDataCapture(overlayData); //CAPTURING LEADERBOARD, CAMERAS will be done at FF16x. TO BE DETERMINED WHETHER STANDARD INTERVALS HAVE TO BE REDUCED BY FACTOR OF 16?! captureLeaderBoardEveryHalfSecond = new SampleFilter(TimeSpan.FromSeconds(0.5), new CaptureLeaderBoard(overlayData, commentaryMessages, removalEdits).Process); captureCamDriverEveryQuaterSecond = new SampleFilter(TimeSpan.FromSeconds(0.25), new CaptureCamDriver(overlayData).Process); captureCamDriverEvery4Seconds = new SampleFilter(TimeSpan.FromSeconds(4), new LogCamDriver().Process); //---------------------------- //end copy / end review //---------------------------- ApplyFirstLapCameraDirection(samples, replayControl); samples = samples .VerifyReplayFrames() .WithCorrectedPercentages() .WithCorrectedDistances() .WithFastestLaps() .WithFinishingStatus() .WithPitStopCounts() .TakeUntil(3.Seconds()).Of(d => d.Telemetry.LeaderHasFinished && d.Telemetry.RaceCars.All(c => c.HasSeenCheckeredFlag || c.HasRetired || c.TrackSurface != TrackLocation.OnTrack)) .TakeUntil(3.Seconds()).AfterReplayPaused(); samples = samples.AtSpeed(iReplaySpeedForAnalysis); overlayData.CapturedVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); ulong numberOfDataProcessed = 0; var startTime = DateTime.Now; foreach (var data in samples) { var relativeTime = (DateTime.Now - startTime).Multiply(iReplaySpeedForAnalysis); //calculate relative time in Replay taking into account replay speed (FF) replayControl.Process(data); sessionDataCapture.Process(data); captureLeaderBoardEveryHalfSecond.Process(data, relativeTime); captureCamDriverEveryQuaterSecond.Process(data, relativeTime); recordPitStop.Process(data, relativeTime); fastestLaps.Process(data, relativeTime); removalEdits.Process(data, relativeTime); captureCamDriverEvery4Seconds.Process(data, relativeTime); numberOfDataProcessed += 1; } removalEdits.Stop(); TraceDebug.WriteLine("Race analysis phase completed. {0} data samples processed with replay speed {1}".F(numberOfDataProcessed, iReplaySpeedForAnalysis)); //save OverlayData into target folder for video ("working folder") SaveReplayScript(overlayData); TraceDebug.WriteLine("Replay Script saved to disk"); iRacing.Replay.SetSpeed(0); }
internal void _CaptureRaceTest(Action <string> onComplete, IEnumerable <DataSample> samples) { //identify wheather highlights video only is selected and OBS pause/resume can be used (to be implemented) if (bRecordUsingPauseResume) { //Retrieve list of raceEvents selected depending on the duration of the highlight video var totalRaceEvents = RaceEventExtension.GetInterestingRaceEvents(overlayData.RaceEvents.ToList()); ApplyFirstLapCameraDirection(samples, replayControl); //Record the selected race events into a highlight video raceVideo.Activate(workingFolder); //Active video-capturing and send start command to recording software. OverlayData.CamDriver curCamDriver = overlayData.CamDrivers.First(); //start thread to control / switch cameras while recording ReplayControl.cameraControl.ReplayCameraControlTask(overlayData); //ReplayControl.cameraControl.CameraOnDriver(short.Parse(curCamDriver.CurrentDriver.CarNumber), (short)curCamDriver.camGroupNumber); //cycle through all raceEvents selected for the highlight video and record them (REMARK: Camera switching not implemented yet) foreach (var raceEvent in totalRaceEvents) { TraceInfo.WriteLine("ADV_RECORDING: Type: {0} | Durations-Span: {1} | ".F(raceEvent.GetType(), raceEvent.Duration)); //jump to selected RaceEvent in iRacing Replay int framePositionInRace = raceStartFrameNumber + (int)Math.Round(raceEvent.StartTime * 60.0); iRacing.Replay.MoveToFrame(raceStartFrameNumber + (int)Math.Round(raceEvent.StartTime * 60.0)); iRacing.Replay.SetSpeed((int)replaySpeeds.normal); //start iRacing Replay at selected position raceVideo.Resume(); //resume recording TraceDebug.WriteLine("Recording Race-Event. Frame-Position: {0} | Duration: {1} ms".F(framePositionInRace, 1000 * raceEvent.Duration)); Thread.Sleep((int)(1000 * raceEvent.Duration)); //pause thread until scene is fully recorded. raceVideo.Pause(); //pause recording software before jumping to new position in iRacing Replay } TraceDebug.WriteLine("Video Capture of Race-Events completed"); raceVideo.Stop(); } else //Code to be removed after being able to implment working solution where analysis phase and replay-capture phase are distinct processes. //use local variables for original code instead of global variables introduced to support full analysis in analysis-phase { var overlayData = new OverlayData(); var removalEdits = new RemovalEdits(overlayData.RaceEvents); var commentaryMessages = new CommentaryMessages(overlayData); var recordPitStop = new RecordPitStop(commentaryMessages); var fastestLaps = new RecordFastestLaps(overlayData); var replayControl = new ReplayControl(samples.First().SessionData, incidents, removalEdits, TrackCameras); var sessionDataCapture = new SessionDataCapture(overlayData); var captureLeaderBoardEveryHalfSecond = new SampleFilter(TimeSpan.FromSeconds(0.5), new CaptureLeaderBoard(overlayData, commentaryMessages, removalEdits).Process); var captureCamDriverEveryQuaterSecond = new SampleFilter(TimeSpan.FromSeconds(0.25), new CaptureCamDriver(overlayData).Process); var captureCamDriverEvery4Seconds = new SampleFilter(TimeSpan.FromSeconds(4), new LogCamDriver().Process); TraceDebug.WriteLine("Cameras:"); TraceDebug.WriteLine(TrackCameras.ToString()); var videoCapture = new VideoCapture(); ApplyFirstLapCameraDirection(samples, replayControl); samples = samples .VerifyReplayFrames() .WithCorrectedPercentages() .WithCorrectedDistances() .WithFastestLaps() .WithFinishingStatus() .WithPitStopCounts() .TakeUntil(3.Seconds()).Of(d => d.Telemetry.LeaderHasFinished && d.Telemetry.RaceCars.All(c => c.HasSeenCheckeredFlag || c.HasRetired || c.TrackSurface != TrackLocation.OnTrack)) .TakeUntil(3.Seconds()).AfterReplayPaused(); if (shortTestOnly) { samples = samples.AtSpeed(Settings.Default.TimingFactorForShortTest); Settings.AppliedTimingFactor = 1.0 / Settings.Default.TimingFactorForShortTest; } videoCapture.Activate(workingFolder); //Start video capturing FileName will be given by recording software. var startTime = DateTime.Now; overlayData.CapturedVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); foreach (var data in samples) { var relativeTime = DateTime.Now - startTime; TraceDebug.WriteLine("Recording at time: {0}", relativeTime); replayControl.Process(data); sessionDataCapture.Process(data); captureLeaderBoardEveryHalfSecond.Process(data, relativeTime); captureCamDriverEveryQuaterSecond.Process(data, relativeTime); recordPitStop.Process(data, relativeTime); fastestLaps.Process(data, relativeTime); removalEdits.Process(data, relativeTime); captureCamDriverEvery4Seconds.Process(data, relativeTime); } var files = videoCapture.Deactivate(); //Stop video capturing - returns list with "guessed" filename. Filenmae being different from replay-script due to different time stamp. //investigate whether renaming of video file is necessary. removalEdits.Stop(); var overlayFile = SaveOverlayData(overlayData, files); iRacing.Replay.SetSpeed(0); AltTabBackToApp(); if (files.Count == 0) { throw new Exception("Unable to find video files in '{0}' - possible wrong working folder".F(workingFolder)); } _WithOverlayFile(overlayFile); onComplete(overlayFile); } //terminate iRacing after video capture completed to free up CPU resources if (bCloseiRacingAfterRecording) { try { //To be added: Option to select/deselect termination of iRacing after capturing video in new settings Dialog Process[] iRacingProc = Process.GetProcessesByName("iRacingSim64DX11"); iRacingProc[0].Kill(); } catch { throw new Exception("Could not terminate iRacing Simulator".F(workingFolder)); } } }