Fishing Balanced

This commit is contained in:
s-prechtl 2022-06-09 11:45:45 +02:00
parent 072a06aef2
commit 6ba8615a1f
2 changed files with 24 additions and 25 deletions

View file

@ -16,4 +16,4 @@ MonoBehaviour:
description: Used to slap people. description: Used to slap people.
selectedSprite: {fileID: 21300000, guid: 8c01c1a230575ac4bb0aee5ba1c7757a, type: 3} selectedSprite: {fileID: 21300000, guid: 8c01c1a230575ac4bb0aee5ba1c7757a, type: 3}
defaultSprite: {fileID: 21300000, guid: d1b54b7f17e2d4d4e82d50d710d4482c, type: 3} defaultSprite: {fileID: 21300000, guid: d1b54b7f17e2d4d4e82d50d710d4482c, type: 3}
price: 150 price: 50

View file

@ -26,12 +26,21 @@ public class FishingController : MonoBehaviour {
public GameObject exMark; public GameObject exMark;
private double _fishingTime; private double _fishingTime;
private double _fishCooldown; private double _fishCooldown;
private double fishCooldown {
get => _fishCooldown;
set {
_fishCooldown = value;
exMark.SetActive(Catchable);
}
}
private const float MinFishCooldown = 1.5f; private const float MinFishCooldown = 1.5f;
private const float MaxFishCooldown = 7f; private const float MaxFishCooldown = 7f;
private const double MaxTime = 2f; private const double MaxTime = 2f;
private bool _fishing; private bool _fishing;
private bool _catchable; private bool Catchable => fishCooldown <= 0;
private bool _caught; private bool _caught;
private Vector2 _ampsXY; private Vector2 _ampsXY;
private Inventory _iv; private Inventory _iv;
@ -50,14 +59,10 @@ public class FishingController : MonoBehaviour {
// Update is called once per frame // Update is called once per frame
void Update() { void Update() {
if (_fishing) { //Fishing if (_fishing) { //Fishing
if (!_catchable) { // Fish not spawned yet
_fishCooldown -= Time.deltaTime; if (!Catchable) {
if (_fishCooldown <= 0) { //fish will get spawned // Fish not spawned yet
_catchable = true; fishCooldown -= Time.deltaTime;
if (!exMark.activeSelf) {
exMark.SetActive(true);
}
}
} else { } else {
_fishingTime += Time.deltaTime; _fishingTime += Time.deltaTime;
NotifyShake(); NotifyShake();
@ -76,9 +81,8 @@ public class FishingController : MonoBehaviour {
private void ResetFishing() { private void ResetFishing() {
_fishing = false; _fishing = false;
_catchable = false;
_fishingTime = 0f; _fishingTime = 0f;
_fishCooldown = Random.Range(MinFishCooldown, MaxFishCooldown); fishCooldown = Random.Range(MinFishCooldown, MaxFishCooldown);
exMark.SetActive(false); exMark.SetActive(false);
} }
@ -102,26 +106,21 @@ public class FishingController : MonoBehaviour {
exMark.transform.position = new Vector3(newPosX, newPosY); exMark.transform.position = new Vector3(newPosX, newPosY);
} }
_fishing = true; _fishing = true;
if (Random.Range(0, 10) > 5) { //uses bait to certain chance
_iv.RemoveItem(_ic.GetItemByName("Bait"), 1); _iv.RemoveItem(_ic.GetItemByName("Bait"), 1);
} }
}
public void TryCatch() { public void TryCatch() {
if (_fishing && _catchable) { if (_fishing && Catchable) {
Debug.Log("Tried to catch!"); Debug.Log("Tried to catch!");
if (_fishingTime <= MaxTime) { if (_fishingTime <= MaxTime) {
Debug.Log("Caught!"); Debug.Log("Caught!");
_iv.AddItem(_ic.GetItemByName("Fish"), Math.Max((int)(1 / (_fishingTime/2)), 1)); _iv.AddItem(_ic.GetItemByName("Fish"), Math.Max((int)(1 / (_fishingTime / 2)), 1));
ResetFishing(); ResetFishing();
} else { } else {
Debug.Log("Failed to catch!"); Debug.Log("Failed to catch!");
_catchable = false;
_fishingTime = 0f; _fishingTime = 0f;
exMark.SetActive(false); exMark.SetActive(false);
_fishCooldown = Random.Range(MinFishCooldown+2, MaxFishCooldown); fishCooldown = Random.Range(MinFishCooldown + 2, MaxFishCooldown);
} }
} }
} }