added Debug.Log for Farmland and Crop

This commit is contained in:
j-weissen 2022-05-20 09:11:58 +02:00
parent 35f93ed50c
commit 108c7b909c
2 changed files with 37 additions and 36 deletions

View file

@ -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; private void Grow()
public bool FullyGrown => _fullyGrown; {
Debug.Log("Crop grown");
_daysGrown++;
}
private bool _markedForDeletion; public void DayLightStep(bool hydrated)
public bool MarkedForDeletion => _markedForDeletion; {
if (_daysGrown >= DaysUntilFinished)
private int _daysGrown;
public Crop()
{ {
_fullyGrown = false; _fullyGrown = true;
_markedForDeletion = false;
_daysGrown = 0;
} }
private void Grow() if (!hydrated)
{ {
_daysGrown++; _markedForDeletion = true;
} }
else if (!_fullyGrown)
public void DayLightStep(bool hydrated)
{ {
if (_daysGrown >= DaysUntilFinished) Grow();
{
_fullyGrown = true;
}
if (!hydrated)
{
_markedForDeletion = true;
}
else if (!_fullyGrown)
{
Grow();
}
} }
} }
} }

View file

@ -1,8 +1,4 @@
using System; using UnityEngine;
using System.Threading;
using DefaultNamespace;
using Items;
using UnityEngine;
namespace Tiles namespace Tiles
{ {
@ -24,6 +20,7 @@ namespace Tiles
_crop.DayLightStep(_hydrated); _crop.DayLightStep(_hydrated);
if (_crop.MarkedForDeletion) if (_crop.MarkedForDeletion)
{ {
Debug.Log("Farmland crop deleted");
_crop = null; _crop = null;
} }
} }
@ -37,6 +34,7 @@ namespace Tiles
if (usable.id == ic.GetItemIdByName("Hoe")) if (usable.id == ic.GetItemIdByName("Hoe"))
{ {
Debug.Log("Farmland hydrated");
_hydrated = true; _hydrated = true;
} }
@ -55,12 +53,14 @@ namespace Tiles
private void Harvest() private void Harvest()
{ {
Debug.Log("Farmland harvested");
// add wheat to inventory // add wheat to inventory
_crop = null; _crop = null;
} }
private void Plant() private void Plant()
{ {
Debug.Log("Farmland planted");
// wheatSeeds-- in inventory // wheatSeeds-- in inventory
_crop = new Crop(); _crop = new Crop();
} }