# Conflicts: # Assets/Scripts/EntityData/TestEntity.asset # Assets/Scripts/Monster/GroundEnemyMovement.cs # Assets/Scripts/Player/Player.cs # Assets/Scripts/Player/PlayerController.cs
67 lines
1.3 KiB
C#
67 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class PlayerController : MonoBehaviour
|
|
{
|
|
private Player player;
|
|
|
|
private Vector2 inputVector;
|
|
private float jumpStartTime;
|
|
|
|
private void Start()
|
|
{
|
|
player = GetComponent<Player>();
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
player.MoveUpdate();
|
|
Debug.DrawRay(transform.position, Vector2.down * 1.25f, Color.red);
|
|
player.CheckGround();
|
|
}
|
|
|
|
private void OnMove(InputValue value)
|
|
{
|
|
player.SetXVector(value);
|
|
}
|
|
|
|
private void OnAttack(InputValue value)
|
|
{
|
|
if (player.IsDashing())
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (value.isPressed)
|
|
{
|
|
player.NormalAttack();
|
|
}
|
|
}
|
|
|
|
private void OnDash(InputValue value)
|
|
{
|
|
if (value.isPressed)
|
|
{
|
|
player.DashAttack();
|
|
}
|
|
}
|
|
|
|
private void OnJump(InputValue value)
|
|
{
|
|
if(value.isPressed)
|
|
{
|
|
player.Jump();
|
|
}
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if (player.IsDashing())
|
|
{
|
|
player.AttackOnDash(collision);
|
|
}
|
|
}
|
|
} |