Ejemplo n.º 1
0
 void Update()
 {
     //press space to decouple all trucks from yourself and eachother
     if (Input.GetKeyDown(KeyCode.Space))
     {
         foreach (GameObject link in linked)
         {
             if (link != null)
             {
                 TruckMove truckMove = link.GetComponent <TruckMove>();
                 if (truckMove != null)
                 {
                     truckMove.RemoveAllConnections(train);
                 }
             }
         }
         linked[0] = null;
         linked[1] = null;
     }
 }
Ejemplo n.º 2
0
 public void RemoveAllConnections(GameObject caller)
 {
     print("name: " + truck.name);
     if (linked[0] != null)
     {
         print(linked[0].name);
     }
     else
     {
         print("Null");
     }
     if (linked[1] != null)
     {
         print(linked[1].name);
     }
     else
     {
         print("Null");
     }
     for (int i = 0; i <= 1; i++)
     {
         if (linked[i] != null)
         {
             TruckMove localTruck = linked[i].GetComponent <TruckMove>();
             linked[i] = null;
             if (localTruck == caller)
             {
             }
             if (localTruck != null && localTruck != caller && localTruck != truck && localTruck != train)
             {
                 localTruck.RemoveAllConnections(truck);
             }
         }
     }
     linked[0] = null;
     linked[1] = null;
 }