This commit is contained in:
Janis
2023-03-01 22:28:06 +01:00
parent 36337c8a72
commit ae0b21f9e9
19 changed files with 600 additions and 455 deletions

View File

@@ -1,5 +1,12 @@
using UnityEngine;
using UnityEngine.Tilemaps;
public enum FieldState
{
EMPTY,
DEAD,
GROWING,
HARVESTABLE,
}
public class Field : Building
{
@@ -8,18 +15,22 @@ public class Field : Building
public SpriteRenderer currentCropSprite;
public int daysSincePlanted;
public bool isWatered;
public bool isDead = false;
public bool isWatered = false;
public FieldState state = FieldState.EMPTY;
private void Start()
{
TimeManager.OnDayChanged += AddDay;
//! DEBUG
OnPlace();
}
private void AddDay()
{
if (crop && isPlaced && !isDead)
if (crop && isPlaced && state != FieldState.DEAD)
{
if (!isWatered)
isDead = true;
state = FieldState.DEAD;
else
{
daysSincePlanted++;
@@ -32,14 +43,14 @@ public class Field : Building
public void Plant(Crop newCrop)
{
daysSincePlanted = 0;
isDead = false;
state = FieldState.GROWING;
crop = newCrop;
}
public override void OnPlace()
{
daysSincePlanted = 0;
isDead = false;
state = FieldState.GROWING;
Plant(TESTCROP);
}
}