示例#1
0
        public ClientGame(ClientGameContext ctx)
        {
            Assert.IsNotNull(ctx.World);
            World = ctx.World;

            //var networkInterface = new LidgrenClientNetworkInterface(ctx.LagSettings);
            var networkInterface = new LiteNetClientNetworkInterface();

            Client = new CubeClient(ctx.World, networkInterface);

            Client.networkInterface.ConnectionRequestAccepted += OnConnectionRequestAccepted;
            Client.networkInterface.Disconnected += OnDisconnected;

            Client.reactor.AddHandler((byte)MessageId.LoadScene, OnLoadScene);
            Client.reactor.AddHandler((byte)MessageId.PossessPawn, OnPossessPawn);
        }
示例#2
0
        public void StartClient()
        {
            if (GameClient != null)
            {
                return;
            }

            var clientWorldGO = new GameObject("Client World");
            var clientWorld   = clientWorldGO.AddComponent <World>();

            var ctx = new ClientGameContext()
            {
                World       = clientWorld,
                LagSettings = LagSettings
            };

            GameClient = CreateClient(ctx);

            OnClientRunning();
        }
示例#3
0
 protected virtual ClientGame CreateClient(ClientGameContext ctx)
 {
     return(new ClientGame(ctx));
 }