탑뷰 슈팅 게임 미니 프로젝트

This commit is contained in:
2026-01-24 01:14:28 +09:00
parent 6753e7f013
commit 22b17ebff9
442 changed files with 165828 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
using UnityEngine;
public class Character : MonoBehaviour
{
// [Range(0 , 3)]
public float MaxHP = 3;
public GameObject HPGauge;
float HP;
private float HPMaxWidth;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
HP = MaxHP;
if (HPGauge != null)
{
HPMaxWidth = HPGauge.GetComponent<RectTransform>().sizeDelta.x;
}
}
public void Initalize()
{
HP = MaxHP;
}
/*
* 살아있으면 true를 리턴한다.
*/
public bool Hit(float damage)
{
HP -= damage;
if (HP < 0)
{
HP = 0;
}
if(HPGauge != null)
{
HPGauge.GetComponent<RectTransform>().sizeDelta = new Vector2(HP/MaxHP * HPMaxWidth, HPGauge.GetComponent<RectTransform>().sizeDelta.y);
}
return HP > 0;
}
// Update is called once per frame
void Update()
{
}
}