From f25892b1e8acbbd61e5759b752011a95f38d6253 Mon Sep 17 00:00:00 2001 From: s-prechtl Date: Thu, 9 Jun 2022 09:34:27 +0200 Subject: [PATCH] Bait usage --- Assets/Scripts/FishingController.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Assets/Scripts/FishingController.cs b/Assets/Scripts/FishingController.cs index d4269f4..10bc50a 100644 --- a/Assets/Scripts/FishingController.cs +++ b/Assets/Scripts/FishingController.cs @@ -33,6 +33,8 @@ public class FishingController : MonoBehaviour { private bool _catchable; private bool _caught; private Vector2 _ampsXY; + private Inventory _iv; + private ItemContainer _ic; public bool Fishing => _fishing; @@ -78,6 +80,10 @@ public class FishingController : MonoBehaviour { } public void StartFishing() { + if (!_iv.items.ContainsKey(_ic.GetItemByName("Bait"))) { + Debug.Log("No bait!"); + return; + } Vector3 pos = Input.mousePosition; if (Camera.main != null) { @@ -93,6 +99,11 @@ public class FishingController : MonoBehaviour { _exMark.transform.position = new Vector3(newPosX, newPosY); } _fishing = true; + + if (Random.Range(0, 10) > 5) { //uses bait to certain chance + _iv.RemoveItem(_ic.GetItemByName("Bait"), 1); + } + } public void TryCatch() {