示例#1
0
        void Awake()
        {
            _client         = _networkedClient.GetComponent <INetworkedClient>();
            _clientIdentity = _networkedClient.GetComponent <NetworkIdentity>();

            _targetFPS = NetworkManager.singleton.serverTickRate;
        }
示例#2
0
        /// <summary>
        /// Constructor of LiNGS Client. Creates a new instance of <see cref="LiNGSClient"/>.
        /// </summary>
        /// <exception cref="ArgumentNullException">When any of the params is null.</exception>
        /// <param name="properties">Properties of the client. These properties cannot be changed after the server is running.</param>
        /// <param name="serverInfo">Information used to connect to the server.</param>
        /// <param name="networkedClient">Game logic to receive callbacks and manage game objects.</param>
        public LiNGSClient(ClientProperties properties, ServerInfo serverInfo, INetworkedClient networkedClient)
        {
            if (properties == null)
            {
                throw new ArgumentNullException("The client properties cannot be null.");
            }

            if (serverInfo == null)
            {
                throw new ArgumentNullException("The server information cannot be null.");
            }

            if (networkedClient == null)
            {
                throw new ArgumentNullException("The networkedClient cannot be null.");
            }

            this.UpdateManager    = new UpdateManager();
            this.ClientProperties = new ClientProperties(properties);
            this.ServerInfo       = new ServerInfo(serverInfo);

            NetworkManager          = new NetworkManager(this, ServerInfo.IP, ServerInfo.Port);
            Router                  = new Router(this);
            MessageAggregator       = new MessageAggregator(this);
            Manager                 = new Manager(this);
            Analyzer                = new Analyzer(this);
            ClientLogicProcessor    = new ClientLogicProcessor(this);
            Simulator               = new Simulator(this);
            Synchronizer            = new Synchronizer(this);
            ClientStatus            = new ClientStatus(this);
            NetworkedClientInstance = networkedClient;

            this.UpdateManager.AddUpdatable(MessageAggregator);
            this.UpdateManager.AddUpdatable(Manager);
            this.UpdateManager.AddUpdatable(Analyzer);
            this.UpdateManager.AddUpdatable(ClientLogicProcessor);
            this.UpdateManager.AddUpdatable(Simulator);
            this.UpdateManager.AddUpdatable(Synchronizer);
        }