cow can be milked
This commit is contained in:
parent
c40aec0022
commit
4e286d74ce
7 changed files with 51 additions and 15 deletions
|
|
@ -23,15 +23,15 @@ namespace Actions {
|
|||
private ActionManager() {
|
||||
_clickActionHandlers = new List<ClickActionHandler>();
|
||||
_nextDayActionHandlers = new List<NextDayActionHandler>();
|
||||
instantiateClickActionHandlers();
|
||||
instantiateNextDayActionHandlers();
|
||||
InstantiateClickActionHandlers();
|
||||
InstantiateNextDayActionHandlers();
|
||||
}
|
||||
|
||||
private void instantiateNextDayActionHandlers() {
|
||||
private void InstantiateNextDayActionHandlers() {
|
||||
_nextDayActionHandlers.Add(new FarmlandTileNextDayActionHandler());
|
||||
}
|
||||
|
||||
private void instantiateClickActionHandlers() {
|
||||
private void InstantiateClickActionHandlers() {
|
||||
_clickActionHandlers.Add(new GrassTileClickHoeActionHandler());
|
||||
_clickActionHandlers.Add(new GrassTileClickShovelActionHandler());
|
||||
_clickActionHandlers.Add(new GrassTileClickFenceActionHandler());
|
||||
|
|
@ -43,6 +43,8 @@ namespace Actions {
|
|||
|
||||
_clickActionHandlers.Add(new WaterTileClickShovelActionHandler());
|
||||
_clickActionHandlers.Add(new WaterTileClickFishingRodActionHandler());
|
||||
|
||||
_clickActionHandlers.Add(new CowAnimalClickActionHandler());
|
||||
}
|
||||
|
||||
public void ClickAction(GameObject gameObject, UsableItem usableItem) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue