// Start is called before the first frame update
 void Start()
 {
     hasRider       = false;
     topPosition    = GetComponentInChildren <Transform>();
     bottomPosition = GetComponentInChildren <Transform>();
     player         = FindObjectOfType <DeltaSkyIXPlayerNet>();
     _elevator      = ElevatorStates.PauseState;
 }
Esempio n. 2
0
 public void StopElevator()
 {
     elevatorState = ElevatorStates.Locked;
     stateSequence.Clear();
     Events["FineControlUp"].active   = true;
     Events["FineControlDown"].active = true;
     Events["LowerElevator"].active   = true;
     Events["RaiseElevator"].active   = true;
     Events["StopElevator"].active    = false;
     playStopSound();
 }
Esempio n. 3
0
        protected void setNextState()
        {
            stateIndex += 1;

            if (stateIndex <= stateSequence.Count - 1)
            {
                elevatorState = stateSequence[stateIndex];
            }
            else
            {
                elevatorState = ElevatorStates.Locked;
            }
        }
    void  ChangeState()
    {
        //yield return new WaitForSeconds(6);
        if (state == ElevatorStates.goDown)
        {
            newPos             = bottom.position;
            transform.position = Vector3.Lerp(transform.position, newPos, smooth * Time.deltaTime);

            /*
             * if(transform.position == newPos)
             *  state = ElevatorStates.pause;
             */
            //state = ElevatorStates.pause;
            if (transform.position.y > -21 && transform.position.y < -20) //Am ajuns jos
            {
                state = ElevatorStates.pause;
            }
        }

        else if (state == ElevatorStates.goUp)
        {
            newPos             = top.position;
            transform.position = Vector3.Lerp(transform.position, newPos, smooth * Time.deltaTime);
            if (transform.position.y > 68 && transform.position.y < 69) //Am ajuns sus
            {
                state = ElevatorStates.pause;
            }

            //state = ElevatorStates.pause;
        }

        else if (state == ElevatorStates.pause)
        {
            if (previous == ElevatorStates.goDown)
            {
                state    = ElevatorStates.goUp;
                previous = ElevatorStates.goUp;
            }
            else
            {
                state    = ElevatorStates.goDown;
                previous = ElevatorStates.goDown;
            }
        }
    }
        public void UseElevator()
        {
            if (Input.GetKeyDown(KeyCode.U) && player != null)
            {
                hasRider = true;
                player.transform.parent = gameObject.transform;
                _elevator = ElevatorStates.goUp;
            }

            if (Input.GetKeyDown(KeyCode.F) && player != null)
            {
                hasRider = true;
                player.transform.parent = gameObject.transform;
                _elevator = ElevatorStates.goDown;
            }

            ElevatorSM();
        }
 // Start is called before the first frame update
 void Start()
 {
     state    = ElevatorStates.pause;
     previous = ElevatorStates.goDown;
 }
Esempio n. 7
0
        public void FixedUpdate()
        {
            float distanceDelta;

            if (HighLogic.LoadedSceneIsFlight == false)
            {
                return;
            }
            if (elevatorTransform == null)
            {
                return;
            }

            //Make sure the door animation button is invisible
            if (doorAnimation != null)
            {
                doorAnimation.Events["Toggle"].active = false;
            }
            if (elevatorState == ElevatorStates.Locked)
            {
                return;
            }

            //Calcuate elevator speed
            elevatorSpeed = maxElevatorSpeed * (elevatorThrottle / 100.0f);
            if (elevatorSpeed < 0.001f)
            {
                return;
            }

            switch (elevatorState)
            {
            case ElevatorStates.PlayLoop:
                playLoopSound();
                setNextState();
                break;

            case ElevatorStates.DoneLowering:
                stateSequence.Clear();
                Events["FineControlUp"].active   = true;
                Events["FineControlDown"].active = true;
                Events["RaiseElevator"].active   = true;
                Events["StopElevator"].active    = false;
                elevatorState = ElevatorStates.Locked;
                status        = "Locked";
                playStopSound();
                break;

            case ElevatorStates.DoneRaising:
                stateSequence.Clear();
                Events["FineControlUp"].active   = true;
                Events["FineControlDown"].active = true;
                Events["LowerElevator"].active   = true;
                Events["StopElevator"].active    = false;
                elevatorState = ElevatorStates.Locked;
                status        = "Locked";
                playStopSound();
                break;

            case ElevatorStates.CloseDoors:
                if (loopSound != null && loopSound.isPlaying)
                {
                    loopSound.Stop();
                }
                if (doorAnimation == null)
                {
                    setNextState();
                }
                else
                {
                    doorAnimation.Toggle();
                    elevatorState = ElevatorStates.ClosingDoors;
                    status        = "Closing Doors";
                }
                break;

            case ElevatorStates.OpenDoors:
                if (doorsAreClosed() == false)
                {
                    setNextState();
                }
                else
                {
                    elevatorState = ElevatorStates.OpeningDoors;
                    status        = "Opening Doors";
                }
                break;

            case ElevatorStates.OpeningDoors:
            case ElevatorStates.ClosingDoors:
                Events["LowerElevator"].active = false;
                Events["RaiseElevator"].active = false;
                if (doorAnimation.aniState == ModuleAnimateGeneric.animationStates.LOCKED || doorAnimation.aniState == ModuleAnimateGeneric.animationStates.CLAMPED)
                {
                    setNextState();
                }
                break;

            case ElevatorStates.RaiseRailings:
                setRailingsVisible();
                setNextState();
                break;

            case ElevatorStates.LowerRailings:
                setRailingsVisible(false);
                setNextState();
                break;

            case ElevatorStates.Lowering:
                status = "Lowering";
                Events["StopElevator"].active = true;
                distanceDelta   = -elevatorSpeed * TimeWarp.fixedDeltaTime;
                travelDistance -= distanceDelta;

                elevatorTransform.Translate(0f, distanceDelta, 0f);

                //Check cable distance.
                if (travelDistance >= maxCableLength)
                {
                    StopElevator();
                    Events["FineControlUp"].active   = false;
                    Events["FineControlDown"].active = false;
                    Events["LowerElevator"].active   = false;
                    ScreenMessages.PostScreenMessage("Maximum length of elevator cable reached.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                }
                break;

            case ElevatorStates.Raising:
                status = "Raising";
                Events["StopElevator"].active = true;

                distanceDelta   = elevatorSpeed * TimeWarp.fixedDeltaTime;
                travelDistance -= distanceDelta;
                elevatorTransform.Translate(0f, distanceDelta, 0f);

                //If we've are back to our original position then we're done.
                if (travelDistance < 0.001f)
                {
                    setNextState();
                    travelDistance = 0f;
                }

                break;

            default:
                break;
            }
        }