예제 #1
0
    public void SendCharacterCoord(string charId, int index, List <CharacterCoord> character_coord)
    {
        GameObject netObj = GameObject.Find("Network");

        if (netObj)
        {
            // Network 클래스의 컴포넌트를 획득.
            Network network = netObj.GetComponent <Network>();
            if (network.IsConnected() == true)
            {
                // 패킷 데이터 생성.
                CharacterData data = new CharacterData();

                data.characterId = charId;
                data.index       = index;
                data.dataNum     = character_coord.Count;
                data.coordinates = new CharacterCoord[character_coord.Count];
                for (int i = 0; i < character_coord.Count; ++i)
                {
                    data.coordinates[i] = character_coord[i];
                }

                // 캐릭터 좌표 송신.
                CharacterDataPacket packet = new CharacterDataPacket(data);
                int sendSize = network.SendUnreliable <CharacterData>(packet);
                if (sendSize > 0)
                {
                    //	Debug.Log("Send character coord.[index:" + index + "]");
                }
            }
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        GameObject netObj = GameObject.Find("Network");

        if (netObj)
        {
            // Network 클래스의 컴포넌트를 획득.
            Network network = netObj.GetComponent <Network>();
            if (network.IsConnected() == true)
            {
                // 패킷 데이터 생성.
                CharacterData data = new CharacterData();

                data.characterId = "hi";
                data.index       = 1;
                data.dataNum     = 4;
                data.coordinates = new CharacterCoord[4];
                for (int i = 0; i < 4; ++i)
                {
                    data.coordinates[i] = new CharacterCoord(0.1f, 0.1f);
                }

                // 캐릭터 좌표 송신.
                CharacterDataPacket packet = new CharacterDataPacket(data);
                int sendSize = network.SendUnreliable <CharacterData>(packet);
                if (sendSize > 0)
                {
                    Debug.Log("Send character coord.[index:" + 4 + "]");
                }
            }
        }
    }
    public void OnReceiveCharacterPacket(int node, PacketId id, byte[] data)
    {
        // 패킷 수신
        CharacterDataPacket packet = new CharacterDataPacket(data);
        CharacterData characterData = packet.GetPacket();

        // 송신한 플레이어 구별
        GameObject netplayer = findPlayer(characterData.characterId);

        // 캐릭터 좌표 보간
        if (netplayer != null)
        {
            netplayer.GetComponent<NetPlayerCtrl>().CalcCoordinates(characterData.index, characterData.coordinates);
        }
    }
예제 #4
0
    public void OnReceiveCharacterPacket(int node, PacketId id, byte[] data)
    {
        // 패킷 수신
        CharacterDataPacket packet        = new CharacterDataPacket(data);
        CharacterData       characterData = packet.GetPacket();

        // 송신한 플레이어 구별
        GameObject netplayer = findPlayer(characterData.characterId);

        // 캐릭터 좌표 보간
        if (netplayer != null)
        {
            netplayer.GetComponent <NetPlayerCtrl>().CalcCoordinates(characterData.index, characterData.coordinates);
        }
    }
예제 #5
0
    public void     OnReceiveCharacterPacket(PacketId id, byte[] data)
    {
        CharacterDataPacket packet   = new CharacterDataPacket(data);
        CharacterData       charData = packet.GetPacket();

        if (GlobalParam.get().is_in_my_home != GlobalParam.get().is_remote_in_my_home)
        {
            return;
        }

        chrBehaviorNet remote = CharacterRoot.get().findCharacter <chrBehaviorNet>(charData.characterId);

        if (remote != null)
        {
            remote.CalcCoordinates(charData.index, charData.coordinates);
        }
    }
예제 #6
0
    // ---------------------------------------------------------------- //

    public void     OnReceiveCharacterPacket(int node, PacketId id, byte[] data)
    {
        CharacterDataPacket packet   = new CharacterDataPacket(data);
        CharacterData       charData = packet.GetPacket();

        chrController controller = findPlayer(charData.characterId);

        if (controller == null)
        {
            return;
        }

        // 캐릭터 좌표 보간.
        chrBehaviorNet behavior = controller.behavior as chrBehaviorNet;

        if (behavior != null)
        {
            behavior.CalcCoordinates(charData.index, charData.coordinates);
        }
    }
예제 #7
0
    // 10프레임마다 캐릭터 좌표를 송신
    public void SendCharacterCoord(int charId, int index, List <CharacterCoord> characterCoord)
    {
        if (network != null)
        {
            // 패킷 데이터 만들기
            CharacterData data = new CharacterData();
            data.characterId = charId;
            data.index       = index;
            data.dataNum     = characterCoord.Count;
            data.coordinates = new CharacterCoord[characterCoord.Count];
            for (int i = 0; i < characterCoord.Count; i++)
            {
                data.coordinates[i] = characterCoord[i];
            }

            // 캐릭터 좌표를 UDP송신
            CharacterDataPacket packet = new CharacterDataPacket(data);
            network.SendUnreliableToAll <CharacterData>(packet);
        }
    }
예제 #8
0
    void setCharInfo(int node, byte[] data)
    {
        CharacterDataPacket positionPacket = new CharacterDataPacket(data);

        CharacterData CharacterInfo = positionPacket.GetPacket();

        Vector3 position = CharacterInfo.position;

        if (CharacterInfo.isJumpEnd)
        {
            ControlScripts[CharacterInfo.CharacterInfo].SetPosition(position);
        }
        else if (CharacterInfo.isJump)
        {
            ControlScripts[CharacterInfo.CharacterInfo].jump();
        }

        else
        {
            ControlScripts[CharacterInfo.CharacterInfo].SetDestination(position);
        }
    }
    // 10프레임마다 캐릭터 좌표를 송신
    public void SendCharacterCoord(int charId, int index, List<CharacterCoord> characterCoord)
    {
        if(network != null)
        {
            // 패킷 데이터 만들기
            CharacterData data = new CharacterData();
            data.characterId = charId;
            data.index = index;
            data.dataNum = characterCoord.Count;
            data.coordinates = new CharacterCoord[characterCoord.Count];
            for(int i = 0; i < characterCoord.Count; i++)
            {
                data.coordinates[i] = characterCoord[i];
            }

            // 캐릭터 좌표를 UDP송신
            CharacterDataPacket packet = new CharacterDataPacket(data);
            network.SendUnreliableToAll<CharacterData>(packet);

        }
    }