예제 #1
0
        private void OnBlockAdded(IBlockModel block)
        {
            var worldPos = _viewTransform.TransformPosition(block.Position);
            var view     = _blockViewBuilder.BuildView(block);

            _blockToView[block] = view;
            view.Position       = worldPos;
            view.Rotation       = block.Rotation;
            Subscribe(block);
        }
        private void RedrawBlockView()
        {
            _blockView?.Dispose();

            var block    = _spawnController.NextBlock;
            var bounds   = ComputeBounds(block.Shape);
            var halfSize = bounds.size / 2;
            var root     = _renderView.BlockRoot;

            _renderView.SetCameraScale(Mathf.Max(halfSize.x, halfSize.z) + 0.5f);

            _blockView          = _blockViewBuilder.BuildView(block);
            _blockView.Position = root.position - bounds.center;
            _blockView.SetParent(root);
        }
예제 #3
0
        private void OnBlockAdded(IBlockModel block)
        {
            var levelPos = ComputeGhostPosition(block);
            var worldPos = _levelViewTransform.TransformPosition(levelPos);

            _rotationAnimator.StopAnimation(_ghostBlockView);
            _movementAnimator.StopAnimation(_ghostBlockView);
            _ghostBlockView?.Dispose();
            _ghostBlockView = _blockViewBuilder.BuildView(block);
            _ghostBlockView.SetMaterial(_ghostMaterial);
            _ghostBlockView.Position = worldPos;
            _ghostBlockView.Rotation = block.Rotation;

            block.OnPositionChanged += UpdateGhostPositionRotation;
            block.OnRotationChanged += UpdateGhostPositionRotation;
        }