コード例 #1
0
    // Use this for initialization
    void Start()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this.gameObject);
            return;
        }

        //DontDestroyOnLoad(this.gameObject);

        SteamCallbackReceiver.Init();

        Lobby           = lobby;
        MaxNumOfPlayers = NumOfPlayers;

        SteamCallbackReceiver.LobbyEnterEvent  += EnterLobby;
        SteamCallbackReceiver.LobbyCreateEvent += CreateLobby;
        SteamCallbackReceiver.ChatUpdateEvent  += UpdateUsers;
        SteamCallbackReceiver.AcceptP2PEvent   += AcceptP2P;
        SteamCallbackReceiver.P2PFailEvent     += P2PStatus;

        MyID = SteamUser.GetSteamID();

        Packet = new BytePacket(4096);

        Commands = new Command[Enum.GetNames(typeof(PacketType)).Length];
        AddCommands(PacketType.LeaveLobby, LeaveLobbyCommand);
        AddCommands(PacketType.Latency, LatencyResponse);

        StartCoroutine(LatencyTest());

        waitForSeconds = new WaitForSeconds(0.1f);

        if (OnClientInitialized)
        {
            OnClientInitialized.Raise();
        }
    }
コード例 #2
0
    void Awake()
    {
        self = SteamUser.GetSteamID();
        Callback <P2PSessionRequest_t> .Create((cb) =>
        {
            if (others.ContainsKey(cb.m_steamIDRemote.m_SteamID))
            {
                SteamNetworking.AcceptP2PSessionWithUser(cb.m_steamIDRemote);
            }
        });

        temp1024 = GamePacket.CreatePacket(1024);
        temp768  = GamePacket.CreatePacket(768);
        temp512  = GamePacket.CreatePacket(512);
        temp256  = GamePacket.CreatePacket(256);

        SteamCallbackReceiver.Init();

        SteamCallbackReceiver.ChatUpdateEvent += OnLobbyChatUpdate;
        SteamCallbackReceiver.LobbyEnterEvent += OnLobbyEnter;
    }