void setListaModelos(OscMessage m)
 {
     string[] nombres_modelos = new string[m.GetInt(0)];
     Debug.Log(m.GetInt(0));
     for (int i = 0; i < nombres_modelos.Length; i++)
     {
         nombres_modelos[i] = m.GetString(1 + i);
         Debug.Log(m.GetString(1 + i));
     }
     info.setModelos(nombres_modelos);
 }
    void setListaPartes(OscMessage m)
    {
        string nombre_modelo_actual = m.GetString(0);

        string[] nombres_partes = new string[m.GetInt(1)];
        for (int i = 0; i < nombres_partes.Length; i++)
        {
            nombres_partes[i] = m.GetString(2 + i);
        }
        info.setPartes(nombre_modelo_actual, nombres_partes);
    }
Esempio n. 3
0
    // FUNCTION POUR ACTIVER OU DESACTIVER DES OBJECTS

    void enableObject(OscMessage message)
    {
        // Pour activer ou deactivers des objets, j'ai prévu isi de toujours travailler des childrens.
        // Unity n'arrivant pas à trouver les objets désactivé dans le vide.
        // Il arrive par contre à trouver les objets enfant.
        // A en croire les forums, il existe une astuce pour éviter ce problème mais pour moi
        // ça me permet de trier mes objets donc je n'ai pas pousser dans ce sens pour le moment.

        // Dans ce cas là, la commande sera la suivante :
        // "/enable <nom du parent> <nom de l'objet cible> 1/0" 1 pour activer et 0 pour désactiver bien sûr.
        GameObject.Find(message.GetString(0)).transform.Find(message.GetString(1)).gameObject.SetActive(message.GetInt(2) != 0);
    }
Esempio n. 4
0
/*
 *  -------------------------------------
 *  -----------SERVER FUNCTIONS----------
 *  -------------------------------------
 */


    // server side
    void RegistationRequestedFromPlayer(OscMessage message)
    {
        if (gameEngine.debugMode)
        {
            Debug.Log("Received : " + message);
        }

        if (gameEngine._userRole == UserRole.Server)
        {
            int playerID = message.GetInt(0);

            int    requestedPort = message.GetInt(1);
            string playerIP      = message.GetString(2);

            UserRole role;
            int      isPlayer = message.GetInt(3);
            if (isPlayer == 1)
            {
                role = UserRole.Player;
            }
            else if (isPlayer == 2)
            {
                role = UserRole.Tracker;
            }
            else
            {
                role = UserRole.Viewer;
            }

            string playerName = message.GetString(4);

            bool available = gameEngine.networkManager.CheckAvailability(userManager, requestedPort, playerIP, gameEngine.gameData.runInLocal);

            if (available)
            {
                UserData user = userManager.AddNewUser(gameEngine, playerID, playerName, playerIP, requestedPort, role, userManager.CountPlayers());
                if (role == UserRole.Player)
                {
                    sender.AddNewPlayerToClientsGames(playerID, playerName, userManager.usersPlaying, isPlayer, userManager.usersPlaying.Count - 1); // minus1 because server had already added user in list
                }
                sender.SendRegistrationConfirmation(user);
            }
            else
            {
                sender.RefuseRegistration(playerIP, requestedPort);
            }
        }
    }
Esempio n. 5
0
    void AddPlayerToGame(OscMessage message)
    {
        if (gameEngine.debugMode)
        {
            Debug.Log("Received : " + message);
        }
        int playerID = message.GetInt(0);

        UserRole userRole;
        int      playerRole = message.GetInt(1);

        if (playerRole == 1)
        {
            userRole = UserRole.Player;
        }
        else if (playerRole == 2)
        {
            userRole = UserRole.Tracker;
        }
        else
        {
            userRole = UserRole.Viewer;
        }

        string playerName = message.GetString(2);
        int    rank       = message.GetInt(3);

        if ((gameEngine._userRole == UserRole.Player || gameEngine._userRole == UserRole.Viewer || gameEngine._userRole == UserRole.Tracker) && playerID != gameEngine._user._ID)
        {
            Debug.Log(playerID + " vs " + gameEngine._user._ID);
            userManager.AddNewUser(gameEngine, playerID, playerName, "null", -1, userRole, rank);
            gameEngine.userManager.ChangeVisualisationMode(gameEngine.currentVisualisationMode, gameEngine, false); // trigger the change mode again, to actualize to new players
        }
    }
Esempio n. 6
0
    void VisualisationModeChange(OscMessage message)
    {
        Debug.Log("Received : " + message);
        string mode   = message.GetString(0);
        int    toFade = message.GetInt(1);

        userManager.ChangeVisualisationMode(mode, gameEngine, toFade == 1);
    }
    void MessageHandler(OscMessage message)
    {
        string message_str = message.GetString(0);

        Debug.Log("Entrei: " + message.GetString(0));

        switch (message_str)
        {
        case "action":
            fire = true;
            break;

        case "jump":
            jump = true;
            break;

        case "stop":
            jump = false;
            break;

        case "left":
            left    = true;
            _timer += Time.time + _coolDown;
            _move   = -1;
            break;

        case "right":
            right   = true;
            _timer += Time.time + _coolDown;
            _move   = 1;
            break;

        case "piano":
            shield = true;
            break;

        default:
            Debug.Log("Unknown message: " + message);
            break;
        }
    }
Esempio n. 8
0
    void EnvironmentChangedByServer(OscMessage message)
    {
        if (gameEngine.debugMode)
        {
            Debug.Log("Received : " + message);
        }

        string envType = message.GetString(0);
        int    val     = message.GetInt(1);

        if (envType == "mirror")
        {
            gameEngine.scenarioEvents.ToggleMirror(val == 1, 0, message.GetInt(2));
        }
    }
Esempio n. 9
0
/*
 *  -------------------------------------
 *  -----------CLIENT FUNCTIONS----------
 *  -------------------------------------
 */

    void RegistrationConfirmed(OscMessage message)
    {
        int playerID = message.GetInt(1);

        if (playerID == gameEngine._user._ID && gameEngine.appState == AppState.WaitingForServer)
        {
            if (gameEngine.debugMode)
            {
                Debug.Log("Received : " + message);
            }
            int    sessionID         = message.GetInt(0);
            int    requestedPort     = message.GetInt(2);
            string visualisationMode = message.GetString(3);
            int    rank         = message.GetInt(4);
            int    recordAudio  = message.GetInt(5);
            int    recordLength = message.GetInt(6);
            gameEngine.EndStartProcess(sessionID, playerID, requestedPort, visualisationMode, rank, recordAudio, recordLength);
        }
    }
Esempio n. 10
0
        void messageHandler(OscMessage message)
        {
            if (MainSettingsVars.currentAnimationComponent == null)
            {
                return;
            }
            if (MainSettingsVars.data.currentGameMode != gameMode.live && MainSettingsVars.data.currentGameMode != gameMode.record_points)
            {
                return;
            }
            if (message.address.IndexOf("/point/") == 0 && message.values.Count == 3)
            {
                parts = message.address.Split(splitter, System.StringSplitOptions.RemoveEmptyEntries);
                point = int.Parse(parts[1]);
                // restrict number of points
                if (point >= MainSettingsVars.pointsLength)
                {
                    return;
                }
                // collect points into dictionary
                MainSettingsVars.currentAnimationComponent.collectPoints(point, message.GetFloat(0), message.GetFloat(1), message.GetFloat(2));
                return;
            }
            else if (message.address.IndexOf("/group/") == 0)
            {
                parts = message.address.Split(splitter, System.StringSplitOptions.RemoveEmptyEntries);
                group = int.Parse(parts[1]);
                switch (parts[2])
                {
                case "active":
                    MainSettingsVars.currentAnimationComponent.meshComponents[group].active = message.GetBool(0);
                    break;

                case "peaks":
                    MainSettingsVars.currentAnimationComponent.meshComponents[group].peaks = message.GetInt(0);
                    break;

                case "level":
                    MainSettingsVars.currentAnimationComponent.meshComponents[group].level = message.GetFloat(0);
                    break;
                }
                return;
            }
            else if (message.address == "/fps")
            {
                MainSettingsVars.currentAnimationComponent.data.fps = message.GetInt(0);
                return;
            }
            else if (message.address == "/x_low")
            {
                MainSettingsVars.currentAnimationComponent.data.x_low = message.GetFloat(0);
                return;
            }
            else if (message.address == "/x_high")
            {
                MainSettingsVars.currentAnimationComponent.data.x_high = message.GetFloat(0);
                return;
            }
            else if (message.address == "/y_low")
            {
                MainSettingsVars.currentAnimationComponent.data.y_low = message.GetFloat(0);
                return;
            }
            else if (message.address == "/y_high")
            {
                MainSettingsVars.currentAnimationComponent.data.y_high = message.GetFloat(0);
                return;
            }
            else if (message.address == "/z_low")
            {
                MainSettingsVars.currentAnimationComponent.data.z_low = message.GetFloat(0);
                return;
            }
            else if (message.address == "/z_high")
            {
                MainSettingsVars.currentAnimationComponent.data.z_high = message.GetFloat(0);
                return;
            }
            else if (message.address == "/audio_file_path")
            {
                MainSettingsVars.currentAnimationComponent.data.audio_file_path = message.GetString();
                return;
            }
            else if (message.address == "/active")
            {
                MainSettingsVars.currentAnimationComponent.active = message.GetBool(0);
                return;
            }
            Debug.Log("HALFTHEORY: " + this.GetType() + ": no function found for " + message.address);
        }