コード例 #1
0
ファイル: GameSurface.cs プロジェクト: henningboat/UbiJam2020
        private void LateUpdate()
        {
            JobHandle localStateHandle  = _localState.Simulate();
            JobHandle syncedStateHandle = _syncronizedState.Simulate();

            JobHandle combinedJobHandle = JobHandle.CombineDependencies(localStateHandle, syncedStateHandle);

            JCompareChangesInLocalState jCompare = new JCompareChangesInLocalState
            {
                SentRPCNumber         = _sentRPCNumber,
                RpcNumberPerNode      = _rpcNumberPerNode,
                LocalStateSurface     = _localState.Surface,
                LastFrameLocalSurface = _localStateBackup,
            };
            JUpdateSyncedToLocalState jUpdateJob = new JUpdateSyncedToLocalState
            {
                ReceivedRpcNumber  = _receivedRpcNumber,
                LocalStateSurface  = _localState.Surface,
                SyncedStateSurface = _syncronizedState.Surface,
                RpcNumberPerNode   = _rpcNumberPerNode,
            };

            combinedJobHandle = jCompare.Schedule(SurfacePieceCount, ParallelJobBatchCount, combinedJobHandle);

            combinedJobHandle = jUpdateJob.Schedule(SurfacePieceCount, ParallelJobBatchCount, combinedJobHandle);

            combinedJobHandle = GameSurfaceRenderingHandler.Instance.ScheduleJobs(_localState, combinedJobHandle);

            combinedJobHandle.Complete();
            _localState.FinishSimulation();
            _syncronizedState.FinishSimulation();
            GameSurfaceRenderingHandler.Instance.Finish(_localState);

            _localState.CopySurfaceTo(_combinedSurface);

            _localState.CopySurfaceTo(_localStateBackup);
        }
コード例 #2
0
ファイル: GameSurface.cs プロジェクト: henningboat/UbiJam2020
        protected override void Awake()
        {
            base.Awake();
            _photonView = GetComponent <PhotonView>();
            _renderer   = GetComponentInChildren <Renderer>();

            WorldSpaceGridNodeSize = (1f / Resolution) * Size;

            _localState       = new GameSurfaceState(Resolution, Size, _gameSurfaceColorTexture, false);
            _syncronizedState = new GameSurfaceState(Resolution, Size, _gameSurfaceColorTexture, true);

            _rpcNumberPerNode = new NativeArray <int>(Resolution * Resolution, Allocator.Persistent);

            _combinedSurface = new NativeArray <SurfaceState>(Resolution * Resolution, Allocator.Persistent);
            Material material = gameObject.GetComponentInChildren <Renderer>().material;

            material.SetTexture("_Mask", _syncronizedState.GameSurfaceTex);
            material.SetTexture("_LocalMask", _localState.GameSurfaceTex);

            _localStateBackup = new NativeArray <SurfaceState>(Resolution * Resolution, Allocator.Persistent);
            _localState.CopySurfaceTo(_localStateBackup);
        }