босс
This commit is contained in:
1 parent
76b6566e46
commit
11d290d572
49 files changed
+2562
-587
No files matched your search
@@ -0,0 +1,68 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Полноэкранный визуальный эффект акустического ослепления (подавления чувств).
|
||||
/// Активируется во время крика Босса: полностью затемняет экран и гасит эхолокацию.
|
||||
/// </summary>
|
||||
public class AcousticJammerOverlay : MonoBehaviour
|
||||
{
|
||||
private Image overlayImage;
|
||||
private CanvasGroup canvasGroup;
|
||||
|
||||
private float currentAlpha = 0f;
|
||||
|
||||
public static AcousticJammerOverlay Create(Transform hudCanvas)
|
||||
{
|
||||
var old = hudCanvas.Find("AcousticJammerOverlay");
|
||||
if (old != null) DestroyImmediate(old.gameObject);
|
||||
|
||||
GameObject root = new GameObject("AcousticJammerOverlay", typeof(RectTransform), typeof(CanvasGroup));
|
||||
root.transform.SetParent(hudCanvas, false);
|
||||
|
||||
RectTransform rt = root.GetComponent<RectTransform>();
|
||||
rt.anchorMin = Vector2.zero;
|
||||
rt.anchorMax = Vector2.one;
|
||||
rt.sizeDelta = Vector2.zero;
|
||||
|
||||
// Черный экран с легким темно-багровым оттенком
|
||||
GameObject imgObj = new GameObject("VignetteBlackout", typeof(RectTransform), typeof(CanvasRenderer), typeof(Image));
|
||||
imgObj.transform.SetParent(root.transform, false);
|
||||
RectTransform imgRt = imgObj.GetComponent<RectTransform>();
|
||||
imgRt.anchorMin = Vector2.zero;
|
||||
imgRt.anchorMax = Vector2.one;
|
||||
imgRt.sizeDelta = Vector2.zero;
|
||||
|
||||
Image img = imgObj.GetComponent<Image>();
|
||||
img.color = new Color(0.01f, 0.005f, 0.005f, 0.98f);
|
||||
img.raycastTarget = false;
|
||||
|
||||
AcousticJammerOverlay overlay = root.AddComponent<AcousticJammerOverlay>();
|
||||
overlay.overlayImage = img;
|
||||
overlay.canvasGroup = root.GetComponent<CanvasGroup>();
|
||||
overlay.canvasGroup.alpha = 0f;
|
||||
overlay.canvasGroup.blocksRaycasts = false;
|
||||
overlay.canvasGroup.interactable = false;
|
||||
|
||||
return overlay;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (canvasGroup == null) canvasGroup = GetComponent<CanvasGroup>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
bool isBlinded = EchoTrigger.Instance != null && EchoTrigger.Instance.IsBlinded;
|
||||
float targetAlpha = isBlinded ? 1f : 0f;
|
||||
float speed = isBlinded ? 14f : 3.5f; // Мгновенно ослепляет, плавно возвращает зрение
|
||||
|
||||
currentAlpha = Mathf.MoveTowards(currentAlpha, targetAlpha, speed * Time.deltaTime);
|
||||
|
||||
if (canvasGroup != null)
|
||||
{
|
||||
canvasGroup.alpha = currentAlpha;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user