Skip to content
Snippets Groups Projects
Verified Commit 64069903 authored by Adrian Paschkowski's avatar Adrian Paschkowski :thinking:
Browse files

Deactivate enemy dragging with open store

parent 27afe738
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ public class StoreStateHandler : MonoBehaviour, IRoundCallback ...@@ -23,6 +23,7 @@ public class StoreStateHandler : MonoBehaviour, IRoundCallback
storeContainer.SetActive(true); storeContainer.SetActive(true);
storeButton.SetActive(false); storeButton.SetActive(false);
objectsToHideOnOpenStore.ForEach(o => o.SetActive(false)); objectsToHideOnOpenStore.ForEach(o => o.SetActive(false));
DragDestroyController.instance.SetDraggingEnabled(false);
} }
public void CloseStore() public void CloseStore()
...@@ -31,10 +32,12 @@ public class StoreStateHandler : MonoBehaviour, IRoundCallback ...@@ -31,10 +32,12 @@ public class StoreStateHandler : MonoBehaviour, IRoundCallback
storeContainer.SetActive(false); storeContainer.SetActive(false);
storeButton.SetActive(true); storeButton.SetActive(true);
objectsToHideOnOpenStore.ForEach(o => o.SetActive(true)); objectsToHideOnOpenStore.ForEach(o => o.SetActive(true));
DragDestroyController.instance.SetDraggingEnabled(true);
} }
public void OnRoundStart() public void OnRoundStart()
{ {
CloseStore();
storeButton.SetActive(false); storeButton.SetActive(false);
} }
......
...@@ -5,10 +5,13 @@ using UnityEngine; ...@@ -5,10 +5,13 @@ using UnityEngine;
public class DragDestroyController : MonoBehaviour public class DragDestroyController : MonoBehaviour
{ {
public static DragDestroyController instance { get; private set; }
[SerializeField] Color disabledColor; [SerializeField] Color disabledColor;
[SerializeField] LayerMask fighterRaycastLayer; [SerializeField] LayerMask fighterRaycastLayer;
[SerializeField] float fighterRaycastLength = 20f; [SerializeField] float fighterRaycastLength = 20f;
bool draggingEnabled = true;
GameObject selectedEnemy; GameObject selectedEnemy;
SpriteRenderer selectedEnemySprite; SpriteRenderer selectedEnemySprite;
Vector3 originalEnemyPosition; Vector3 originalEnemyPosition;
...@@ -16,14 +19,14 @@ public class DragDestroyController : MonoBehaviour ...@@ -16,14 +19,14 @@ public class DragDestroyController : MonoBehaviour
int noCollisionLayer; int noCollisionLayer;
void Awake() public void SetDraggingEnabled(bool enabled)
{ {
noCollisionLayer = LayerMask.NameToLayer("No Collision"); draggingEnabled = enabled;
} }
void Update() void Update()
{ {
if (!RoundController.instance.roundRunning) if (!RoundController.instance.roundRunning && draggingEnabled)
{ {
if (Input.GetButtonUp("Fire2") && selectedEnemy == null) if (Input.GetButtonUp("Fire2") && selectedEnemy == null)
{ {
...@@ -113,4 +116,19 @@ public class DragDestroyController : MonoBehaviour ...@@ -113,4 +116,19 @@ public class DragDestroyController : MonoBehaviour
pos.z = selectedEnemy.transform.position.z; pos.z = selectedEnemy.transform.position.z;
return pos; return pos;
} }
void Awake()
{
if (instance == null)
{
instance = this;
}
else if (instance != this)
{
Destroy(gameObject);
}
DontDestroyOnLoad(gameObject);
noCollisionLayer = LayerMask.NameToLayer("No Collision");
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment