66 lines
1.3 KiB
C#
66 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)
|
|
{
|
|
if (Mouse.current.leftButton.isPressed)
|
|
{
|
|
player.NormalAttack();
|
|
}
|
|
else if (Mouse.current.rightButton.isPressed)
|
|
{
|
|
player.DashAttack();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnJump(InputValue value)
|
|
{
|
|
if(value.isPressed)
|
|
{
|
|
player.Jump();
|
|
}
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if (player.IsDashing())
|
|
{
|
|
player.AttackOnDash(collision);
|
|
}
|
|
}
|
|
} |