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

47 lines
942 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
2021-11-18 11:34:14 +00:00
{
public class RespawnHUDMarker : HUDDistanceMarker
2021-11-18 11:34:14 +00:00
{
private bool _isReady;
2021-11-18 11:34:14 +00:00
public override void InitCanvasMarker()
{
_markerRadius = 0.2f;
_markerTarget = transform;
_markerLabel = "RESPAWN PLAYER";
_isReady = true;
base.InitCanvasMarker();
2021-11-18 11:34:14 +00:00
}
private void Update()
2021-11-18 11:34:14 +00:00
{
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();
if (RespawnManager.Instance.RespawnNeeded != isVisible)
{
_isVisible = RespawnManager.Instance.RespawnNeeded;
_canvasMarker.SetVisibility(_isVisible);
}
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
}
}
}