Exemplo n.º 1
0
 void Awake()
 {
     viewManager = GetComponent <NetViewManager>();
     lock (LockObj) {
         if (instance == null)
         {
             instance = this;
         }
     }
 }
Exemplo n.º 2
0
    void Awake()
    {
        socket      = GetComponent <NetSocket>();
        database    = GetComponent <StreamDatabaseServer>();
        loginServer = GetComponent <LoginServer>();
        viewManager = GetComponent <NetViewManager>();

        loginServer.OnLoginSuccess += LoggedIn;

        socket.RegisterRpcListener(this);
        socket.Events.OnClientDisconnected += ClientDisconnected;
    }
Exemplo n.º 3
0
        private void Start()
        {
            socket      = GetComponent <NetSocket>();
            viewManager = GetComponent <NetViewManager>();
            zoneClient  = GetComponent <NetZoneClient>();

            ExampleItems.PopulateItemDatabase();

            zoneClient.OnZoneSetupSuccess += ZoneSetupSuccessful;

            socket.Events.OnDisconnectedFromServer += DisconnectedFromServer;

            socket.StartSocket();
            socket.RegisterRpcListener(this);
        }
Exemplo n.º 4
0
        private void Start()
        {
            socket      = GetComponent <NetSocket>();
            viewManager = GetComponent <NetViewManager>();
            zoneClient  = GetComponent <NetZoneClient>();

            zoneClient.OnZoneSetupSuccess += ZoneSetupSuccessful;

            socket.Events.OnDisconnectedFromServer += DisconnectedFromServer;
            socket.Events.OnConnectedToServer      += ConnectedToServer;

            socket.StartSocket();
            socket.RegisterRpcListener(this);

            socket.Connect(ServerAddress);
        }
Exemplo n.º 5
0
    void Start()
    {
        socket      = GetComponent <NetSocket>();
        viewManager = GetComponent <NetViewManager>();
        zoneClient  = GetComponent <NetZoneClient>();

        zoneClient.OnZoneSetupSuccess          += ZoneSetupSuccessful;
        socket.Events.OnConnectedToServer      += ConnectedToServer;
        socket.Events.OnDisconnectedFromServer += DisconnectedFromServer;
        viewManager.OnNetViewCreated           += OnNetViewCreated;

        socket.StartSocket();
        socket.RegisterRpcListener(this);

        NetSerializer.Add <Item>(Item.Serialize, Item.Deserialize);
        NetSerializer.Add <Equip>(Item.Serialize, Item.Deserialize);

        socket.Connect(serverIps[serverIpIndex] + ":" + serverPort);
    }
Exemplo n.º 6
0
        private void Start()
        {
            socket      = GetComponent <NetSocket>();
            viewManager = GetComponent <NetViewManager>();
            zoneManager = GetComponent <NetZoneManager>();
            zoneServer  = GetComponent <NetZoneServer>();

            zoneServer.OnAssignment += AssignedToZone;

            socket.ProtocolAuthority = true;
            socket.AcceptConnections = true;
            socket.MaxConnections    = 512;

            socket.Events.OnClientDisconnected += ClientDisconnected;
            socket.Events.OnPeerApproval       += PeerApproval;
            socket.Events.OnSocketStart        += SocketStart;
            socket.Events.OnFailedToConnect    += FailedToConnect;

            socket.StartSocket(ServerAddress + ":" + ServerPortRoot);
            socket.RegisterRpcListener(this);
        }
Exemplo n.º 7
0
 private void Awake()
 {
     viewManager = GetComponent <NetViewManager>();
 }
Exemplo n.º 8
0
    void OnGUI()
    {
        if (mode == netMode.client)
        {
            if (GUI.Button(new Rect(10, 10, 50, 50), "Client"))
            {
            }
        }
        else if (mode == netMode.server)
        {
            if (GUI.Button(new Rect(10, 10, 50, 50), "Server"))
            {
            }
            if (GUI.Button(new Rect(10, 70, 50, 50), "Peers"))
            {
                zoneManager.ListPeers();
            }
            if (GUI.Button(new Rect(10, 140, 50, 50), "UPeers"))
            {
                zoneManager.ListUPeers();
            }
        }
        else
        {
            if (GUI.Button(new Rect(10, 10, 50, 50), "Server"))
            {
                mode = netMode.server;
//                netManager = (GameObject)GameObject.Instantiate(Resources.Load("ServerGameManager"));
                gameObject.AddComponent <NetSocket>();
                socket = GetComponent <NetSocket>();

                gameObject.AddComponent <NetViewManager>();
                viewManager = GetComponent <NetViewManager>();

                gameObject.AddComponent <NetZoneManager>();
                zoneManager = GetComponent <NetZoneManager>();

                gameObject.AddComponent <NetZoneServer>();
                zoneServer = GetComponent <NetZoneServer>();
                zoneServer.OnAssignment += AssignedToZone;

                gameObject.AddComponent <NetScopeManager>();

                socket.ProtocolAuthority = true;
                socket.AcceptConnections = true;
                socket.MaxConnections    = 512;

                socket.Events.OnClientDisconnected += ClientDisconnected;
                socket.Events.OnPeerApproval       += PeerApproval;
                socket.Events.OnSocketStart        += SocketStart;
                socket.Events.OnFailedToConnect    += FailedToConnect;

                socket.StartSocket(ServerAddress + ":" + ServerPortRoot);
                socket.RegisterRpcListener(this);
                serverCamera.enabled = true;
            }
            if (GUI.Button(new Rect(10, 70, 50, 30), "Client"))
            {
                mode       = netMode.client;
                netManager = (GameObject)GameObject.Instantiate(Resources.Load("ClientGameManager"));
            }
        }
    }