Exemple #1
0
    private void envoiChrono(int premierFini)
    {
        MyNetworkMessage message = new MyNetworkMessage();

        message.message = premierFini;
        NetworkServer.SendToAll(chronoID, message);
    }
Exemple #2
0
    //public void ConnectClient(string ip)
    //{
    //    // クライアント開始
    //    client = new NetworkClient();
    //    //Debug.Log("クライアント開始キテルグマ");

    //    // サーバーに接続
    //    client.Connect(ipInput.text, 7000);
    //}

    public bool SendMessage(MessageInfo message)
    {
        var mes = new MyNetworkMessage();

        mes.myMessageInfo.fromPlayerID = message.fromPlayerID;
        mes.myMessageInfo.messageType  = message.messageType;
        if (message.exInfo != null)
        {
            mes.myMessageInfo.exInfo = new byte[256];
            int size = message.exInfo.Length;
            Buffer.BlockCopy(message.exInfo, 0, mes.myMessageInfo.exInfo, 0, size);
        }
        //client.Send(Msg.MyMessage, mes);
        // サーバーに届くまでMsg.Textを送り続ける
        for (int i = 0; ; i++)
        {
            if (client == null)
            {
                return(false);
            }
            if (client.Send(Msg.MyMessage, mes))
            {
                return(true);
            }

            // 114514回送っても返事が来ないので死んでどうぞ
            if (i > 114514)
            {
                Application.Quit();
            }
        }
    }
Exemple #3
0
    ////lorsqu'un joueur appuie sur valider, on stocke les choix du joueur, met à jour les caractéristique du robot
    //// et on passe au canvas suivant
    private void ButtonClicked()
    {
        JoueurStatic.Dim   = dim.sprite;
        JoueurStatic.Loco  = loco.sprite;
        JoueurStatic.Equi1 = equi0.sprite;
        JoueurStatic.Equi2 = equi1.sprite;
        JoueurStatic.Equi3 = equi2.sprite;
        MyNetworkMessage conception = new MyNetworkMessage();

        conception.message = JoueurStatic.Numero;
        JoueurStatic.Client.Send(conceptionID, conception);
        MyImageMessage robot = new MyImageMessage();

        robot.loco  = loco.sprite.name;
        robot.dim   = dim.sprite.name;
        robot.equi1 = equi0.sprite.name;
        robot.equi2 = equi1.sprite.name;
        robot.equi3 = equi2.sprite.name;
        robot.num   = JoueurStatic.Numero;
        robot.zone  = JoueurStatic.Position;
        JoueurStatic.Client.Send(idMessage, robot);

        canvas_choix_cartes.SetActive(false);
        canvas_pres_robot.SetActive(true);
    }
Exemple #4
0
    void OnMessageBroadcast(string Mess)
    {
        MyNetworkMessage messageBr = new MyNetworkMessage();

        messageBr.message = "Get someone client : " + Mess;
        NetworkServer.SendToAll(messageID, messageBr);
    }
Exemple #5
0
    //sends a string to the server
    public void SendMsg(string message)
    {
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = message;
        messageContainer.id      = myID;
        myClient.Send(MyMessageTypes.str, messageContainer);
    }
Exemple #6
0
    public void OnStart()
    {
        MyNetworkMessage messageEv = new MyNetworkMessage();

        messageEv.message = "On Start!";
        client.Send(messageID, messageEv);
        //anim.SetFloat("AnimSpeed", anim.GetFloat("AnimSpeed") + 1);
    }
Exemple #7
0
    public void SendMessageToAll(string message)
    {
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = message;

        NetworkServer.SendToAll(messageID, messageContainer);
    }
Exemple #8
0
    public void SpeedUp()
    {
        //anim.SetFloat("AnimSpeed", anim.GetFloat("AnimSpeed") + 1);
        MyNetworkMessage messageEv = new MyNetworkMessage();

        messageEv.message = "On SpeedUp!";
        client.Send(messageID, messageEv);
    }
Exemple #9
0
    public void SendMessage(int clientNumber, string message)
    {
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = message;

        NetworkServer.SendToClient(clientNumber, messageID, messageContainer);
    }
Exemple #10
0
    private void BoutonRetourClicked()
    {
        MyNetworkMessage msg = new MyNetworkMessage();

        NetworkServer.SendToAll(retourID, msg);
        canvas_choix_vainqueur.SetActive(false);
        canvas_debat.GetComponent <InitDebat>().Retour = true;
        canvas_debat.SetActive(true);
    }
Exemple #11
0
    private void OnDebatReceived(NetworkMessage netMsg)
    {
        MyNetworkMessage msg = new MyNetworkMessage();

        NetworkServer.SendToAll(debatclientID, msg);

        canvas_pres_persos.SetActive(false);
        canvas_debat.SetActive(true);
    }
Exemple #12
0
    private void ButtonClicked()
    {
        int joueurCourant    = Initialisation.premierJoueur;
        MyNetworkMessage msg = new MyNetworkMessage();

        msg.message = joueurCourant;
        NetworkServer.SendToAll(waitID, msg);
        SceneManager.LoadScene("Scene5");
    }
Exemple #13
0
    public void SendMessage(string message)
    {
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = message;

        // Say hi to the server when connected
        client.Send(messageID, messageContainer);
    }
Exemple #14
0
    void onSpace()
    {
        Debug.Log("now in onSpace void!");
        MyNetworkMessage messageSpace = new MyNetworkMessage();

        messageSpace.message = "On space!";
        client.Send(messageID, messageSpace);
        //GameObject.Find("Cube").transform.RotateAround(Vector3.zero, Vector3.up, 100 * Time.deltaTime);
    }
Exemple #15
0
    // connexion d'un joueur sur un des boutons du client
    void OnMessageReceived(NetworkMessage message)
    {
        int id = message.ReadMessage <MyNetworkMessage>().message;
        MyNetworkMessage msg = new MyNetworkMessage();

        msg.message = id;
        NetworkServer.SendToAll(messageID, msg);
        Text_Connexion.recupInfoJoueur(id);
    }
Exemple #16
0
    public void Broadcast(string msg)
    {
        // Send a message to all the clients connected
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = msg;

        // Broadcast a message a to everyone connected
        NetworkServer.SendToAll(messageID, messageContainer);
    }
Exemple #17
0
    // public void SendMsgToServer()
    // {
    //     string sendMsg = inputField.text;
    //     MyNetworkMessage messageContainer = new MyNetworkMessage();
    //     messageContainer.message = sendMsg;
    //     Debug.Log("Send Message to server:" + sendMsg);

    //     // Say hi to the server when connected
    //     client.Send(messageID,messageContainer);
    // }

    public void SendMsgToServer(string msg)
    {
        string           sendMsg          = msg;
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = sendMsg;
        Debug.Log("Send Message to server:" + sendMsg);

        // Say hi to the server when connected
        client.Send(messageID, messageContainer);
    }
Exemple #18
0
    //вызывается при присоединении на сервер
    //создает новый экзмепляр и отправляет сообщение на сервер
    void OnConnected(NetworkMessage message)
    {
        connected                     = true;
        MessageLog.text               = "Connection succesfull";
        ButtonConnect.interactable    = false;
        ButtonDisconnect.interactable = true;
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = "Hello server!";
        client.Send(messageID, messageContainer);
    }
    void OnConnected(NetworkMessage message)
    {
        // Do stuff when connected to the server

        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = "Score: " + GameData.Points.Combined.Get();

        // Say hi to the server when connected
        _client.Send(_messageID, messageContainer);
    }
Exemple #20
0
    void OnConnected(NetworkMessage message)
    {
        // Do stuff when connected to the server

        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = "Hello server!";

        // Say hi to the server when connected
        client.Send(messageID, messageContainer);
    }
Exemple #21
0
    void OnConnected(NetworkMessage message)
    {
        // Do stuff when connected to the server
        Debug.Log("onConnected");
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = "Hello server!";
        Debug.Log("Client connected");
        Debug.Log("Send Message to server");

        // Say hi to the server when connected
        client.Send(messageID, messageContainer);
    }
Exemple #22
0
    public void Restart()
    {
        currentMessage = null;
        waitTimer      = 0;

        sendMessageNumber = 0;
        //receiveMessageNumber = 0;
        for (int i = 0; i < messageBuffer.Length; i++)
        {
            messageBuffer[i]             = new MessageInfo();
            messageBuffer[i].messageType = MessageType.NoMessage;
        }
    }
Exemple #23
0
    private void ButtonClicked()
    {
        joueur       = MainScript.joueur;
        joueur.Dim   = dim.sprite;
        joueur.Loco  = loco.sprite;
        joueur.Equi1 = equi0.sprite;
        joueur.Equi2 = equi1.sprite;
        joueur.Equi3 = equi2.sprite;
        MyNetworkMessage conception = new MyNetworkMessage();

        conception.message = position;
        client.Send(conceptionID, conception);
        MyImageMessage test  = new MyImageMessage();
        MyImageMessage robot = new MyImageMessage();

        //string s = UnityEditor.AssetDatabase.GetAssetPath(loco.sprite);
        robot.loco  = loco.sprite.ToString();
        robot.dim   = dim.sprite.ToString();
        robot.equi1 = equi0.sprite.ToString();
        robot.equi2 = equi1.sprite.ToString();
        robot.equi3 = equi2.sprite.ToString();
        robot.num   = position;
        // Debug.Log("zone : " + selectUser.zone);
        robot.zone = selectUser.zone;
        client.Send(idMessage, robot);
        RandomPerso();
        SceneManager.LoadScene("scene2bis");
        //if (position == SansHUD.premierFini) {
        //    MyImageMessage mLoco = new MyImageMessage();
        //    mLoco.image = loco.sprite.ToString();
        //    mLoco.type = "Locomotion";
        //    MyImageMessage mDim = new MyImageMessage();
        //    mDim.image = dim.sprite.ToString().ToString();
        //    mDim.type = "Dimension";
        //    MyImageMessage mEqui0 = new MyImageMessage();
        //    mEqui0.image = equi0.sprite.ToString().ToString();
        //    mEqui0.type = "Equipements";
        //    MyImageMessage mEqui1 = new MyImageMessage();
        //    mEqui1.image = equi1.sprite.ToString().ToString();
        //    mEqui1.type = "Equipements";
        //    MyImageMessage mEqui2 = new MyImageMessage();
        //    mEqui2.image = equi2.sprite.ToString().ToString();
        //    mEqui2.type = "Equipements";
        //    client.Send(idMessage, mLoco);
        //    client.Send(idMessage, mDim);
        //    client.Send(idMessage, mEqui0);
        //    client.Send(idMessage, mEqui1);
        //    client.Send(idMessage, mEqui2);
        //}
    }
Exemple #24
0
    private void onButtonClicked(int i)
    {
        ////lorsque le joueur clique sur sa position, on met à jour dans joueur static le numéro du joueur et sa
        ////position, puis on envoie au serveur un message pour lui indiquer que le joueur i a cliqué
        JoueurStatic.Numero   = positions[i];
        JoueurStatic.Position = i + 1;
        MyNetworkMessage message = new MyNetworkMessage();

        message.message = JoueurStatic.Numero;
        JoueurStatic.Client.Send(messageID, message);
        ////on passe au canvas suivant
        canvas_position_joueurs.SetActive(false);
        canvas_infos_joueurs.SetActive(true);
    }
 ////lorsque le joueur a son bouton actif (si c est le présentateur) et qu'il appuie dessus,
 //// on passe soit au présentateur suivant, soit on passe au débat si c'est le dernier joueur à
 ////présenter un personnage
 private void ButtonClicked()
 {
     nextbutton.gameObject.SetActive(false);
     if ((nextbutton.transform.GetChild(0).gameObject.GetComponent <Text>().text == "Commencer le débat") ||
         (nextbutton.transform.GetChild(0).gameObject.GetComponent <Text>().text == "Start debate"))
     {
         ////On indique au serveur que la présentation du joueur est terminée
         MyNetworkMessage msg = new MyNetworkMessage();
         JoueurStatic.Client.Send(debatID, msg);
     }
     else
     {
         ////On indique au serveur que la présentation du joueur est terminée
         MyNetworkMessage msg = new MyNetworkMessage();
         JoueurStatic.Client.Send(joueurID, msg);
     }
 }
Exemple #26
0
    void OnMessageReceived(NetworkMessage netMessage)
    {
        // You can send any object that inherence from MessageBase
        // The client and server can be on different projects, as long as the MyNetworkMessage or the class you are using have the same implementation on both projects
        // The first thing we do is deserialize the message to our custom type
        var objectMessage = netMessage.ReadMessage <MyNetworkMessage>();

        ServerLog("Message received: " + objectMessage.message);
        Debug.Log("Message received: " + objectMessage.message);

        //Send to all the message that i received
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = objectMessage.message;
        ServerLog("Sent to all the message: " + objectMessage.message);
        NetworkServer.SendToAll(messageID, messageContainer);
    }
Exemple #27
0
    private void RetourButtonClicked()
    {
        if (Partie.Langue == "FR")
        {
            button.transform.GetChild(0).GetComponent <Text>().text = fr;
        }
        else
        {
            button.transform.GetChild(0).GetComponent <Text>().text = en;
        }
        nbClicked--;
        bouton_retour.gameObject.SetActive(false);
        MyNetworkMessage msg = new MyNetworkMessage();

        msg.message = Partie.JoueurCourant;
        NetworkServer.SendToAll(RetourID, msg);
    }
Exemple #28
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Sprite self = this.GetComponent <Image>().sprite;

        Debug.Log(collision.gameObject.name);
        Sprite s = collision.gameObject.GetComponent <Image>().sprite;

        if ((collision.gameObject.transform != this.transform.parent.parent.GetChild(0)) && (cartes.Contains(collision.gameObject)) && (s.name != "DecideurPublic") && (s.name != "DecideurPrive"))
        {
            int  index = cartes.IndexOf(collision.gameObject);
            bool exp   = true;
            if (self.name == "Jeton Vert")
            {
                exp = Tour.Piles[index] < 3;
            }
            else if (self.name == "Jeton Rouge")
            {
                exp = Tour.Piles[index] == 3;
            }
            if (exp)
            {
                this.gameObject.SetActive(false);
                MyNetworkMessage msg = new MyNetworkMessage();
                msg.message = Partie.JoueurCourant;
                NetworkServer.SendToAll(goID, msg);
                button.SetActive(true);

                if (Tour.Piles[index] < 8)
                {
                    Debug.Log(Tour.Piles[index]);
                    joueurs[index].transform.GetChild(2).GetChild(Tour.Piles[index]).gameObject.GetComponent <Image>().sprite = this.gameObject.GetComponent <Image>().sprite;
                    joueurs[index].transform.GetChild(2).GetChild(Tour.Piles[index]).gameObject.SetActive(true);
                    debatObject.debate.JoueurRecevant = index;
                    debatObject.debate.Personnage     = joueurs[index].transform.GetChild(0).GetComponent <Image>().name;
                    debatObject.AddGivenJeton();
                    //joueurs[index]


                    Tour.Piles[index]++;
                }
            }
        }
        this.transform.position = positionInit;
    }
Exemple #29
0
    public void StartGame()
    {
        if (lobbyManager.connectedClients.Count < 1)
        {
            return;
        }

        //Send message to all connected that the game as started
        var message = new MyNetworkMessage();

        //Players - 1 because the clients expect the message to be the number of enemies
        message.message = (lobbyManager.GetParticipatingPlayers().Count - 1).ToString();
        NetworkServer.SendToAll(AceMsgTypes.GameStart, message);

        //plannedPlayers = new PlayerPlanningPhaseDone[lobbyManager.GetParticipatingPlayers().Count];

        //Start the actual game, shuffling cards n shit
        gameManager.StartGame();
    }
Exemple #30
0
    void OnClientConnected(NetworkMessage netMessage)
    {
        // Do stuff when a client connects to this server

        // Send a thank you message to the client that just connected
        MyNetworkMessage messageContainer = new MyNetworkMessage();

        messageContainer.message = "Thanks for joining!";

        // This sends a message to a specific client, using the connectionId
        NetworkServer.SendToClient(netMessage.conn.connectionId, messageID, messageContainer);

        // Send a message to all the clients connected
        messageContainer         = new MyNetworkMessage();
        messageContainer.message = "A new player has conencted to the server";

        // Broadcast a message a to everyone connected
        NetworkServer.SendToAll(messageID, messageContainer);
    }