From 108c7b909c52c1e4c701726993382da2057f26a7 Mon Sep 17 00:00:00 2001 From: j-weissen Date: Fri, 20 May 2022 09:11:58 +0200 Subject: [PATCH] added Debug.Log for Farmland and Crop --- Assets/Scripts/Crop.cs | 63 ++++++++++++++-------------- Assets/Scripts/Tiles/FarmlandTile.cs | 10 ++--- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Assets/Scripts/Crop.cs b/Assets/Scripts/Crop.cs index a5231d1..441c2d1 100644 --- a/Assets/Scripts/Crop.cs +++ b/Assets/Scripts/Crop.cs @@ -1,44 +1,45 @@ -namespace DefaultNamespace +using UnityEngine; + +public class Crop { - public class Crop + private const int DaysUntilFinished = 4; + + private bool _fullyGrown; + public bool FullyGrown => _fullyGrown; + + private bool _markedForDeletion; + public bool MarkedForDeletion => _markedForDeletion; + + private int _daysGrown; + + public Crop() { - private const int DaysUntilFinished = 4; + Debug.Log("Crop created"); + _fullyGrown = false; + _markedForDeletion = false; + _daysGrown = 0; + } - private bool _fullyGrown; - public bool FullyGrown => _fullyGrown; - - private bool _markedForDeletion; - public bool MarkedForDeletion => _markedForDeletion; + private void Grow() + { + Debug.Log("Crop grown"); + _daysGrown++; + } - private int _daysGrown; - - public Crop() + public void DayLightStep(bool hydrated) + { + if (_daysGrown >= DaysUntilFinished) { - _fullyGrown = false; - _markedForDeletion = false; - _daysGrown = 0; + _fullyGrown = true; } - private void Grow() + if (!hydrated) { - _daysGrown++; + _markedForDeletion = true; } - - public void DayLightStep(bool hydrated) + else if (!_fullyGrown) { - if (_daysGrown >= DaysUntilFinished) - { - _fullyGrown = true; - } - - if (!hydrated) - { - _markedForDeletion = true; - } - else if (!_fullyGrown) - { - Grow(); - } + Grow(); } } } \ No newline at end of file diff --git a/Assets/Scripts/Tiles/FarmlandTile.cs b/Assets/Scripts/Tiles/FarmlandTile.cs index e2c7278..d1dcf5e 100644 --- a/Assets/Scripts/Tiles/FarmlandTile.cs +++ b/Assets/Scripts/Tiles/FarmlandTile.cs @@ -1,8 +1,4 @@ -using System; -using System.Threading; -using DefaultNamespace; -using Items; -using UnityEngine; +using UnityEngine; namespace Tiles { @@ -24,6 +20,7 @@ namespace Tiles _crop.DayLightStep(_hydrated); if (_crop.MarkedForDeletion) { + Debug.Log("Farmland crop deleted"); _crop = null; } } @@ -37,6 +34,7 @@ namespace Tiles if (usable.id == ic.GetItemIdByName("Hoe")) { + Debug.Log("Farmland hydrated"); _hydrated = true; } @@ -55,12 +53,14 @@ namespace Tiles private void Harvest() { + Debug.Log("Farmland harvested"); // add wheat to inventory _crop = null; } private void Plant() { + Debug.Log("Farmland planted"); // wheatSeeds-- in inventory _crop = new Crop(); }