TigerProject/Assets/Scripts/Player/PlayerController.cs

66 lines
1.3 KiB
C#
Raw Normal View History

2026-01-20 10:06:03 +00:00
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
2026-01-20 10:06:03 +00:00
using UnityEngine;
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
private Player player;
private Vector2 inputVector;
private float jumpStartTime;
2026-01-20 10:06:03 +00:00
private void Start()
{
player = GetComponent<Player>();
2026-01-20 10:06:03 +00:00
}
private void FixedUpdate()
{
2026-01-23 10:22:52 +00:00
player.MoveUpdate();
2026-01-20 10:06:03 +00:00
Debug.DrawRay(transform.position, Vector2.down * 1.25f, Color.red);
2026-01-23 10:22:52 +00:00
player.CheckGround();
2026-01-20 10:06:03 +00:00
}
private void OnMove(InputValue value)
{
2026-01-23 10:22:52 +00:00
player.SetXVector(value);
2026-01-20 10:06:03 +00:00
}
private void OnAttack(InputValue value)
{
2026-01-26 09:08:38 +00:00
if (player.IsDashing())
{
return;
}
if (value.isPressed)
{
if (Mouse.current.leftButton.isPressed)
{
2026-01-23 10:22:52 +00:00
player.NormalAttack();
}
else if (Mouse.current.rightButton.isPressed)
{
2026-01-23 10:22:52 +00:00
player.DashAttack();
}
}
}
2026-01-20 10:06:03 +00:00
private void OnJump(InputValue value)
{
2026-01-26 09:08:38 +00:00
if(value.isPressed)
{
player.Jump();
}
}
2026-01-23 10:22:52 +00:00
private void OnTriggerEnter2D(Collider2D collision)
{
2026-01-23 10:22:52 +00:00
if (player.IsDashing())
{
2026-01-23 10:22:52 +00:00
player.AttackOnDash(collision);
}
}
2026-01-20 10:06:03 +00:00
}