示例#1
0
        public void readSocket()
        {
            //readRessource();
            byte[] TabTaille = new byte[4];
            theStream.Read(TabTaille, 0, 4);
            int taille = BitConverter.ToInt32(TabTaille, 0);

            byte[] TabIdentifier = new byte[1];
            theStream.Read(TabIdentifier, 0, 1);
            char[] Identifier = System.Text.Encoding.ASCII.GetChars(TabIdentifier);
            Debug.Log(Identifier.Length);

            switch (Identifier[0])
            {
            case 'r':
                //Read Ressourse
                readRessource();
                break;

            case 'w':
                //Read Ressourse
                string str = readString(taille - 1);
                Debug.Log("reçu " + str);
                break;

            case 'u':
                //Event
                ZEvent monEvent = new ZEvent();
                monEvent.fromBinary(theStream);
                receiveMove(monEvent);
                break;

            case 'c':
                //connexion
                ZEvent maConn = new ZEvent();
                maConn.fromBinary(theStream);
                //receiveMove(maConn);
                IDjoueur = maConn.getEvent();
                //Debug.Log("connexion !! "+maConn.getEvent()+" "+maConn.getType()+" "+maConn.getPosition().x+" "+maConn.getPosition().y+" "+maConn.getPosition().z);
                //Debug.Log("connexion !! "+maConn.getEvent()+" "+maConn.getType()+" "+maConn.getDirection().x+" "+maConn.getDirection().y+" "+maConn.getDirection().z);

                break;

            default:
                taille = taille - 1;
                Debug.Log("type inconnue, je jette tout : " + taille + "Byte");
                byte[] dechet = new byte[taille];
                theStream.Read(dechet, 0, taille);
                break;
            }
        }
示例#2
0
        public void receiveMove(ZEvent monEvent)
        {
            int ID = 0;

            if (monEvent.getEvent() == IDjoueur)
            {
                return;
            }
            if (Characters.TryGetValue(monEvent.getEvent(), out ID))
            {
                GameObject         o  = GameObject.Find("z@walk " + ID);
                AICharacterControl cc = (AICharacterControl)o.GetComponent(typeof(AICharacterControl));
                transform.position = monEvent.getPosition();
                //Debug.Log ("z@walk "+ID+" "+monEvent.getPosition().x+" "+monEvent.getPosition().y+" "+monEvent.getPosition().z+" ");
                //o.transform.forward = monEvent.transform.forward;
                cc.SetTarget(transform);
            }
            else
            {
                //on fait pop le zombie ou le characters
                Characters.Add(monEvent.getEvent(), (int)monEvent.getEvent());
            }
        }