void HandlePlayerData(byte[] data)
    {
        int packetnum;

        KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames();
        buffer.WriteBytes(data);
        packetnum = buffer.ReadInteger();

        int i = buffer.ReadInteger();

        if (Globals.instance.MyIndex < 1)
        {
            Globals.instance.MyIndex       = i;
            ClientSendData.instance._index = Globals.instance.MyIndex;
        }

        _LoginWindow.SetActive(false);


        Network.instanceP[i].index = i;
        General.instance.SetPlayerX(i, buffer.ReadFloat());
        General.instance.SetPlayerY(i, buffer.ReadFloat());
        General.instance.SetPlayerZ(i, buffer.ReadFloat());

        Network.instanceP[i].Username = buffer.ReadString();

        _playerPrefs = Instantiate(_playerPrefs, new Vector3(General.instance.GetPlayerX(i), General.instance.GetPlayerY(i), General.instance.GetPlayerZ(i)), Quaternion.identity);
        _playerPrefs.GetComponent <NetPlayer>().Index = i;
        _playerPrefs.name = "Player " + i + " : " + Network.instanceP[i].Username;
    }
예제 #2
0
        void HandleMovement(int index, byte[] data)
        {
            KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames();
            buffer.WriteBytes(data);
            int   packetnum = buffer.ReadInteger();
            float posX      = buffer.ReadFloat();
            float posY      = buffer.ReadFloat();
            float posZ      = buffer.ReadFloat();

            float rotX = buffer.ReadFloat();
            float rotY = buffer.ReadFloat();
            float rotZ = buffer.ReadFloat();
            float rotW = buffer.ReadFloat();

            Globals.general.SetPlayerX(index, posX);
            Globals.general.SetPlayerY(index, posY);
            Globals.general.SetPlayerZ(index, posZ);

            // SendPlayer Movement
            Globals.networkSendData.SendPlayerMovement(index, posX, posY, posZ, rotX, rotY, rotZ, rotW);
        }
    void HandleMovement(byte[] _data)
    {
        Debug.Log("Data is player movement.");
        int packetnum;

        KaymakGames.KaymakGames buffer = new KaymakGames.KaymakGames();
        //buffer.WriteBytes(data);
        buffer.WriteBytes(_data);

        packetnum = buffer.ReadInteger();

        // PLayer Info
        int index = buffer.ReadInteger();
        // PLayer Position
        float x = buffer.ReadFloat();
        float y = buffer.ReadFloat();
        float z = buffer.ReadFloat();

        // Player Rotation
        float rotX = buffer.ReadFloat();
        float rotY = buffer.ReadFloat();
        float rotZ = buffer.ReadFloat();
        float rotW = buffer.ReadFloat();

        GameObject _netPlayer;

        if (_netPlayer = GameObject.Find("Player " + index + " : " + Network.instanceP[index].Username))
        {
            _netPlayer.GetComponent <Transform>().position = new Vector3(x, y, z);
            _netPlayer.GetComponent <Transform>().rotation = new Quaternion(rotX, rotY, rotZ, rotW);
        }

        else
        {
        }
    }