씬 정리
This commit is contained in:
18
Assets/Scripts/Unicorn/Player/Player.cs
Normal file
18
Assets/Scripts/Unicorn/Player/Player.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Unicorn.Game.Hitbox;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unicorn.Game.Player
|
||||
{
|
||||
public class Player: LivingEntity
|
||||
{
|
||||
protected override void OnDamaged(DamageInfo info)
|
||||
{
|
||||
Debug.Log(health);
|
||||
}
|
||||
|
||||
protected override void OnDeath()
|
||||
{
|
||||
Debug.Log("주것서영.");
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Unicorn/Player/Player.cs.meta
Normal file
3
Assets/Scripts/Unicorn/Player/Player.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28098bcb033145e7aed508aa64877be6
|
||||
timeCreated: 1777820261
|
||||
35
Assets/Scripts/Unicorn/Player/PlayerAttack.cs
Normal file
35
Assets/Scripts/Unicorn/Player/PlayerAttack.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using Unicorn.System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Unicorn.Game.Player
|
||||
{
|
||||
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/Unicorn/Player/PlayerAttack.cs.meta
Normal file
3
Assets/Scripts/Unicorn/Player/PlayerAttack.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54eed17cf1e34c79b343bc0642ca8797
|
||||
timeCreated: 1777820778
|
||||
42
Assets/Scripts/Unicorn/Player/PlayerMovement.cs
Normal file
42
Assets/Scripts/Unicorn/Player/PlayerMovement.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using Unicorn.System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Unicorn.Game.Player
|
||||
{
|
||||
public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
public float moveSpeed;
|
||||
public float jumpForce;
|
||||
|
||||
private Rigidbody2D _rb;
|
||||
private UnicornInputSystem _unicorn;
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_unicorn.Player.Jump.performed -= Jump;
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
_rb = GetComponent<Rigidbody2D>();
|
||||
_unicorn = UnicornInput.Unicorn;
|
||||
_unicorn.Player.Jump.performed += Jump;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Jump(InputAction.CallbackContext obj)
|
||||
{
|
||||
_rb.linearVelocityY = jumpForce;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
var readValue = _unicorn.Player.Horizontal.ReadValue<float>();
|
||||
_rb.linearVelocityX = readValue * moveSpeed;
|
||||
if (_unicorn.Player.Down.IsPressed() && _rb.linearVelocityY < jumpForce/1.5)
|
||||
_rb.linearVelocityY = Math.Min(0, _rb.linearVelocityY);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Unicorn/Player/PlayerMovement.cs.meta
Normal file
2
Assets/Scripts/Unicorn/Player/PlayerMovement.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db8b3864bdcf65d40b42ee58c17e87aa
|
||||
Reference in New Issue
Block a user