示例#1
0
        void InitLockStepCallbacks()
        {
            var lockStep = GetComponent <LockStep>();

            lockStep.getDataFunc = () =>
            {
                return(new Msg()
                {
                    data = LifeGameUpdater.CreateStepData(_resolutionScale)
                });
            };

            lockStep.stepFunc = (stepCount, reader) =>
            {
                if (_stepEnable)
                {
                    var msg = reader.ReadMessage <Msg>();
                    _lifeGame.Step(msg.data);
                }
                return(_stepEnable);
            };

            lockStep.onMissingCatchUpServer = () =>
            {
                Debug.Log("OnMissingCatchUp at Server. NetworkManager.StopHost() will be called.");
                return(true);
            };
            lockStep.onMissingCatchUpClient = () => Debug.Log("OnMissingCatchUp at Client. Server will disconnect.");

            lockStep.getHashFunc = () => LockStepHelper.GenerateBufferHash <LifeGame.Data>(_lifeGame.readBufs);
        }
示例#2
0
        protected override void Start()
        {
            base.Start();
            _lifeGame = GetComponent <LifeGame>();
            LifeGameUpdater.Reset();

            InitLockStepCallbacks();
        }