Exemple #1
0
        private void InterpolateCameraZoom(int currentLevel)
        {
            if (LeanTween.isTweening(_cameraZoomId))
            {
                return;
            }

            var bounds = _levelBounds[currentLevel];
            var mid    = (bounds.Item1 + bounds.Item2) / 2f;

            // Interpolate camera zoom between levels
            var yPos             = transform.position.y;
            var delta            = -mid + yPos;
            var closestNextLevel = delta < 0
                                ? (currentLevel <= 0 ? 0 : currentLevel - 1)
                                : (currentLevel >= _levelBounds.Length - 1 ? _levelBounds.Length - 1 : currentLevel + 1);
            var nextBounds = _levelBounds[closestNextLevel];
            var nextMid    = (nextBounds.Item1 + nextBounds.Item2) / 2f;
            var deltaRatio = Mathf.Abs(delta) > Mathf.Abs(nextMid - mid) ? 1f : Mathf.Abs(delta) / Mathf.Abs(nextMid - mid);

            var puzzleScale       = _levels[_selectedLevel].GetComponent <PuzzleScale>();
            var selectedLevelZoom = CameraScript.CameraZoomToFit(puzzleScale.Dimensions, puzzleScale.Margin, _scaleRatio);

            var nextPuzzleScale = _levels[closestNextLevel].GetComponent <PuzzleScale>();
            var nextLevelZoom   = CameraScript.CameraZoomToFit(nextPuzzleScale.Dimensions, nextPuzzleScale.Margin, _scaleRatio);

            Camera.main.orthographicSize = LeanTween.easeInOutSine(selectedLevelZoom, nextLevelZoom, deltaRatio);
        }
Exemple #2
0
        public void EnableScroll()
        {
            if (_scrollEnabled)
            {
                _scrollEnabled = false;
                DisableScroll();
                return;
            }

            _navigation.Hide();

            var puzzleState = _levels[_selectedLevel].GetComponent <PuzzleState>();
            var puzzleScale = puzzleState.GetComponent <PuzzleScale>();
            var boardAction = puzzleState.GetComponent <BoardAction>();

            puzzleState.BoardEnabled = false;

            RevealLevels(_selectedLevel);

            puzzleScale.PuzzleInit        -= OnPuzzleInit;
            boardAction.PuzzleWin         -= OnPuzzleWin;
            puzzleState.LevelStateChanged -= OnLevelStateChanged;

            var zoom = CameraScript.CameraZoomToFit(puzzleScale.Dimensions, puzzleScale.Margin, _scaleRatio);

            _cameraZoomId = CameraScript.ZoomCamera(zoom, CameraZoomTime, LeanTweenType.easeInSine);

            _panVelocity   = Vector3.up / VelocityScalingFactor;
            _scrollEnabled = true;

            // TODO: make configurable
            const float volume = 0.3f;

            _gameAudio.Play(GameClip.MenuSelect, volume: volume);

            var puzzleInfo = puzzleState.GetComponentInChildren <PuzzleInfo>();

            puzzleInfo.Show();
        }