コード例 #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>());
 }
コード例 #2
0
 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>();
         }
     }
 }
コード例 #3
0
        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;
                    }
                }
            }
        }