void OnMouseDown()
    {
        // ----- PARTIE NATHAN -----
        // Envoies des positions
        for (int i = 1; i <= 6; i++)
        {
            PlayerPrefs.SetInt("P" + i, PlayerPrefs.GetInt("LaPosition" + i));
        }
        // Envoies le nombre de joueur
        PlayerPrefs.SetInt("nombreJoueur", PlayerPrefs.GetInt("nbJoueur"));
        int indice = 1;

        for (int i = 0; i <= 5; i++)
        {
            if (PlayerPrefs.GetInt("P" + (i + 1)) == 0)
            {
                positions[i] = 0;
            }
            else
            {
                positions[i] = indice;
                indice++;
            }     // Position des joueurs
        }
        for (int i = 0; i < 6; i++)
        {
            Debug.Log("positions[" + i + "] = " + positions[i]);
        }
        envoi = positions;
        for (int i = 0; i < 6; i++)
        {
            Debug.Log("envoi[" + i + "] = " + envoi[i]);
        }
        MyPositionsMessage message = new MyPositionsMessage();

        message.position1 = positions[0];
        message.position2 = positions[1];
        message.position3 = positions[2];
        message.position4 = positions[3];
        message.position5 = positions[4];
        message.position6 = positions[5];
        NetworkServer.SendToAll(positionsID, message);
        Debug.Log("envoi des positions");

        // --------------------------

        // Debug.Log("Click");
        SceneManager.LoadScene("Scene_2");
    }
Example #2
0
    void OnMouseDown()
    {
        // Envoi des positions
        for (int i = 1; i <= 6; i++)
        {
            PlayerPrefs.SetInt("P" + i, PlayerPrefs.GetInt("LaPosition" + i));
        }
        // Envoies le nombre de joueur
        PlayerPrefs.SetInt("nombreJoueur", PlayerPrefs.GetInt("nbJoueur"));
        int indice = 1;

        for (int i = 0; i <= 5; i++)
        {
            if (PlayerPrefs.GetInt("P" + (i + 1)) == 0)
            {
                positions[i] = 0;
            }
            else
            {
                positions[i] = indice;
                indice++;
            }     // Position des joueurs
        }
        Partie.Positions = positions;

        for (int i = 0; i < Partie.Positions.Length; i++)
        {
            if (Partie.Positions[i] != 0)
            {
                Joueur j = new Joueur();
                j.Numero   = Partie.Positions[i];
                j.Position = i;
                if (Partie.Type != "expert")
                {
                    j.Dimensions  = RandomDim();
                    j.Locomotions = RandomLoco();
                    j.Equipements = RandomEqui();
                    j.Persos      = RandomPerso();
                }
                Partie.AddPlayer(j);
            }
        }

        MyPositionsMessage message = new MyPositionsMessage();

        int pub;
        int priv;

        if (Partie.Type == "expert")
        {
            pub = Random.Range(1, Partie.Joueurs.Count);
            if (pub == Partie.Joueurs.Count)
            {
                priv = 1;
            }
            else
            {
                priv = pub + 1;
            }

            foreach (Joueur j in Partie.Joueurs)
            {
                if (pub == j.Numero)
                {
                    j.IsPublic = true;
                }
                else if (priv == j.Numero)
                {
                    j.IsPrive = true;
                }
            }
        }
        message.position1 = positions[0];
        message.position2 = positions[1];
        message.position3 = positions[2];
        message.position4 = positions[3];
        message.position5 = positions[4];
        message.position6 = positions[5];
        message.langue    = Partie.Langue;
        message.type      = Partie.Type;
        NetworkServer.SendToAll(positionsID, message);

        // --------------------------

        canvas_mains.SetActive(false);
        canvas_joueurs.SetActive(true);
    }