quantum-space-buddies/QSB/RespawnSync/RespawnHUDMarker.cs

46 lines
904 B
C#
Raw Normal View History

2021-11-25 15:32:34 +00:00
using UnityEngine;
2021-11-18 11:34:14 +00:00
namespace QSB.RespawnSync;
public class RespawnHUDMarker : HUDDistanceMarker
2021-11-18 11:34:14 +00:00
{
private bool _isReady;
public override void InitCanvasMarker()
2021-11-18 11:34:14 +00:00
{
_markerRadius = 0.2f;
_markerTarget = transform;
_markerLabel = "RESPAWN PLAYER";
_isReady = true;
2021-11-18 11:34:14 +00:00
base.InitCanvasMarker();
}
2021-11-18 11:34:14 +00:00
private void Update()
{
if (!_isReady)
{
return;
2021-11-18 11:34:14 +00:00
}
if (_canvasMarker != null)
2021-11-18 11:34:14 +00:00
{
var isVisible = _canvasMarker.IsVisible();
2021-11-18 11:34:14 +00:00
if (RespawnManager.Instance.RespawnNeeded != isVisible)
2021-11-18 11:34:14 +00:00
{
_isVisible = RespawnManager.Instance.RespawnNeeded;
_canvasMarker.SetVisibility(_isVisible);
2021-11-18 11:34:14 +00:00
}
}
2021-11-18 11:34:14 +00:00
if (_isVisible && _canvasMarker != null)
{
var color = (Mathf.Sin(Time.unscaledTime * 10f) > 0f)
? Color.white
: new Color(1f, 1f, 1f, 0.1f);
_canvasMarker._mainTextField.color = color;
_canvasMarker._offScreenIndicator._textField.color = color;
2021-11-18 11:34:14 +00:00
}
}
}