Beispiel #1
0
 private void Client_onNewConfiguration(object obj, ConfigEvent configArgs)
 {
     if (this.Config == null)
     {
         this.Config       = configArgs.Config;
         this.canStartGame = true;
     }
 }
    private static ReaLabConfiguration DeconstructConfiguration(byte[] trame)
    {
        ReaLabConfiguration config;

        // Taille du nom codé sur 2 byte car c'est un ushort
        ushort lastNameCount = (ushort)BitConverter.ToInt16(trame, indiceTrame);

        indiceTrame += 2;
        string lastName = Encoding.ASCII.GetString(trame, indiceTrame, lastNameCount);

        indiceTrame += lastNameCount;

        // Taille du prénom codé sur 2 byte car c'est un ushort
        ushort firstNameCount = (ushort)BitConverter.ToInt16(trame, indiceTrame);

        indiceTrame += 2;
        string firstName = Encoding.ASCII.GetString(trame, indiceTrame, firstNameCount);

        indiceTrame += firstNameCount;

        // Année de naissance codé sur 2 byte car c'est un ushort
        ushort year = (ushort)BitConverter.ToInt16(trame, 0);

        indiceTrame += 2;
        // Mois de naissance codé sur un byte
        int month = trame[indiceTrame];

        indiceTrame++;
        // Jour de naissance codé sur un byte
        int day = trame[indiceTrame];

        indiceTrame++;

        // Difficulté du jeu codé sur un byte
        int difficulty = trame[indiceTrame];

        indiceTrame++;
        // Zoom du jeu codé sur un byte
        int zoom = trame[indiceTrame];

        indiceTrame++;
        // Niveau à charger codé sur un byte
        int level = trame[indiceTrame];

        indiceTrame++;
        // Etat du debug
        byte debugByte = trame[indiceTrame];

        indiceTrame++;
        bool debug = (debugByte == 0) ? false : true;

        config = new ReaLabConfiguration(lastName, firstName, new DateTime(year, month, day), difficulty, zoom, level, debug);
        return(config);
    }
Beispiel #3
0
        /// <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);
        }
 public ConfigEvent(ReaLabConfiguration config)
 {
     this.config = config;
 }