Exemplo n.º 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);
        }
Exemplo n.º 2
0
 public void RotateToMax()
 {
     rotationState        = ERotationStates.RotatingToMax;
     currentRotationState = rotationState.ToString();
 }
Exemplo n.º 3
0
 public void RotateToNeutral()
 {
     rotationState        = ERotationStates.RotatingToNeutral;
     currentRotationState = rotationState.ToString();
 }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 public void RotateToNeutral()
 {
     rotationState = ERotationStates.RotatingToNeutral;
     currentRotationState = rotationState.ToString();
 }
Exemplo n.º 6
0
 public void RotateToMin()
 {
     rotationState = ERotationStates.RotatingToMin;
     currentRotationState = rotationState.ToString();
 }