84 lines
2.3 KiB
C#
84 lines
2.3 KiB
C#
using UnityEngine;
|
|
|
|
public class CanvasManager : MonoBehaviour
|
|
{
|
|
public GameObject canvasInteractionInfoPrefab;
|
|
|
|
public GameObject canvasThrowingBarPrefab;
|
|
|
|
[HideInInspector]
|
|
public GameObject currentCanvasInteractionInfo;
|
|
|
|
[HideInInspector]
|
|
public GameObject currentCanvasThrowinigBar;
|
|
|
|
private Canvas m_Canvas;
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
}
|
|
|
|
public void ShowHideCanvasInfoInteractionPanel(Transform _object, bool visable)
|
|
{
|
|
if (!visable && currentCanvasInteractionInfo != null)
|
|
{
|
|
Object.Destroy(currentCanvasInteractionInfo);
|
|
}
|
|
else
|
|
{
|
|
if (_object == null || !(currentCanvasInteractionInfo == null))
|
|
{
|
|
return;
|
|
}
|
|
string text = _object.tag;
|
|
if (!(text == "Rod"))
|
|
{
|
|
if (text == "Stojak" && !(ScriptsHandler.Instance.m_PlayerMain.currentRightHandObject == null))
|
|
{
|
|
currentCanvasInteractionInfo = Object.Instantiate(canvasInteractionInfoPrefab, ScriptsHandler.Instance.m_Canvas.transform);
|
|
currentCanvasInteractionInfo.GetComponent<InteractionCanvasInfoPanel>().SetInfoPanel(InteractionCanvasInfoPanel.Type.DropRodOnStojak, _object);
|
|
}
|
|
}
|
|
else if (!(ScriptsHandler.Instance.m_PlayerMain.currentRightHandObject != null))
|
|
{
|
|
currentCanvasInteractionInfo = Object.Instantiate(canvasInteractionInfoPrefab, ScriptsHandler.Instance.m_Canvas.transform);
|
|
currentCanvasInteractionInfo.GetComponent<InteractionCanvasInfoPanel>().SetInfoPanel(InteractionCanvasInfoPanel.Type.PickUpRod, _object);
|
|
}
|
|
}
|
|
}
|
|
|
|
public float ShowHideThrowingBar(bool visable, float targetValue)
|
|
{
|
|
if (!visable)
|
|
{
|
|
if (currentCanvasThrowinigBar == null)
|
|
{
|
|
return 0f;
|
|
}
|
|
float barValue = currentCanvasThrowinigBar.GetComponent<CanvasThrowingBar>().barValue;
|
|
Object.Destroy(currentCanvasThrowinigBar);
|
|
return barValue;
|
|
}
|
|
if (currentCanvasThrowinigBar == null)
|
|
{
|
|
currentCanvasThrowinigBar = Object.Instantiate(canvasThrowingBarPrefab, ScriptsHandler.Instance.m_Canvas.transform);
|
|
return 0f;
|
|
}
|
|
currentCanvasThrowinigBar.GetComponent<CanvasThrowingBar>().SetTargetBar(targetValue, 1f);
|
|
return currentCanvasThrowinigBar.GetComponent<CanvasThrowingBar>().barValue;
|
|
}
|
|
|
|
public float StopThrowingBar()
|
|
{
|
|
if (currentCanvasThrowinigBar == null)
|
|
{
|
|
return 0f;
|
|
}
|
|
return currentCanvasThrowinigBar.GetComponent<CanvasThrowingBar>().Stop();
|
|
}
|
|
}
|