예제 #1
0
 /// <summary>
 /// Initialize train
 /// </summary>
 void Start()
 {
     _rigidbody      = GetComponent <Rigidbody>();
     _transform      = GetComponent <Transform>();
     _doorController = GetComponent <ITrainDoorsController>();
     ConnectWagons();
     InitializeSFX();
 }
예제 #2
0
        private void Start()
        {
            if (train == null)
            {
                return;
            }

            _doorController = train.GetComponent <ITrainDoorsController>();
            _playerInput    = train.GetComponent <TrainPlayerInput>();

            ConfigureInputText();
        }
예제 #3
0
        private void OnTriggerEnter(Collider other)
        {
            TrainStationController trainStationController = other.GetComponent <TrainStationController>();

            if (trainStationController != null)
            {
                switch (stopMode)
                {
                case StopMode.Always:
                    trainStationController.StopAtStation(stationBehaviour, stopTimeout, turnOffEngines);
                    break;

                case StopMode.Once:
                    if (!_alreadyStopped)
                    {
                        trainStationController.StopAtStation(stationBehaviour, stopTimeout, turnOffEngines);
                        _alreadyStopped = true;
                    }
                    break;

                case StopMode.Random:
                    if (Probability.RandomEvent(randomStopProbability))
                    {
                        trainStationController.StopAtStation(stationBehaviour, stopTimeout, turnOffEngines);
                    }
                    break;
                }

                ITrainDoorsController trainDoorsController = other.GetComponent <ITrainDoorsController>();

                if (trainDoorsController != null)
                {
                    trainDoorsController.StationDoorDirection = stationDoorDirection;
                }
            }
        }