Ejemplo n.º 1
0
 /// <summary>
 /// Wagon finished ride
 /// </summary>
 private void WagonFinishedRideEvent()
 {
     if (CurrentWagonController != null)
     {
         CurrentWagonController = null;
         if (wagonSpawnQueue.Count > 0)
         {
             wagonSpawnQueue.Dequeue();
         }
         elapsedTime = 0.0f;
         if (wagonSpawnQueue.Count <= 0)
         {
             onFinishWagonSpawner?.Invoke();
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Update
 /// </summary>
 private void Update()
 {
     if ((wagonSpawnQueue.Count > 0) && (wagonAsset != null) && (CurrentWagonController == null))
     {
         WagonSpawnData wagon_spawn_data = wagonSpawnQueue.Peek();
         if (wagon_spawn_data == null)
         {
             wagonSpawnQueue.Dequeue();
         }
         else
         {
             elapsedTime += Time.deltaTime;
             if (elapsedTime >= wagon_spawn_data.Delay)
             {
                 elapsedTime = 0.0f;
                 GameObject go = Instantiate(wagonAsset, transform);
                 if (go != null)
                 {
                     WagonControllerScript wagon_controller = go.GetComponent<WagonControllerScript>();
                     Animator animator = go.GetComponent<Animator>();
                     if ((wagon_controller == null) || (animator == null))
                     {
                         Destroy(go);
                     }
                     else
                     {
                         CurrentWagonController = wagon_controller;
                         wagon_controller.WantsPhoto = wagon_spawn_data.WantsPhoto;
                         wagon_controller.OnFinishWagonRide?.AddListener(WagonFinishedRideEvent);
                         Debug.Log("Playing animation " + AnimationPrefix + (railID + 1));
                         animator.Play(AnimationPrefix + (railID + 1), 0);
                         onSpawnWagon?.Invoke();
                     }
                 }
             }
         }
     }
 }