Exemplo n.º 1
0
        public void OnUpdate()
        {
            // Режим в эдиторе
            #if UNITY_EDITOR
            OnStart();
            #endif

            int directionValue = direction == AnimationDirection.DirectionPositive ? 1 : -1;

            switch (state) {
                case LeverState.State1:

                    animator.update(this.gameObject, state1Angles, directionValue, speed);

                    if (turnLever && animator.isComplete(this.gameObject, state1Angles, directionValue, speed)) {
                        door.openDoor();
                        turnLever = false;
                    }

                    break;
                case LeverState.State2:

                    animator.update(this.gameObject, state2Angles, directionValue, speed);

                    if (turnLever && animator.isComplete(this.gameObject, state2Angles, directionValue, speed)) {
                        door.closeDoor();
                        turnLever = false;
                    }

                    break;
            }

            if (prevState != state)
                turnLever = true;

            prevState = state;
        }
Exemplo n.º 2
0
 public string stateToString(LeverState state)
 {
     switch (state) {
         case LeverState.State1: return Dictionary.LEVER_STATE1_TEXT;
         case LeverState.State2: return Dictionary.LEVER_STATE2_TEXT;
     }
     return "";
 }
Exemplo n.º 3
0
        public void leverState2()
        {
            if (state == LeverState.State2 || !mayBeState1ToState2) return;

            prevState = state;
            state = LeverState.State2;

            #if UNITY_EDITOR
            if (audioSource == null) return;
            #endif

            audioSource.clip = sound.leverState2Sound();
            audioSource.Play();
        }