cow can be milked

This commit is contained in:
d-hain 2022-06-23 23:59:32 +02:00
parent c40aec0022
commit 4e286d74ce
7 changed files with 51 additions and 15 deletions

View file

@ -89,14 +89,16 @@ namespace Assets.Scripts.Actions {
}
public abstract class AbstractAnimalClickActionHandler : ClickActionHandler {
public void InvokeAction(GameObject gameObject) {
protected Animal _animal;
public virtual void InvokeAction(GameObject gameObject) {
throw new System.NotImplementedException();
}
public bool Matches(GameObject gameObject, UsableItem usableItem) {
public virtual bool Matches(GameObject gameObject, UsableItem usableItem) {
bool rv = false;
try {
gameObject.GetComponent<Animal>();
_animal = gameObject.GetComponent<Animal>();
rv = true;
}
catch { }
@ -265,4 +267,18 @@ namespace Assets.Scripts.Actions {
return rv;
}
}
public class CowAnimalClickActionHandler : AbstractAnimalClickActionHandler {
public override void InvokeAction(GameObject gameObject) {
Inventory.instance.AddElement(_animal.producedItem, 1);
}
public override bool Matches(GameObject gameObject, UsableItem usableItem) {
bool rv = base.Matches(gameObject, usableItem);
if(rv) {
rv = _animal.displayName.Equals("Cow") && usableItem.ID == ItemContainer.Instance.GetItemIdByName("Bucket");
}
return rv;
}
}
}