/// <summary>
        /// Update wagons doors controllers list, if the script is attached to a locomotive
        /// </summary>
        public void UpdateWagonsDoorsControllers()
        {
            //If null wagon script is attached to wagon
            if (_trainController == null)
            {
                return;
            }

            _wagonsDoorsControllers = new List <TrainDoorsController>();

            if (_trainController.wagons == null)
            {
                return;
            }

            foreach (var wagon in _trainController.wagons)
            {
                TrainDoorsController doorController = wagon.GetComponent <TrainDoorsController>();

                if (doorController != null)
                {
                    _wagonsDoorsControllers.Add(doorController);
                }
            }
        }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     _locomotive     = GetComponent <TrainController_v3>();
     _doorController = GetComponent <TrainDoorsController>();
 }