/// <summary> /// Arret le serveur de communication et coupe le jeu unity /// </summary> public void StopGame() { if (this.server != null) { this.server.onNewTrajectory -= new NewTrajectoryHandler(server_onNewTrajectory); this.server.onLevelStarted -= new NewLevelStartedHandler(server_onLevelStarted); this.server.onCheckpointReached -= new NewCheckpointReachedHandler(server_onCheckpointReached); this.server.onLevelStopped -= new NewLevelStoppedHandler(server_onLevelStopped); this.server.StopGame(); if (this.gameProcess != null) { //this.gameProcess.Kill(); this.gameProcess = null; } Thread.Sleep(10); this.server.Stop(); this.server = null; } }
/// <summary> /// Démarre le serveur de communication et lance le jeu unity /// </summary> public void StartGame() { if (this.server != null) { this.server.Stop(); } // Démarrage du serveur et envoie de la config this.server = new ReaLabServer("127.0.0.1", 8888, 8889); this.server.Start(); var config = new ReaLabConfiguration(singleton.Patient.Nom, singleton.Patient.Prenom, singleton.PatientSingleton.DateNaiss, this.difficulty, this.zoom, this.level, false); this.server.SetReaLabConfiguration(config); this.server.onNewTrajectory += new NewTrajectoryHandler(server_onNewTrajectory); this.server.onLevelStarted += new NewLevelStartedHandler(server_onLevelStarted); this.server.onCheckpointReached += new NewCheckpointReachedHandler(server_onCheckpointReached); this.server.onLevelStopped += new NewLevelStoppedHandler(server_onLevelStopped); // Lancement du jeu if (this.gameProcess != null) { this.gameProcess.Kill(); } // Trouve le handler de la fenetre mainP //var handler = this.GetHandle("ReaPlan patient"); // Creation du process du jeu this.gameProcess = new Process(); this.gameProcess.StartInfo.FileName = PATHTOGAME; //this.gameProcess.StartInfo.Arguments = "-parentHWND " + handler.ToInt32() + " " + Environment.CommandLine; //this.gameProcess.StartInfo.UseShellExecute = true; //this.gameProcess.StartInfo.CreateNoWindow = true; this.gameProcess.Start(); this.gameProcess.WaitForInputIdle(); //EnumChildWindows(handler, this.WindowEnum, IntPtr.Zero); }