Attack까지 완성..?
This commit is contained in:
23
Assets/Scripts/LivingEntity.cs
Normal file
23
Assets/Scripts/LivingEntity.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using UnityEngine;
|
||||
|
||||
public partial class LivingEntity : MonoBehaviour
|
||||
{
|
||||
public float health = 20.0f;
|
||||
|
||||
public void Damage(float damage, Collider2D cause)
|
||||
{
|
||||
health -= damage;
|
||||
OnDamaged(damage, cause);
|
||||
if (health <= 0.0f) OnDeath();
|
||||
}
|
||||
|
||||
private void OnDamaged(float damage, Collider2D cause)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
private void OnDeath()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/LivingEntity.cs.meta
Normal file
2
Assets/Scripts/LivingEntity.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe858eccb62e2294f91ad1a4291f2b10
|
||||
4
Assets/Scripts/Player.cs
Normal file
4
Assets/Scripts/Player.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
public class Player: LivingEntity
|
||||
{
|
||||
|
||||
}
|
||||
3
Assets/Scripts/Player.cs.meta
Normal file
3
Assets/Scripts/Player.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28098bcb033145e7aed508aa64877be6
|
||||
timeCreated: 1777820261
|
||||
32
Assets/Scripts/PlayerAttack.cs
Normal file
32
Assets/Scripts/PlayerAttack.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PlayerAttack: MonoBehaviour
|
||||
{
|
||||
public GameObject attackHitbox;
|
||||
private UnicornInputSystem _unicornInput;
|
||||
private void Start()
|
||||
{
|
||||
_unicornInput = UnicornInput.Unicorn;
|
||||
_unicornInput.Player.Attack.performed += Attack;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_unicornInput.Player.Attack.performed -= Attack;
|
||||
}
|
||||
|
||||
private void Attack(InputAction.CallbackContext obj)
|
||||
{
|
||||
StartCoroutine(OnAttack());
|
||||
}
|
||||
|
||||
private IEnumerator OnAttack()
|
||||
{
|
||||
attackHitbox.SetActive(true);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
attackHitbox.SetActive(false);
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/PlayerAttack.cs.meta
Normal file
3
Assets/Scripts/PlayerAttack.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54eed17cf1e34c79b343bc0642ca8797
|
||||
timeCreated: 1777820778
|
||||
Reference in New Issue
Block a user