Renaming QoL changes

This commit is contained in:
s-prechtl 2022-06-09 10:32:43 +02:00
parent d492a9efbb
commit 2412d0f9c6

View file

@ -5,6 +5,7 @@ using System.Data.Common;
using System.Net.Mail; using System.Net.Mail;
using System.Threading; using System.Threading;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
using Random = UnityEngine.Random; using Random = UnityEngine.Random;
public class FishingController : MonoBehaviour { public class FishingController : MonoBehaviour {
@ -22,13 +23,13 @@ public class FishingController : MonoBehaviour {
#endregion #endregion
public GameObject _exMark; public GameObject exMark;
private double _fishingTime; private double _fishingTime;
private double _fishCooldown; private double _fishCooldown;
private readonly float _minFishCooldown = 1.5f; private const float MinFishCooldown = 1.5f;
private readonly float _maxFishCooldown = 7f; private const float MaxFishCooldown = 7f;
private readonly double _maxTime = 2f; private const double MaxTime = 2f;
private bool _fishing; private bool _fishing;
private bool _catchable; private bool _catchable;
private bool _caught; private bool _caught;
@ -53,8 +54,8 @@ public class FishingController : MonoBehaviour {
_fishCooldown -= Time.deltaTime; _fishCooldown -= Time.deltaTime;
if (_fishCooldown <= 0) { //fish will get spawned if (_fishCooldown <= 0) { //fish will get spawned
_catchable = true; _catchable = true;
if (!_exMark.activeSelf) { if (!exMark.activeSelf) {
_exMark.SetActive(true); exMark.SetActive(true);
} }
} }
} else { } else {
@ -65,9 +66,9 @@ public class FishingController : MonoBehaviour {
} }
private void NotifyShake() { private void NotifyShake() {
_exMark.transform.position = exMark.transform.position =
new Vector3(_exMark.transform.position.x + _ampsXY.x * Time.deltaTime, new Vector3(exMark.transform.position.x + _ampsXY.x * Time.deltaTime,
_exMark.transform.position.y + _ampsXY.y * Time.deltaTime, exMark.transform.position.y + _ampsXY.y * Time.deltaTime,
transform.position.z); transform.position.z);
_ampsXY.x *= -1; _ampsXY.x *= -1;
_ampsXY.y *= -1; _ampsXY.y *= -1;
@ -77,8 +78,8 @@ public class FishingController : MonoBehaviour {
_fishing = false; _fishing = false;
_catchable = false; _catchable = false;
_fishingTime = 0f; _fishingTime = 0f;
_fishCooldown = Random.Range(_minFishCooldown, _maxFishCooldown); _fishCooldown = Random.Range(MinFishCooldown, MaxFishCooldown);
_exMark.SetActive(false); exMark.SetActive(false);
} }
public void StartFishing() { public void StartFishing() {
@ -92,13 +93,13 @@ public class FishingController : MonoBehaviour {
float newPosX = pos.x; float newPosX = pos.x;
float newPosY; float newPosY;
if (pos.y - 50 - ((RectTransform)_exMark.transform).rect.height >= 0) { //check if bottom of panel is in screen if (pos.y - 50 - ((RectTransform)exMark.transform).rect.height >= 0) { //check if bottom of panel is in screen
newPosY = pos.y - ((RectTransform)_exMark.transform).rect.height; newPosY = pos.y - ((RectTransform)exMark.transform).rect.height;
} else { } else {
newPosY = pos.y + ((RectTransform)_exMark.transform).rect.height; newPosY = pos.y + ((RectTransform)exMark.transform).rect.height;
} }
_exMark.transform.position = new Vector3(newPosX, newPosY); exMark.transform.position = new Vector3(newPosX, newPosY);
} }
_fishing = true; _fishing = true;
@ -111,7 +112,7 @@ public class FishingController : MonoBehaviour {
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();
@ -119,8 +120,8 @@ public class FishingController : MonoBehaviour {
Debug.Log("Failed to catch!"); Debug.Log("Failed to catch!");
_catchable = false; _catchable = false;
_fishingTime = 0f; _fishingTime = 0f;
_exMark.SetActive(false); exMark.SetActive(false);
_fishCooldown = Random.Range(_minFishCooldown+2, _maxFishCooldown); _fishCooldown = Random.Range(MinFishCooldown+2, MaxFishCooldown);
} }
} }
} }