50 lines
1.1 KiB
C#
50 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
|
|
public class Player : MonoBehaviour
|
|
{
|
|
private int currentHealth;
|
|
private int maxHealth;
|
|
|
|
private int maxJumpCount = 2;
|
|
private int currentJumpCount = 2;
|
|
|
|
[SerializeField] private float moveSpeed = 9f;
|
|
[SerializeField] private float jumpSpeed = 18.2f;
|
|
[SerializeField] private float jumpCutMultiplier = 0.3f;
|
|
|
|
private Rigidbody2D _rigidbody;
|
|
|
|
|
|
private void Start()
|
|
{
|
|
_rigidbody = gameObject.GetComponent<Rigidbody2D>();
|
|
}
|
|
|
|
public void Jump()
|
|
{
|
|
if (currentJumpCount > 0)
|
|
{
|
|
currentJumpCount--;
|
|
_rigidbody.linearVelocity = new Vector2(_rigidbody.linearVelocity.x, 0);
|
|
_rigidbody.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse);
|
|
}
|
|
|
|
}
|
|
|
|
public void Heal(int heal)
|
|
{
|
|
if (heal < 0) { return; }
|
|
|
|
currentHealth += heal;
|
|
if (currentHealth > maxHealth)
|
|
{
|
|
currentHealth = maxHealth;
|
|
}
|
|
}
|
|
|
|
|
|
} |