Crops working
This commit is contained in:
parent
22a4abf927
commit
7ceb7e4bcb
10 changed files with 388 additions and 117 deletions
|
|
@ -6,52 +6,23 @@ namespace Tiles
|
|||
{
|
||||
private Crop _crop;
|
||||
|
||||
public FarmlandTile() : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_008.png")
|
||||
public FarmlandTile(GameObject gameObject) : base("Assets/Farming Asset Pack/Split Assets/farming_tileset_008.png", gameObject)
|
||||
{
|
||||
_crop = null;
|
||||
_crop = new Crop(gameObject.transform.GetChild(1).GetComponent<SpriteRenderer>(),
|
||||
gameObject.transform.GetChild(0).GetComponent<SpriteRenderer>());
|
||||
}
|
||||
|
||||
public override void DayLightStep()
|
||||
{
|
||||
_crop.DayLightStep();
|
||||
}
|
||||
|
||||
public new void DayLightStep()
|
||||
{
|
||||
}
|
||||
|
||||
public new BaseTile Clicked(UsableItem usable)
|
||||
public override BaseTile Clicked(UsableItem usable)
|
||||
{
|
||||
base.Clicked(usable);
|
||||
|
||||
ItemContainer ic = ItemContainer.Instance;
|
||||
|
||||
if (usable.id == ic.GetItemIdByName("Hoe"))
|
||||
{
|
||||
Debug.Log("Farmland hydrated");
|
||||
//_hydrated = true;
|
||||
}
|
||||
_crop.Clicked(usable);
|
||||
|
||||
if (usable.id == ic.GetItemIdByName("Wheat Seed") && _crop == null)
|
||||
{
|
||||
Plant();
|
||||
}
|
||||
|
||||
if (usable.id == ic.GetItemIdByName("Scythe") && _crop != null && _crop.FullyGrown)
|
||||
{
|
||||
Harvest();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue