39 lines
1 KiB
C#
39 lines
1 KiB
C#
using System;
|
|
using Core.Extensions;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class Marisa : Entity
|
|
{
|
|
[Header("Mouse")]
|
|
[SerializeField] private Camera cam;
|
|
public Vector2 mouseWorldPos;
|
|
public Transform firingPointBase;
|
|
public Transform firingPoint;
|
|
[Header("UI")]
|
|
[SerializeField] private Transform hpBarUI;
|
|
[SerializeField] private TextMeshProUGUI healthText;
|
|
private void Update()
|
|
{
|
|
mouseWorldPos = cam.ScreenToWorldPoint(Input.mousePosition);
|
|
firingPointBase.Lookat2D(mouseWorldPos);
|
|
}
|
|
|
|
protected override void FixedUpdate()
|
|
{
|
|
moveDirection = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
|
|
base.FixedUpdate();
|
|
}
|
|
|
|
public override void TakeDamage(float damage)
|
|
{
|
|
base.TakeDamage(damage);
|
|
UpdateHealthUI();
|
|
}
|
|
|
|
private void UpdateHealthUI()
|
|
{
|
|
hpBarUI.localScale = new Vector3(Math.Clamp(health/maxHealth,0,maxHealth), 1,1);
|
|
healthText.text = $"{health}/{maxHealth}";
|
|
}
|
|
}
|