Update ItemStash for Dissapearing Pasties

This commit is contained in:
Philip W 2021-11-03 00:05:42 +00:00
parent fb9f847dbc
commit fa8cffae13
2 changed files with 22 additions and 3 deletions

View File

@ -566,7 +566,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 353042924}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 4.28, y: 0.71000004, z: 0}
m_LocalPosition: {x: 7.18, y: 0.71000004, z: 0}
m_LocalScale: {x: 1.5, y: 1.5, z: 0.5}
m_Children: []
m_Father: {fileID: 965912684}
@ -1624,7 +1624,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1530896880}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -4.58, y: 0.71000004, z: 0}
m_LocalPosition: {x: -7.14, y: 0.71000004, z: 0}
m_LocalScale: {x: 1.5, y: 1.5, z: 0.5}
m_Children: []
m_Father: {fileID: 965912684}

View File

@ -7,6 +7,8 @@ public class ItemStash : MonoBehaviour
[Header("Dropped Item Amount")]
public int droppedItemAmount = 3;
private GameObject[] pasties;
private void OnTriggerEnter2D(Collider2D other)
{
string objectTag = other.gameObject.tag;
@ -22,8 +24,25 @@ public class ItemStash : MonoBehaviour
droppedItemAmount += 1;
}
private void Start()
{
pasties = GameObject.FindGameObjectsWithTag("Pastie");
}
private void Update()
{
if (droppedItemAmount == 0 && pasties[0].GetComponent<SpriteRenderer>().enabled == true)
{
foreach (GameObject pastie in pasties)
{
pastie.GetComponent<SpriteRenderer>().enabled = false;
}
}
else if (droppedItemAmount != 0 && pasties[0].GetComponent<SpriteRenderer>().enabled == false)
{
foreach (GameObject pastie in pasties)
{
pastie.GetComponent<SpriteRenderer>().enabled = true;
}
}
}
}