コード例 #1
0
ファイル: PlayerHost.cs プロジェクト: matthewmics/SpikeRoll
    // Start is called before the first frame update
    void Start()
    {
        NetUI = MultiplayerUIScript;
        Server = this;
        GameSession = new MultiplayerGameSession();
        GeneralControl = NetworkObjects.GetComponent<MultiplayerGeneralControl>();
        MultiplayerSession = GetComponent<MultiplayerPrefs>();

        NetworkObjects.SetActive(false);
        ConnectionPanel.SetActive(true);

        NetworkTransport.Init();
        ConnectionConfig cc = new ConnectionConfig();
        reliableChannel = cc.AddChannel(QosType.ReliableSequenced);
        unreliableChannel = cc.AddChannel(QosType.Unreliable);
        stateUpdateChannel = cc.AddChannel(QosType.StateUpdate);
        
        HostTopology topo = new HostTopology(cc, MAX_CONNECTION);

        hostId = NetworkTransport.AddHost(topo, port, null); 

        messageText.text = "WAITING FOR OTHER PLAYER. YOUR IP IS " + SepakNetworkUtil.GetLocalIPAddress();


        isStarted = true;


        if(MultiplayerGameSession.NumberOfPlayers == 2)
        {
            Destroy(NetworkObjects.transform.Find("player1ai1").gameObject);
            Destroy(NetworkObjects.transform.Find("player2ai1").gameObject);
        }

    }
コード例 #2
0
    public void Start()
    {
        NetUI = NetUIInstance;
        ConnectionPanel.SetActive(true);
        NetworkObjects.SetActive(false);

        NetworkTransport.Init();
        ConnectionConfig cc = new ConnectionConfig();

        reliableChannel    = cc.AddChannel(QosType.ReliableSequenced);
        unreliableChannel  = cc.AddChannel(QosType.Unreliable);
        stateUpdateChannel = cc.AddChannel(QosType.StateUpdate);

        HostTopology topo = new HostTopology(cc, MAX_CONNECTION);

        hostId = NetworkTransport.AddHost(topo, 0, null);
    }