Beispiel #1
0
 void OnCollisionStay2D(Collision2D other)
 {
     if (other.gameObject.CompareTag("FishSchool"))
     {
         currentFishSchool = other.gameObject.GetComponent <FishSchoolGameScript>();
     }
 }
Beispiel #2
0
        void Start()
        {
            controls        = GetComponent <MouseControls>();
            fishMeterNeedle = FindObjectOfType <FishMeterNeedle>();

            audioPlayer    = FindObjectOfType <AudioPlayer>();
            mainGameScript = FindObjectOfType <MainGameScript>();
            fishStack      = GetComponentInChildren <FishStack>();

            currentFishSchool = null;

            currentWeight = 0.0f;

            newDay = false;
        }
Beispiel #3
0
 void OnCollisionExit2D(Collision2D other)
 {
     if (other.gameObject.CompareTag("FishSchool"))
     {
         if (currentFishSchool != null)
         {
             if (other.gameObject == currentFishSchool.gameObject)
             {
                 currentFishSchool = null;
             }
         }
     }
     else if (other.gameObject.CompareTag("Dock"))
     {
         isDocked = false;
     }
 }
Beispiel #4
0
        IEnumerator StartFishing()
        {
            isFishing = true;
            yield return(new WaitUntil(() => controls.GetMouseButtonDown(0)));

            if (currentFishSchool != null)
            {
                if (Mathf.Abs(fishMeterNeedle.GetNormalizedValue()) <= fishingMeterTolerance)
                {
                    currentWeight += currentFishSchool.weight;
                    Debug.Log($"Successfully fished a {currentFishSchool.weight:F2}kg. fish!");

                    audioPlayer.PlaySound(audioPlayer.fished);
                }
                else
                {
                    Debug.Log($"Failed to fished a {currentFishSchool.weight:F2}kg. fish");
                }
            }

            isFishing        = false;
            lastFishedSchool = currentFishSchool;
            yield return(null);
        }