Improved possible action panel

This commit is contained in:
alilas2 2022-06-12 17:18:43 +02:00
parent fce6e7aa9b
commit d352ad391f
6 changed files with 90 additions and 11 deletions

View File

@ -10,10 +10,15 @@ public class OpenPanelOnCollision : MonoBehaviour
public GameObject SecondPanel;
public GameObject PanelAbove;
public GameObject obj;
private bool inRange = false;
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.tag == "Player")
{
inRange = true;
if(SecondPanel.active == false)
{
Panel.SetActive(true);
@ -25,16 +30,77 @@ public class OpenPanelOnCollision : MonoBehaviour
}
}
void Update()
private void OnTriggerStay2D(Collider2D collision)
{
if(OtherPanel.active == true)
if (collision.tag == "Player")
{
inRange = true;
if(OtherPanel.active == true)
{
if (SecondPanel.active == false)
{
Panel.SetActive(false);
}
else
{
SecondPanel.SetActive(false);
PanelAbove.SetActive(false);
}
}
else if (SecondPanel.active == false)
{
Panel.SetActive(true);
}
else
{
PanelAbove.SetActive(true);
}
}
}
IEnumerator Timer1()
{
yield return new WaitForSeconds(0.3f);
if(inRange == false)
{
Panel.SetActive(false);
}
}
IEnumerator Timer2()
{
yield return new WaitForSeconds(0.3f);
if (inRange == false)
{
PanelAbove.SetActive(false);
}
}
void Update()
{
if(obj.active == false)
{
if (Panel.active == true)
{
Panel.SetActive(false);
}
else if (PanelAbove.active == true)
{
PanelAbove.SetActive(false);
}
}
if(OtherPanel.active == true)
{
StartCoroutine(Timer1());
}
if(SecondPanel.active == false)
{
if(PanelAbove.active == true)
{
StartCoroutine(Timer2());
PanelAbove.SetActive(false);
Panel.SetActive(true);
}
@ -43,13 +109,14 @@ public class OpenPanelOnCollision : MonoBehaviour
private void OnTriggerExit2D(Collider2D collision)
{
inRange = false;
if(Panel.active == true)
{
Panel.SetActive(false);
StartCoroutine(Timer1());
}
else if(PanelAbove.active == true)
{
PanelAbove.SetActive(false);
StartCoroutine(Timer2());
}
}
}

View File

@ -998,6 +998,7 @@ MonoBehaviour:
OtherPanel: {fileID: 163167163}
SecondPanel: {fileID: 1662373578}
PanelAbove: {fileID: 1293589669}
obj: {fileID: 2102416356}
--- !u!58 &132185249
CircleCollider2D:
m_ObjectHideFlags: 0
@ -7402,6 +7403,7 @@ MonoBehaviour:
OtherPanel: {fileID: 5331092055018478733, guid: 2b46aee216d4b304f8aebcb303ebf4f4, type: 3}
SecondPanel: {fileID: 1662373578}
PanelAbove: {fileID: 1293589669}
obj: {fileID: 158729764}
--- !u!58 &277639225
CircleCollider2D:
m_ObjectHideFlags: 0
@ -25552,6 +25554,7 @@ MonoBehaviour:
OtherPanel: {fileID: 5331092055018478733, guid: 2b46aee216d4b304f8aebcb303ebf4f4, type: 3}
SecondPanel: {fileID: 1662373578}
PanelAbove: {fileID: 1293589669}
obj: {fileID: 1027343184}
--- !u!58 &584661740
CircleCollider2D:
m_ObjectHideFlags: 0
@ -36014,6 +36017,7 @@ MonoBehaviour:
OtherPanel: {fileID: 5331092055018478733, guid: 2b46aee216d4b304f8aebcb303ebf4f4, type: 3}
SecondPanel: {fileID: 1662373578}
PanelAbove: {fileID: 1293589669}
obj: {fileID: 1265465282}
--- !u!58 &805898527
CircleCollider2D:
m_ObjectHideFlags: 0
@ -36458,6 +36462,7 @@ MonoBehaviour:
OtherPanel: {fileID: 626405956}
SecondPanel: {fileID: 503724235}
PanelAbove: {fileID: 1241490289}
obj: {fileID: 641696201}
--- !u!58 &875629809
CircleCollider2D:
m_ObjectHideFlags: 0
@ -36621,6 +36626,7 @@ MonoBehaviour:
OtherPanel: {fileID: 9124304227729624651, guid: e9cbfeb9e69af1245bc3180e86ff23f6, type: 3}
SecondPanel: {fileID: 503724235}
PanelAbove: {fileID: 1241490289}
obj: {fileID: 889215474}
--- !u!58 &887082961
CircleCollider2D:
m_ObjectHideFlags: 0
@ -37687,6 +37693,7 @@ MonoBehaviour:
OtherPanel: {fileID: 626405956}
SecondPanel: {fileID: 503724235}
PanelAbove: {fileID: 1241490289}
obj: {fileID: 8620305}
--- !u!58 &1013260100
CircleCollider2D:
m_ObjectHideFlags: 0
@ -38046,6 +38053,7 @@ MonoBehaviour:
OtherPanel: {fileID: 626405956}
SecondPanel: {fileID: 503724235}
PanelAbove: {fileID: 1241490289}
obj: {fileID: 68076400}
--- !u!58 &1102795099
CircleCollider2D:
m_ObjectHideFlags: 0
@ -38503,6 +38511,7 @@ MonoBehaviour:
OtherPanel: {fileID: 626405956}
SecondPanel: {fileID: 503724235}
PanelAbove: {fileID: 1241490289}
obj: {fileID: 242009510}
--- !u!58 &1202265634
CircleCollider2D:
m_ObjectHideFlags: 0
@ -131310,6 +131319,7 @@ MonoBehaviour:
OtherPanel: {fileID: 5331092055018478733, guid: 2b46aee216d4b304f8aebcb303ebf4f4, type: 3}
SecondPanel: {fileID: 1662373578}
PanelAbove: {fileID: 1293589669}
obj: {fileID: 926459323}
--- !u!58 &1698721849
CircleCollider2D:
m_ObjectHideFlags: 0
@ -131631,6 +131641,7 @@ MonoBehaviour:
OtherPanel: {fileID: 9124304227729624651, guid: e9cbfeb9e69af1245bc3180e86ff23f6, type: 3}
SecondPanel: {fileID: 1662373578}
PanelAbove: {fileID: 1293589669}
obj: {fileID: 622865435}
--- !u!58 &1754993748
CircleCollider2D:
m_ObjectHideFlags: 0
@ -132898,6 +132909,7 @@ MonoBehaviour:
OtherPanel: {fileID: 626405956}
SecondPanel: {fileID: 503724235}
PanelAbove: {fileID: 1241490289}
obj: {fileID: 682072029}
--- !u!58 &2132075801
CircleCollider2D:
m_ObjectHideFlags: 0

View File

@ -24,7 +24,7 @@ public class PickableController : MonoBehaviour
InventoryManager.Instance.AddToInventory(this.item);
string pickaxe = "picked";
PlayerPrefs.SetString("pickaxe1", pickaxe);
Destroy(gameObject);
gameObject.SetActive(false);
}
}
}

View File

@ -7,6 +7,6 @@ public class QuitGame : MonoBehaviour
public void Exit()
{
Application.Quit();
UnityEditor.EditorApplication.isPlaying = false;
//UnityEditor.EditorApplication.isPlaying = false;
}
}

View File

@ -25,7 +25,7 @@ public class breakable : MonoBehaviour
int rock = PlayerPrefs.GetInt("rock");
if(rock == 0)
{
Destroy(gameObject);
gameObject.SetActive(false);
}
}
@ -33,7 +33,7 @@ public class breakable : MonoBehaviour
{
if (timeToBreak == true){
PlayerPrefs.SetInt("rock", 0);
Destroy(gameObject);
gameObject.SetActive(false);
}
yield return new WaitForSeconds(1);
var em = collisionParticleSystem.emission;

View File

@ -24,16 +24,16 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c72111f19352f223d667d6d0a1532f0e1372ce7f518e8ea3f7129370bfb25
flags: 0
RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
flags: 0
RecentlyUsedScenePath-7:
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c7c1100123d24383a273e2e2c5326ece92021
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c72111f1958072926337e38271427fb
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650