Beispiel #1
0
 public void InitializeCarriage(NavSection navSection, NavConnection destination, Train engine, int carriage, int maxCarriages)
 {
     m_Engine        = engine;
     m_CarriageIndex = carriage;
     m_MaxCarriages  = maxCarriages;
     blockedDistance = 0.1f;
     Initialize(navSection, destination);
 }
Beispiel #2
0
        private void SpawnCarriage(NavSection navSection, NavConnection destination, int carriage)
        {
            Vector3 pos         = transform.TransformPoint(0, 0, -carriage * 1.05f);
            Train   newCarriage = Instantiate(TrafficSystem.Instance.trainCarriagePrefab, pos, transform.rotation, transform).GetComponent <Train>();

            newCarriage.transform.localScale = Vector3.one;
            newCarriage.InitializeCarriage(navSection, destination, this, carriage, carriageCount);
        }
Beispiel #3
0
        // -------------------------------------------------------------------
        // Initialization

        public override void Initialize(NavSection navSection, NavConnection destination)
        {
            for (int i = 0; i < carriageCount; i++)
            {
                SpawnCarriage(navSection, destination, i + 1);
            }
            base.Initialize(navSection, destination);
        }
Beispiel #4
0
 public override void RegisterVehicle(NavSection section, bool isAdd)
 {
     if (isAdd && m_CarriageIndex == 0)
     {
         base.RegisterVehicle(section, isAdd);
     }
     else if (!isAdd && m_CarriageIndex == m_MaxCarriages)
     {
         m_Engine.ForceUnregisterVehicle(section);
     }
 }
Beispiel #5
0
 public void ForceUnregisterVehicle(NavSection section)
 {
     base.RegisterVehicle(section, false);
 }