oba jetzt wirklich
This commit is contained in:
parent
a5ded24c36
commit
5433305b14
4 changed files with 32 additions and 36 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Transactions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Actions {
|
namespace Actions {
|
||||||
public interface ActionHandler {
|
public interface ClickActionHandler {
|
||||||
public void InvokeAction(GameObject gameObject, UsableItem usableItem);
|
public void InvokeAction(GameObject gameObject);
|
||||||
public bool Matches(GameObject gameObject, UsableItem usableItem);
|
public bool Matches(GameObject gameObject, UsableItem usableItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,14 +1,12 @@
|
||||||
using Actions;
|
using Actions;
|
||||||
using Tiles;
|
using Tiles;
|
||||||
using TMPro.EditorUtilities;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Assets.Scripts.Actions {
|
namespace Assets.Scripts.Actions {
|
||||||
public abstract class AbstractTileActionHandler : ActionHandler {
|
public abstract class AbstractTileClickActionHandler : ClickActionHandler {
|
||||||
protected BaseTile _tile;
|
protected BaseTile _tile;
|
||||||
protected int _usableItemId;
|
|
||||||
protected ItemContainer _ic;
|
protected ItemContainer _ic;
|
||||||
public virtual void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public virtual void InvokeAction(GameObject gameObject) {
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -19,12 +17,12 @@ namespace Assets.Scripts.Actions {
|
||||||
_tile = gameObject.GetComponent<TileBehaviour>().Tile;
|
_tile = gameObject.GetComponent<TileBehaviour>().Tile;
|
||||||
rv = true;
|
rv = true;
|
||||||
}
|
}
|
||||||
catch {
|
catch { }
|
||||||
}
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public abstract class AbstractGrassTileActionHandler : AbstractTileActionHandler {
|
public abstract class AbstractGrassTileClickActionHandler : AbstractTileClickActionHandler {
|
||||||
public override bool Matches(GameObject gameObject, UsableItem usableItem) {
|
public override bool Matches(GameObject gameObject, UsableItem usableItem) {
|
||||||
bool rv = base.Matches(gameObject, usableItem);
|
bool rv = base.Matches(gameObject, usableItem);
|
||||||
if(rv) {
|
if(rv) {
|
||||||
|
|
@ -33,7 +31,7 @@ namespace Assets.Scripts.Actions {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public abstract class AbstractFarmlandTileActionHandler : AbstractTileActionHandler {
|
public abstract class AbstractFarmlandTileClickActionHandler : AbstractTileClickActionHandler {
|
||||||
protected Crop crop;
|
protected Crop crop;
|
||||||
public override bool Matches(GameObject gameObject, UsableItem usableItem) {
|
public override bool Matches(GameObject gameObject, UsableItem usableItem) {
|
||||||
bool rv = base.Matches(gameObject, usableItem);
|
bool rv = base.Matches(gameObject, usableItem);
|
||||||
|
|
@ -78,7 +76,7 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public abstract class AbstractWaterTileActionHandler : AbstractTileActionHandler {
|
public abstract class AbstractWaterTileClickActionHandler : AbstractTileClickActionHandler {
|
||||||
public override bool Matches(GameObject gameObject, UsableItem usableItem) {
|
public override bool Matches(GameObject gameObject, UsableItem usableItem) {
|
||||||
bool rv = base.Matches(gameObject, usableItem);
|
bool rv = base.Matches(gameObject, usableItem);
|
||||||
if(rv) {
|
if(rv) {
|
||||||
|
|
@ -88,25 +86,24 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class AbstractAnimalActionHandler : ActionHandler {
|
public abstract class AbstractAnimalClickActionHandler : ClickActionHandler {
|
||||||
public virtual void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public void InvokeAction(GameObject gameObject) {
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool Matches(GameObject gameObject, UsableItem usableItem) {
|
public bool Matches(GameObject gameObject, UsableItem usableItem) {
|
||||||
bool rv = false;
|
bool rv = false;
|
||||||
try {
|
try {
|
||||||
gameObject.GetComponent<Animal>();
|
gameObject.GetComponent<Animal>();
|
||||||
rv = true;
|
rv = true;
|
||||||
}
|
}
|
||||||
catch {
|
catch { }
|
||||||
}
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GrassTileHoeActionHandler : AbstractGrassTileActionHandler {
|
public class GrassTileClickHoeActionHandler : AbstractGrassTileClickActionHandler {
|
||||||
public override void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public override void InvokeAction(GameObject gameObject) {
|
||||||
gameObject.GetComponent<TileBehaviour>().Tile = new FarmlandTile();
|
gameObject.GetComponent<TileBehaviour>().Tile = new FarmlandTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,8 +116,8 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GrassTileShovelActionHandler : AbstractGrassTileActionHandler {
|
public class GrassTileClickShovelActionHandler : AbstractGrassTileClickActionHandler {
|
||||||
public override void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public override void InvokeAction(GameObject gameObject) {
|
||||||
gameObject.GetComponent<TileBehaviour>().Tile = new WaterTile();
|
gameObject.GetComponent<TileBehaviour>().Tile = new WaterTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,8 +130,8 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GrassTileFenceActionHandler : AbstractGrassTileActionHandler {
|
public class GrassTileClickFenceActionHandler : AbstractGrassTileClickActionHandler {
|
||||||
public override void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public override void InvokeAction(GameObject gameObject) {
|
||||||
SpriteRenderer fenceRenderer = null;
|
SpriteRenderer fenceRenderer = null;
|
||||||
BoxCollider2D fenceCollider = null;
|
BoxCollider2D fenceCollider = null;
|
||||||
foreach (Transform transChild in gameObject.GetComponentsInChildren<Transform>()) {
|
foreach (Transform transChild in gameObject.GetComponentsInChildren<Transform>()) {
|
||||||
|
|
@ -166,8 +163,8 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FarmlandTileShovelActionHandler : AbstractFarmlandTileActionHandler {
|
public class FarmlandTileClickShovelActionHandler : AbstractFarmlandTileClickActionHandler {
|
||||||
public override void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public override void InvokeAction(GameObject gameObject) {
|
||||||
gameObject.GetComponent<TileBehaviour>().Tile = new GrassTile();
|
gameObject.GetComponent<TileBehaviour>().Tile = new GrassTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,8 +177,8 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FarmlandTileScytheActionHandler : AbstractFarmlandTileActionHandler {
|
public class FarmlandTileClickScytheActionHandler : AbstractFarmlandTileClickActionHandler {
|
||||||
public override void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public override void InvokeAction(GameObject gameObject) {
|
||||||
if(crop.FullyGrown) {
|
if(crop.FullyGrown) {
|
||||||
Inventory.instance.AddElement(ItemContainer.Instance.GetItemByName("Wheat Seeds"),
|
Inventory.instance.AddElement(ItemContainer.Instance.GetItemByName("Wheat Seeds"),
|
||||||
(int)(Random.Range(1, 300)));
|
(int)(Random.Range(1, 300)));
|
||||||
|
|
@ -200,8 +197,8 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FarmlandTileWateringCanActionHandler : AbstractFarmlandTileActionHandler {
|
public class FarmlandTileClickWateringCanActionHandler : AbstractFarmlandTileClickActionHandler {
|
||||||
public override void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public override void InvokeAction(GameObject gameObject) {
|
||||||
crop.Hydrated = true;
|
crop.Hydrated = true;
|
||||||
updateFarmlandSprites(gameObject);
|
updateFarmlandSprites(gameObject);
|
||||||
}
|
}
|
||||||
|
|
@ -215,8 +212,8 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FarmlandTileWheatSeedsActionHandler : AbstractFarmlandTileActionHandler {
|
public class FarmlandTileClickWheatSeedsActionHandler : AbstractFarmlandTileClickActionHandler {
|
||||||
public override void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public override void InvokeAction(GameObject gameObject) {
|
||||||
if(!crop.Planted) {
|
if(!crop.Planted) {
|
||||||
crop.Plant();
|
crop.Plant();
|
||||||
Inventory.instance.RemoveElement(ItemContainer.Instance.GetItemByName("Wheat Seeds"), 1);
|
Inventory.instance.RemoveElement(ItemContainer.Instance.GetItemByName("Wheat Seeds"), 1);
|
||||||
|
|
@ -234,8 +231,8 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WaterTileShovelActionHandler : AbstractWaterTileActionHandler {
|
public class WaterTileClickShovelActionHandler : AbstractWaterTileClickActionHandler {
|
||||||
public override void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public override void InvokeAction(GameObject gameObject) {
|
||||||
gameObject.GetComponent<TileBehaviour>().Tile = new GrassTile();
|
gameObject.GetComponent<TileBehaviour>().Tile = new GrassTile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,10 +245,8 @@ namespace Assets.Scripts.Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WaterTileFishingRodActionHandler : AbstractWaterTileActionHandler {
|
public class WaterTileClickFishingRodActionHandler : AbstractWaterTileClickActionHandler {
|
||||||
public override void InvokeAction(GameObject gameObject, UsableItem usableItem) {
|
public override void InvokeAction(GameObject gameObject) {
|
||||||
ItemContainer ic = ItemContainer.Instance;
|
|
||||||
|
|
||||||
FishingController fc = FishingController.instance;
|
FishingController fc = FishingController.instance;
|
||||||
if(!fc.Fishing) {
|
if(!fc.Fishing) {
|
||||||
fc.StartFishing();
|
fc.StartFishing();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue