Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
d60c65149c
5 changed files with 72 additions and 15 deletions
|
|
@ -23,12 +23,19 @@ namespace Actions {
|
||||||
|
|
||||||
private List<ClickActionHandler> _clickActionHandlers;
|
private List<ClickActionHandler> _clickActionHandlers;
|
||||||
private List<NextDayActionHandler> _nextDayActionHandlers;
|
private List<NextDayActionHandler> _nextDayActionHandlers;
|
||||||
|
private bool _enabled;
|
||||||
|
|
||||||
|
public bool Enabled {
|
||||||
|
get => _enabled;
|
||||||
|
set => _enabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
private ActionManager() {
|
private ActionManager() {
|
||||||
_clickActionHandlers = new List<ClickActionHandler>();
|
_clickActionHandlers = new List<ClickActionHandler>();
|
||||||
_nextDayActionHandlers = new List<NextDayActionHandler>();
|
_nextDayActionHandlers = new List<NextDayActionHandler>();
|
||||||
instantiateClickActionHandlers();
|
instantiateClickActionHandlers();
|
||||||
instantiateNextDayActionHandlers();
|
instantiateNextDayActionHandlers();
|
||||||
|
Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -65,6 +72,7 @@ namespace Actions {
|
||||||
/// <param name="gameObject">The affected gameObject</param>
|
/// <param name="gameObject">The affected gameObject</param>
|
||||||
/// <param name="usableItem">the current tool</param>
|
/// <param name="usableItem">the current tool</param>
|
||||||
public void ClickAction(GameObject gameObject, UsableItem usableItem) {
|
public void ClickAction(GameObject gameObject, UsableItem usableItem) {
|
||||||
|
if(Enabled) {
|
||||||
foreach(ClickActionHandler actionHandler in _clickActionHandlers) {
|
foreach(ClickActionHandler actionHandler in _clickActionHandlers) {
|
||||||
if(actionHandler.Matches(gameObject, usableItem)) {
|
if(actionHandler.Matches(gameObject, usableItem)) {
|
||||||
actionHandler.InvokeAction(gameObject);
|
actionHandler.InvokeAction(gameObject);
|
||||||
|
|
@ -72,15 +80,15 @@ namespace Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to Invoke ClickActions, all ClickActionHandlers in ClickActionHandlers list are iterated through,
|
/// Used to Invoke NextDay, all NextDayActionHandlers in NextDayActionHandlers list are iterated through,
|
||||||
/// only one will be invoked per method call
|
/// only one will be invoked per method call
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gameObject">The affected gameObject</param>
|
/// <param name="gameObject">The affected gameObject</param>
|
||||||
/// <param name="usableItem">the current tool</param>
|
|
||||||
public void NextDayAction(GameObject gameObject) {
|
public void NextDayAction(GameObject gameObject) {
|
||||||
Debug.Log("nextday action");
|
if(Enabled) {
|
||||||
foreach(NextDayActionHandler actionHandler in _nextDayActionHandlers) {
|
foreach(NextDayActionHandler actionHandler in _nextDayActionHandlers) {
|
||||||
if(actionHandler.Matches(gameObject)) {
|
if(actionHandler.Matches(gameObject)) {
|
||||||
actionHandler.InvokeAction(gameObject);
|
actionHandler.InvokeAction(gameObject);
|
||||||
|
|
@ -90,3 +98,4 @@ namespace Actions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
@ -100,7 +100,7 @@ namespace Assets.Scripts.Actions {
|
||||||
bool rv = false;
|
bool rv = false;
|
||||||
try {
|
try {
|
||||||
_animal = gameObject.GetComponent<Animal>();
|
_animal = gameObject.GetComponent<Animal>();
|
||||||
rv = true;
|
rv = _animal != null;
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
return rv;
|
return rv;
|
||||||
|
|
@ -277,7 +277,8 @@ namespace Assets.Scripts.Actions {
|
||||||
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) {
|
||||||
rv = _animal.displayName.Equals("Cow") && usableItem.ID == ItemContainer.Instance.GetItemIdByName("Bucket");
|
rv = _animal.displayName.Equals("Cow") &&
|
||||||
|
usableItem.ID == ItemContainer.Instance.GetItemIdByName("Bucket");
|
||||||
}
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Actions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
public class InventoryUI : MonoBehaviour {
|
public class InventoryUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
|
||||||
public Transform itemsParent;
|
public Transform itemsParent;
|
||||||
public GameObject inventoryUI;
|
public GameObject inventoryUI;
|
||||||
private Inventory _inventory;
|
private Inventory _inventory;
|
||||||
|
|
@ -59,4 +60,18 @@ public class InventoryUI : MonoBehaviour {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn off ActionManager when Pointer over UI
|
||||||
|
*/
|
||||||
|
public void OnPointerEnter(PointerEventData eventData) {
|
||||||
|
ActionManager.Instance.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on ActionManager when Pointer over UI
|
||||||
|
*/
|
||||||
|
public void OnPointerExit(PointerEventData eventData) {
|
||||||
|
ActionManager.Instance.Enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Actions;
|
||||||
|
using Tiles;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
|
||||||
namespace Shop {
|
namespace Shop {
|
||||||
public class ShopUI : MonoBehaviour {
|
public class ShopUI : MonoBehaviour , IPointerEnterHandler, IPointerExitHandler{
|
||||||
public Transform itemsParent;
|
public Transform itemsParent;
|
||||||
public Transform animalsParent;
|
public Transform animalsParent;
|
||||||
public GameObject shopUI;
|
public GameObject shopUI;
|
||||||
|
|
@ -81,5 +85,19 @@ namespace Shop {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn off ActionManager when Pointer over UI
|
||||||
|
*/
|
||||||
|
public void OnPointerEnter(PointerEventData eventData) {
|
||||||
|
ActionManager.Instance.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on ActionManager when Pointer over UI
|
||||||
|
*/
|
||||||
|
public void OnPointerExit(PointerEventData eventData) {
|
||||||
|
ActionManager.Instance.Enabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -7,6 +7,20 @@ using UnityEngine.Tilemaps;
|
||||||
/// Instatiates Tiles at beginning of the game
|
/// Instatiates Tiles at beginning of the game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TileController : MonoBehaviour {
|
public class TileController : MonoBehaviour {
|
||||||
|
#region Singleton
|
||||||
|
|
||||||
|
public static TileController instance;
|
||||||
|
|
||||||
|
private void Awake() {
|
||||||
|
if (instance != null) {
|
||||||
|
Debug.LogWarning("More than one instance of TileController found");
|
||||||
|
}
|
||||||
|
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public GameObject tile;
|
public GameObject tile;
|
||||||
|
|
||||||
public GameObject cameraGameObject;
|
public GameObject cameraGameObject;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue