Пример #1
0
 public void DoneCollectingSample()
 {
     samplesCollected++;
     if (samplesCollected >= requiredSamples)
     {
         currentStage = CollectionStage.NeedLeave;
         uiSamplesText.gameObject.SetActive(false);
         uiSamplesLabelText.gameObject.SetActive(false);
         uiInstructionsText.gameObject.SetActive(true);
         uiInstructionsText.text = "RETURN to BASE\nfor ANALYSIS";
     }
 }
Пример #2
0
 void UpdateCompass()
 {
     if (currentStage == CollectionStage.NeedSites || currentStage == CollectionStage.Free)
     {
         //get closet soil site
         float nearestDist  = 10000000000;            // arbitrary high number
         int   nearestIndex = -1;
         for (int i = 0; i < soilSites.Count; i++)
         {
             if (soilSites[i].collectable)
             {
                 Vector3 displacement = soilSites[i].transform.position - robot.transform.position;
                 if (displacement.magnitude < nearestDist)
                 {
                     nearestDist  = displacement.magnitude;
                     nearestIndex = i;
                 }
             }
         }
         if (nearestIndex == -1)
         {
             // uh oh?
             currentStage = CollectionStage.NeedLeave;
         }
         else
         {
             // move compass to look at target
             compass.LookAt(soilSites[nearestIndex].transform);
         }
     }
     else if (currentStage == CollectionStage.NeedLeave)
     {
         compass.LookAt(endSite.transform);
     }
     else
     {
         // do nothing?
     }
 }