Added Crop, Farming&Harvesting functionality (no graphics yet!)
This commit is contained in:
parent
b9030174b6
commit
a3a81eeb2a
3 changed files with 101 additions and 3 deletions
|
|
@ -37,7 +37,5 @@ namespace Tiles
|
|||
Debug.Log(usable.ToString() + " used on " + this.ToString());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,68 @@
|
|||
using UnityEngine;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using DefaultNamespace;
|
||||
using Items;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Tiles
|
||||
{
|
||||
public class FarmlandTile : BaseTile
|
||||
{
|
||||
private Crop _crop;
|
||||
private bool _hydrated;
|
||||
|
||||
public FarmlandTile() : base(Color.black)
|
||||
{
|
||||
_crop = null;
|
||||
_hydrated = false;
|
||||
}
|
||||
|
||||
public new void DayLightStep()
|
||||
{
|
||||
if (_crop != null)
|
||||
{
|
||||
_crop.DayLightStep(_hydrated);
|
||||
if (_crop.MarkedForDeletion)
|
||||
{
|
||||
_crop = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new BaseTile Clicked(UsableItem usable)
|
||||
{
|
||||
base.Clicked(usable);
|
||||
|
||||
ItemContainer ic = ItemContainer.Instance;
|
||||
|
||||
if (usable.id == ic.GetItemIdByName("Hoe"))
|
||||
{
|
||||
_hydrated = true;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
// add wheat to inventory
|
||||
_crop = null;
|
||||
}
|
||||
|
||||
private void Plant()
|
||||
{
|
||||
// wheatSeeds-- in inventory
|
||||
_crop = new Crop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue