コード例 #1
0
 void Start()
 {
     if (WayPoints == null || WayPoints.Length == 0)
     {
         Debug.Log("Platform has no waypoints...disabling.");
         gameObject.SetActive(false);
         return;
     }
     //CurrentWayPointIndex = 1;
     CurrentCursorDir = StartingDirection;
     HasCollided      = false;
     HasCrushedPlayer = false;
 }
コード例 #2
0
 /*
  *      Increase the current waypoint index and if exceeds the length of
  *      the array reset it.
  */
 void IncreaseWayPointIndex()
 {
     //Debug.Log("Current waypoint index: " + CurrentWayPointIndex);
     //Debug.Log("Waypoint array length: " + WayPoints.Length);
     //If we have a single point this code is useless!
     if (WayPoints.Length == 1)
     {
         return;
     }
     //Debug.Log("CurrentCursorDir: " + CurrentCursorDir.ToString());
     //Debug.Log("CurrentWayPointIndex: " + CurrentWayPointIndex);
     if (CurrentCursorDir == WayPointCursorDir.CursorDir_UP)
     {
         if ((CurrentWayPointIndex + 1) >= WayPoints.Length)
         {
             //If CycleWayPoints cycle the array starting from the first element.
             if (CycleWayPoints)
             {
                 CurrentWayPointIndex = 0;
                 return;
             }
             //Change direction immediately.
             CurrentCursorDir = WayPointCursorDir.CursorDir_DOWN;
             CurrentWayPointIndex--;
             return;
         }
         CurrentWayPointIndex++;
     }
     else
     {
         if ((CurrentWayPointIndex - 1) < 0)
         {
             //If CycleWayPoints cycle the array starting from the last element.
             if (CycleWayPoints)
             {
                 CurrentWayPointIndex = WayPoints.Length - 1;
                 return;
             }
             //Change direction immediately.
             CurrentCursorDir = WayPointCursorDir.CursorDir_UP;
             CurrentWayPointIndex++;
             return;
         }
         CurrentWayPointIndex--;
     }
 }