Пример #1
0
        public void FixedUpdate()
        {
            if (rotationState == ERotationStates.Neutral)
            {
                return;
            }

            switch (rotationState)
            {
            case ERotationStates.RotatingToNeutral:
                if (currentRotationAngle < 0)
                {
                    currentRotationAngle += degPerUpdate;
                }
                else if (currentRotationAngle > 0)
                {
                    currentRotationAngle -= degPerUpdate;
                }

                if (Math.Abs(currentRotationAngle) <= degPerUpdate)
                {
                    currentRotationAngle = 0.0f;
                    rotationState        = ERotationStates.Neutral;
                    currentRotationState = rotationState.ToString();
                }
                break;

            case ERotationStates.RotatingToMin:
                currentRotationAngle -= degPerUpdate;
                if (currentRotationAngle < minRotateAngle)
                {
                    currentRotationAngle = minRotateAngle;
                    rotationState        = ERotationStates.MinRotation;
                    currentRotationState = rotationState.ToString();
                }
                break;

            case ERotationStates.RotatingToMax:
                currentRotationAngle += degPerUpdate;
                if (currentRotationAngle > maxRotateAngle)
                {
                    currentRotationAngle = maxRotateAngle;
                    rotationState        = ERotationStates.MaxRotation;
                    currentRotationState = rotationState.ToString();
                }
                break;
            }

            rotationTarget.transform.localEulerAngles = new Vector3(currentRotationAngle, 0, 0);
        }
Пример #2
0
 public void RotateToMax()
 {
     rotationState        = ERotationStates.RotatingToMax;
     currentRotationState = rotationState.ToString();
 }
Пример #3
0
 public void RotateToNeutral()
 {
     rotationState        = ERotationStates.RotatingToNeutral;
     currentRotationState = rotationState.ToString();
 }
Пример #4
0
        public void FixedUpdate()
        {
            if (rotationState == ERotationStates.Neutral)
                return;

            switch (rotationState)
            {
                case ERotationStates.RotatingToNeutral:
                    if (currentRotationAngle < 0)
                        currentRotationAngle += degPerUpdate;
                    else if (currentRotationAngle > 0)
                        currentRotationAngle -= degPerUpdate;

                    if (Math.Abs(currentRotationAngle) <= degPerUpdate)
                    {
                        currentRotationAngle = 0.0f;
                        rotationState = ERotationStates.Neutral;
                        currentRotationState = rotationState.ToString();
                    }
                    break;

                case ERotationStates.RotatingToMin:
                    currentRotationAngle -= degPerUpdate;
                    if (currentRotationAngle < minRotateAngle)
                    {
                        currentRotationAngle = minRotateAngle;
                        rotationState = ERotationStates.MinRotation;
                        currentRotationState = rotationState.ToString();
                    }
                    break;

                case ERotationStates.RotatingToMax:
                    currentRotationAngle += degPerUpdate;
                    if (currentRotationAngle > maxRotateAngle)
                    {
                        currentRotationAngle = maxRotateAngle;
                        rotationState = ERotationStates.MaxRotation;
                        currentRotationState = rotationState.ToString();
                    }
                    break;
            }

            rotationTarget.transform.localEulerAngles = new Vector3(currentRotationAngle, 0, 0);
        }
Пример #5
0
 public void RotateToNeutral()
 {
     rotationState = ERotationStates.RotatingToNeutral;
     currentRotationState = rotationState.ToString();
 }
Пример #6
0
 public void RotateToMin()
 {
     rotationState = ERotationStates.RotatingToMin;
     currentRotationState = rotationState.ToString();
 }