Ejemplo n.º 1
0
    public void Receive(Packet packet)
    {
        try
        {
            if (!remotePlayers.ContainsKey(packet.Sender))
            {
                return;
            }
            RemotePlayer rp = remotePlayers[packet.Sender];
            switch (packet.TypeCode)
            {
            case Packet.Type.SYNC_PLAYER_POS:
                rp.SyncPosition((Vector2) new UnityPacketData(packet.Body, packet).OData);
                break;

            case Packet.Type.SYNC_PLAYER_DEAD:
                rp.Die();
                break;

            case Packet.Type.SYNC_PLAYER_RESPAWN:
                rp.Respawn();
                break;
            }
        }catch (System.Exception e)
        {
            Debug.Log(e);
            GameManager.instance.ShowMessage(UnityEngine.Random.Range(0, 2) % 2 == 0 ? "패킷이 잘못전달되었습니다.. 개발자 일안하냐ㅏ!!"
                : "패킷이 잘못전달되었습니다. 버그 제보는 저희에게 큰 힘이 됩니다 카톡 (010-4187-7834) ", 1.0f, MessageType.Important);
        }
    }