Exemple #1
0
        // Is the move the same, OR similar?
        public bool IsSimilarMove(AnimationSpecification animationSpecification)
        {
            if (animationSpecification.moveType == MoveType.noMove)
            {
                return(false);
            }

            if (animationSpecification.cubeAxis == cubeAxis &&
                animationSpecification.cubeSlices == cubeSlices)
            {
                return(true);
            }

            if (animationSpecification.cubeSlices == CubeSlices.s01234 &&
                cubeSlices == CubeSlices.s01234)
            {
                return(true);
            }

            if (animationSpecification.cubeAxis == cubeAxis &&
                IsSimilarSlice(animationSpecification.cubeSlices))
            {
                return(true);
            }

            return(false);
        }
Exemple #2
0
        public void AddRandomMove()
        {
            AnimationSpecification animationSpecification = AnimationData.GetRandomMove();

            // Don't allow "similar moves". This avoids back and forth, and triple moves.
            while (animationSpecification.IsSimilarMove(_lastAnimationSpecification))
            {
                animationSpecification = AnimationData.GetRandomMove();
            }

            AddAnimation(animationSpecification);
        }
Exemple #3
0
        void Update()
        {
            _skipStep++;
            if (_skipStep <= skipFrames)
            {
                return;
            }

            _skipStep = 0;

            if (!isAnimating)
            {
                if (_queue.Count > 0)
                {
                    // We are not currently performing an animation,
                    // but there are Animations on the queue,
                    // so peel off an animation from the queue,
                    // Add it, and proceed directly to execute it.
                    AnimationSpecification animationSpecification = _queue.Dequeue();
                    AddAnimation(animationSpecification);
                }
                else if (_doRandomMoves)
                {
                    // We are not currently performing an animation,
                    // but we have specified to "do random moves",
                    // so Add a random animation, and proceed directly to execute it.
                    AddRandomMove();
                }
                else
                {
                    return;
                }
            }

            _animationStep++;

            faceMapPanel.DoAnimation(_angleStep, IsAnimationOnStep(_animationStep));
            myCube.DoAnimation(_angleStep);

            // Transform the rotations into array manipulations.
            if (IsAnimationOnFinishStep(_animationStep))
            {
                faceMapPanel.FinishAnimation();
                myCube.FinishAnimation();
            }

            if (IsAnimationOnLastStep(_animationStep))
            {
                isAnimating = false;
            }
        }
Exemple #4
0
        public void AddAnimation(AnimationSpecification animationSpecification)
        {
            if (isAnimating)
            {
                _queue.Enqueue(animationSpecification);
                return;
            }

            if (_playSound)
            {
                if (animationSpecification.moveType == MoveType.doubleMove)
                {
                    _myAudioSource.PlayOneShot(audioClipDouble, _myAudioSource.volume); // <<<
                }
                else
                {
                    _myAudioSource.PlayOneShot(audioClipSingle, _myAudioSource.volume); // <<<
                }
            }

            myCube.SpecifyAnimation(animationSpecification);
            faceMapPanel.SpecifyAnimation(animationSpecification);

            movesPanel.AddMove(animationSpecification);

            if (animationSpecification.rotationDirection == RotationDirection.reverse)
            {
                _angleStep = -_baseAngleStep;
            }
            else
            {
                _angleStep = _baseAngleStep;
            }

            _moveType = animationSpecification.moveType;

            _lastAnimationSpecification = animationSpecification;
            // Record the "last" animation added to prevent random moves being "duplicated".

            _animationStep = 0;
            isAnimating    = true;
        }
Exemple #5
0
 void Awake()
 {
     _lastAnimationSpecification = AnimationData.GetNullMove();
     _myAudioSource = GetComponent <AudioSource>();
 }