示例#1
0
        IEnumerator RotateAround(Vector3 axis, float rotAngle, float rotDuration, Transform rotateTransform)
        {
            Transform thisTransform = rotateTransform;
            float     elapsed       = 0.0f;
            float     rotated       = 0.0f;

            if (!_rotating)
            {
                _rotating = true;

                while (elapsed < rotDuration)
                {
                    float step = rotAngle / rotDuration * (Time.deltaTime * 2);
                    thisTransform.RotateAround(thisTransform.position, axis, step);
                    elapsed += (Time.deltaTime * 2);
                    rotated += step;
                    yield return(null);
                }

                thisTransform.RotateAround(thisTransform.position, axis, rotAngle - rotated);
            }
            _rotating = false;

            _currentCubeCode = DetectFaces.DetectSides(transform.eulerAngles, _rotAngleDict);

            ChangeFacingTag();
        }
示例#2
0
        void Start()
        {
            mainCam = GameObject.Find("Main Camera").GetComponent <Camera>();

            _rotAngleDict = new Dictionary <Vector3, int>();
            _rotAngleDict.Add(new Vector3(270, 0, 0), 123);
            _rotAngleDict.Add(new Vector3(270, 90, 0), 243);
            _rotAngleDict.Add(new Vector3(270, 180, 0), 453);
            _rotAngleDict.Add(new Vector3(270, 270, 0), 513);

            //with 2 on top of cube
            _rotAngleDict.Add(new Vector3(0, 180, 180), 162);
            _rotAngleDict.Add(new Vector3(0, 270, 180), 642);
            _rotAngleDict.Add(new Vector3(0, 0, 180), 432);
            _rotAngleDict.Add(new Vector3(0, 90, 180), 312);

            //with 6 on top of cube
            _rotAngleDict.Add(new Vector3(90, 0, 0), 156);
            _rotAngleDict.Add(new Vector3(90, 90, 0), 546);
            _rotAngleDict.Add(new Vector3(90, 180, 0), 426);
            _rotAngleDict.Add(new Vector3(90, 270, 0), 216);

            //with 5 on top of cube
            _rotAngleDict.Add(new Vector3(0, 0, 0), 135);
            _rotAngleDict.Add(new Vector3(0, 90, 0), 345);
            _rotAngleDict.Add(new Vector3(0, 180, 0), 465);
            _rotAngleDict.Add(new Vector3(0, 270, 0), 615);

            //with 1 on top of cube
            _rotAngleDict.Add(new Vector3(0, 180, 90), 561);
            _rotAngleDict.Add(new Vector3(0, 270, 90), 621);
            _rotAngleDict.Add(new Vector3(0, 0, 90), 231);
            _rotAngleDict.Add(new Vector3(0, 90, 90), 351);

            //with 4 on top of cube
            _rotAngleDict.Add(new Vector3(0, 180, 270), 264);
            _rotAngleDict.Add(new Vector3(0, 270, 270), 654);
            _rotAngleDict.Add(new Vector3(0, 0, 270), 534);
            _rotAngleDict.Add(new Vector3(0, 90, 270), 324);

            _currentCubeCode = DetectFaces.DetectSides(transform.eulerAngles, _rotAngleDict);
            ChangeFacingTag();
        }
示例#3
0
        private void ChangeFacingTag()
        {
            if (singleCubeFaceNo > 0 && singleCubeFaceNo < 7)
            {
                if (_currentCubeCode.ToString().Contains(singleCubeFaceNo.ToString()))
                {
                    DetectFaces.SetObjTagToFacingCam(gameObject);
                }
                else
                {
                    DetectFaces.SetObjTagToNotFacingCam(gameObject);
                }
            }

            else if (_currentCubeCode == correctCubeCode)
            {
                DetectFaces.SetObjTagToFacingCam(gameObject);
            }
            else
            {
                DetectFaces.SetObjTagToNotFacingCam(gameObject);
            }
        }