2026-01-20 10:06:03 +00:00
|
|
|
using System.Collections;
|
2026-01-22 12:57:04 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Unity.VisualScripting;
|
2026-01-20 10:06:03 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
|
|
|
|
public class PlayerController : MonoBehaviour
|
|
|
|
|
{
|
2026-01-23 08:06:57 +00:00
|
|
|
private Player player;
|
2026-01-22 12:57:04 +00:00
|
|
|
|
2026-01-20 10:06:03 +00:00
|
|
|
private void Start()
|
|
|
|
|
{
|
2026-01-23 08:06:57 +00:00
|
|
|
player = GetComponent<Player>();
|
2026-01-20 10:06:03 +00:00
|
|
|
}
|
2026-01-28 07:39:18 +00:00
|
|
|
|
2026-01-20 10:06:03 +00:00
|
|
|
private void FixedUpdate()
|
|
|
|
|
{
|
2026-01-28 07:39:18 +00:00
|
|
|
player.AddGravityForceOnJump();
|
|
|
|
|
player.MoveHorizontal();
|
2026-01-20 10:06:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnMove(InputValue value)
|
|
|
|
|
{
|
2026-01-28 07:39:18 +00:00
|
|
|
player.SetInputVector(value);
|
2026-01-22 12:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-27 10:20:36 +00:00
|
|
|
private void OnDash(InputValue value)
|
|
|
|
|
{
|
|
|
|
|
if (value.isPressed)
|
|
|
|
|
{
|
2026-01-28 07:39:18 +00:00
|
|
|
player.Dash();
|
2026-01-27 10:20:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-20 10:06:03 +00:00
|
|
|
private void OnJump(InputValue value)
|
|
|
|
|
{
|
2026-01-28 07:39:18 +00:00
|
|
|
player._isJumping = value.isPressed;
|
2026-01-26 09:08:38 +00:00
|
|
|
if(value.isPressed)
|
|
|
|
|
{
|
|
|
|
|
player.Jump();
|
|
|
|
|
}
|
2026-01-22 12:57:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-28 07:39:18 +00:00
|
|
|
|
|
|
|
|
private void OnAttack(InputValue value)
|
2026-01-22 12:57:04 +00:00
|
|
|
{
|
2026-01-28 07:39:18 +00:00
|
|
|
if (player.IsDashing)
|
2026-01-22 12:57:04 +00:00
|
|
|
{
|
2026-01-28 07:39:18 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value.isPressed)
|
|
|
|
|
{
|
|
|
|
|
player.Attack();
|
2026-01-22 12:57:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
2026-01-28 07:39:18 +00:00
|
|
|
|
|
|
|
|
// private void OnTriggerEnter2D(Collider2D collision)
|
|
|
|
|
// {
|
|
|
|
|
// if (player.IsDashing())
|
|
|
|
|
// {
|
|
|
|
|
// player.AttackOnDash(collision);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2026-01-20 10:06:03 +00:00
|
|
|
}
|