maint: added livewatch asset

This commit is contained in:
Chris
2025-08-31 18:14:07 -04:00
parent 7f5d95787b
commit ae2371a6fa
385 changed files with 150792 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using System;
using UnityEngine;
namespace Ingvar.LiveWatch.TowerDefenceDemo
{
public class MobHealthBar : MonoBehaviour
{
[SerializeField] private MobMain mob;
[SerializeField] private Transform bar;
private Camera _mainCamera;
private void Awake()
{
_mainCamera = Camera.main;
}
private void OnEnable()
{
mob.Health.HealthChanged += RefreshBar;
RefreshBar();
}
private void OnDisable()
{
mob.Health.HealthChanged -= RefreshBar;
}
private void LateUpdate()
{
transform.rotation = _mainCamera.transform.rotation;
}
private void RefreshBar()
{
var progress = (float)mob.Health.CurrentHealth / mob.Health.MaxHealth;
bar.localScale = new Vector3(progress, bar.localScale.y, bar.localScale.z);
}
}
}