Esempio n. 1
0
 /// <summary>
 /// Awake is called when the script instance is being loaded.
 /// </summary>
 void Awake()
 {
     _distance  = transform.localScale.z;
     _direction = transform.forward;
     _rail      = this.GetComponent <Rail>();
     // _checkPoints = new List<CheckPoint>(this.GetComponentsInChildren<CheckPoint>());
 }
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.GetComponent <Rail>() != null)
     {
         if (other.gameObject.GetComponent <Rail>().isActive || currentRail == null)
         {
             rails.Enqueue(other.gameObject.GetComponent <Rail>());
             currentRail = other.gameObject.GetComponent <Rail>();
         }
     }
 }
        private void OnTriggerExit(Collider other)
        {
            if (other.gameObject.GetComponent <Rail>() != null)
            {
                if (other.gameObject.GetComponent <Rail>().isActive)
                {
                    Rail rail = rails.Dequeue();
                    if (rail.gameObject.GetComponent <Edge>() != null)
                    {
                        rail.gameObject.GetComponent <Edge>().DeActivate();
                    }
                    else
                    {
                        rail.DeActivate();
                    }

                    if (rails.Count == 0)
                    {
                        currentRail = null;
                    }
                }
            }
        }