コード例 #1
0
        // Get the AnimationController to do the animation of the Cube and the Map.
        public void OnRotate(InputAction.CallbackContext context, CubeAxis axis, CubeSlices slices)
        {
            if (context.phase != InputActionPhase.Started)
            {
                return;
            }

            AnimationSpecification animationSpecification;

            animationSpecification.cubeAxis   = axis;
            animationSpecification.cubeSlices = slices;

            if (Keyboard.current.leftShiftKey.isPressed)
            {
                animationSpecification.rotationDirection = RotationDirection.reverse;
            }
            else
            {
                animationSpecification.rotationDirection = RotationDirection.normal;
            }

            if (Keyboard.current.leftCtrlKey.isPressed)
            {
                animationSpecification.moveType = MoveType.doubleMove;
            }
            else
            {
                animationSpecification.moveType = MoveType.singleMove;
            }

            animationController.AddAnimation(animationSpecification);
        }
コード例 #2
0
ファイル: FaceMapPanel.cs プロジェクト: Nick-J-King/Rubix
        public void SpecifyAnimation(AnimationSpecification animationSpecification)
        {
            cubeAxis          = animationSpecification.cubeAxis;
            cubeSlices        = animationSpecification.cubeSlices;
            rotationDirection = animationSpecification.rotationDirection;

            isAnimating = true;
        }
コード例 #3
0
ファイル: RubiksCube.cs プロジェクト: 1sequins/Rubiks
    public void StartRotation(CubeAxis axis)
    {
        if (rotating)
        {
            return;
        }

        rotatingAxis  = axis;
        startRotating = true;
    }
コード例 #4
0
ファイル: RubiksCube.cs プロジェクト: 1sequins/Rubiks
    private void Scramble()
    {
        if (scrambles <= 0)
        {
            scrambling = false;
            PlayManager.Instance.DoneScrambling();
            return;
        }
        scrambles--;

        CubeAxis randomAxis = allAxis[Random.Range(0, allAxis.Length)];

        while (lastRandomScramble != null && lastRandomScramble == randomAxis)
        {
            randomAxis = allAxis[Random.Range(0, allAxis.Length)];
        }
        lastRandomScramble = randomAxis;
        bool clockwise = Random.value < 0.5f;

        StartRotation(randomAxis, clockwise);
    }
コード例 #5
0
        public void AddMove(AnimationSpecification animationSpecification)
        {
            RotationDirection rotationDirection = animationSpecification.rotationDirection;
            CubeAxis          cubeAxis          = animationSpecification.cubeAxis;
            CubeSlices        cubeSlices        = animationSpecification.cubeSlices;
            MoveType          moveType          = animationSpecification.moveType;

            string s = "";

            switch (cubeAxis)
            {
            case CubeAxis.x:
                s = "x";
                break;

            case CubeAxis.y:
                s = "y";
                break;

            case CubeAxis.z:
                s = "z";
                break;
            }

            switch (cubeSlices)
            {
            case CubeSlices.s0:
                s += "0";
                break;

            case CubeSlices.s01:
                s += "01";
                break;

            case CubeSlices.s1:
                s += "1";
                break;

            case CubeSlices.s2:
                s += "2";
                break;

            case CubeSlices.s3:
                s += "3";
                break;

            case CubeSlices.s34:
                s += "34";
                break;

            case CubeSlices.s4:
                s += "4";
                break;

            case CubeSlices.s01234:
                s += "01234";
                break;
            }

            if (rotationDirection == RotationDirection.reverse)
            {
                s += "R";
            }
            if (moveType == MoveType.doubleMove)
            {
                s += "D";
            }

            GameObject g1 = Instantiate(prefab);

            g1.gameObject.transform.SetParent(contentRect, false);

            g1.SetActive(true);

            var g1m = g1.GetComponent <MyMove>();

            g1m.text.text = "  " + s;

            Canvas.ForceUpdateCanvases();

            contentObj.GetComponent <VerticalLayoutGroup>().CalculateLayoutInputVertical();
            contentObj.GetComponent <ContentSizeFitter>().SetLayoutVertical();

            sr.content.GetComponent <VerticalLayoutGroup>().CalculateLayoutInputVertical();
            sr.content.GetComponent <ContentSizeFitter>().SetLayoutVertical();

            sr.normalizedPosition = new Vector2(0, 0);

            _numMoves++;
            SetTitle();
        }
コード例 #6
0
ファイル: RubiksCube.cs プロジェクト: 1sequins/Rubiks
 public void StartRotation(CubeAxis axis, bool clockwise)
 {
     cw = clockwise;
     StartRotation(axis);
 }