2022-06-14 15:54:28 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2022-06-17 22:22:19 +02:00
|
|
|
using System.Linq;
|
2022-06-14 15:54:28 +02:00
|
|
|
|
|
|
|
public class closePossibleButtonInfo : MonoBehaviour
|
|
|
|
{
|
2022-06-17 22:22:19 +02:00
|
|
|
[SerializeField]
|
|
|
|
public List<GameObject> Panels; // for Quest panel && Dialogue Panel and in future for all others which could require to close info-panels
|
|
|
|
|
|
|
|
|
|
|
|
public List<string> actionPanels = new List<string>{"E-InteractivePanel", "E-InteractivePanelAbove", "Spacebar-InteractivePanel", "Spacebar-InteractivePanelAbove"};
|
2022-06-14 15:54:28 +02:00
|
|
|
|
|
|
|
void Update()
|
|
|
|
{
|
2022-06-17 22:22:19 +02:00
|
|
|
int index = Panels.FindIndex(panel => panel.active == true);
|
|
|
|
|
|
|
|
if (index >= 0)
|
2022-06-14 15:54:28 +02:00
|
|
|
{
|
2022-06-17 22:22:19 +02:00
|
|
|
|
|
|
|
// BRUTAL AND NAIVE SOLUTION
|
|
|
|
// TODO rewrite during refactoring dialogue panels module !!! - 18.06.2022
|
|
|
|
|
|
|
|
// EPanel.SetActive(false);
|
|
|
|
// EPanel1.SetActive(false);
|
|
|
|
// SpacePanel.SetActive(false);
|
|
|
|
// SpacePanel1.SetActive(false);
|
|
|
|
|
|
|
|
// the same solution prescribed for the needs of dynamic toolpits - also rewrite later -
|
|
|
|
// TODO - cahne whole logic
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1. Fetch "space hit" and all other panels and destroy them if exists as GUI object children
|
|
|
|
// Because its in "Update" object are destroyed all time - again and again and again - when cndition is met
|
|
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// add action which will block open action-into-panels again if one of "Panels" is currently opened and allow this after close
|
|
|
|
// add condition for each object whisch have "OpenPanelOnCollision" script
|
|
|
|
// GetComponent<OpenPanelOnCollision>().isAllowedToShowPanels = false;
|
|
|
|
|
|
|
|
GameObject globalGUI = GameObject.FindGameObjectsWithTag("GUI")[0];
|
|
|
|
foreach (Transform eachChild in globalGUI.transform) {
|
|
|
|
|
|
|
|
int match = actionPanels.FindIndex(actionPanelName => (actionPanelName == eachChild.name || actionPanelName + "(Clone)" == eachChild.name));
|
|
|
|
|
|
|
|
if(match >= 0)
|
|
|
|
{
|
|
|
|
//Debug.Log("Destroy " + eachChild.name);
|
|
|
|
Destroy(eachChild.gameObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-06-14 15:54:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|