mirror of
https://github.com/DerTyp7/harvestdale-unity.git
synced 2025-10-29 04:42:08 +01:00
add field functinallity
This commit is contained in:
@@ -3,12 +3,35 @@ using UnityEngine;
|
|||||||
|
|
||||||
public class FieldController : Interactable
|
public class FieldController : Interactable
|
||||||
{
|
{
|
||||||
public Field field;
|
private Field field;
|
||||||
public Crop testCrop;
|
|
||||||
|
public override string interactText => field.State == FieldState.EMPTY ? "Plant" : field.State == FieldState.HARVESTABLE ? "Harvest" : field.State == FieldState.GROWING && !field.IsWatered ? "Water" : "Empty";
|
||||||
|
|
||||||
|
public void SetField(Field field)
|
||||||
|
{
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnInteract()
|
public override void OnInteract()
|
||||||
{
|
{
|
||||||
Debug.Log("Interacting with field");
|
Debug.Log("Interacting with field");
|
||||||
field.Plant(testCrop);
|
if (field.State == FieldState.EMPTY)
|
||||||
|
{
|
||||||
|
if (FarmManager.Instance.CropInventory.Items.Length > 0)
|
||||||
|
field.Plant(FarmManager.Instance.CropInventory.Items[0].item);
|
||||||
|
}
|
||||||
|
else if (field.State == FieldState.HARVESTABLE)
|
||||||
|
{
|
||||||
|
field.Harvest();
|
||||||
|
}
|
||||||
|
else if (field.State == FieldState.GROWING && !field.IsWatered)
|
||||||
|
{
|
||||||
|
field.Water();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
field.EmptyField();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user