mirror of
https://github.com/DerTyp7/harvestdale-unity.git
synced 2025-10-30 13:07:10 +01:00
a
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user