Functioning player movement,

Persistent block needs to be implemented
This commit is contained in:
RochesterX
2025-01-31 12:48:13 -05:00
parent 36815eb876
commit 70518b2b69
7 changed files with 189 additions and 306 deletions

View File

@@ -5,12 +5,14 @@ using UnityEngine.InputSystem;
[RequireComponent(typeof(Animation))]
public class Block : MonoBehaviour
{
public bool cancelable = true;
//public bool cancelable = true;
[SerializeField] private BoxCollider2D blockArea;
private InputActionAsset actions;
private Animation animationComponent;
public bool blocking = false;
private void Start()
{
actions = GetComponent<PlayerInput>().actions;
@@ -21,13 +23,14 @@ public class Block : MonoBehaviour
{
var blockAction = actions.FindAction("Block");
if (blockAction.triggered)
if (blockAction.ReadValue<float>() == 1f)
{
Debug.Log("Block action triggered!");
if (!cancelable) return;
//if (!cancelable) return;
animationComponent.Play("Block");
//animationComponent.Play("Block");
GetComponent<AnimationPlayer>().Block();
DisableCancellation();
ActivateBlockArea();
@@ -50,12 +53,12 @@ public class Block : MonoBehaviour
public void DisableCancellation()
{
cancelable = false;
//cancelable = false;
}
public void EnableCancellation()
{
cancelable = true;
//cancelable = true;
}
public bool IsBlocking()

View File

@@ -12,9 +12,12 @@ public class Damageable : MonoBehaviour
{
if (collision.gameObject.CompareTag("Punch Hurtbox"))
{
print($"{name}: Ouch");
Damage();
Recoil(collision.transform.parent.gameObject);
if (GetComponent<Block>().blocking)
{
collision.gameObject.GetComponent<Damageable>().Damage(gameObject);
return;
}
Damage(collision.transform.parent.gameObject);
}
}
@@ -24,9 +27,10 @@ public class Damageable : MonoBehaviour
//damageSource.transform.localScale *= 1.1f;
}
private void Damage()
public void Damage(GameObject source)
{
damage += force;
Recoil(source);
}
public void ResetDamage()

View File

@@ -119,7 +119,7 @@ public class PlayerMovement : MonoBehaviour
private void Jump()
{
if (!punch.cancelable) return;
//if (!punch.cancelable) return;
if (virtualButtonJumpLastFrame == 1f)
{
@@ -160,7 +160,7 @@ public class PlayerMovement : MonoBehaviour
private void HorizontalMovement()
{
if (!punch.cancelable) return;
//if (!punch.cancelable) return;
body.AddForce(new Vector2(virtualAxisX * walkSpeed * walkSpeedFactor, 0), ForceMode2D.Force);

View File

@@ -21,7 +21,7 @@ public class Punch : MonoBehaviour
{
if (actions.FindAction("Punch").ReadValue<float>() == 1f)
{
if (!cancelable) return;
//if (!cancelable) return;
GetComponent<AnimationPlayer>().Punch();
DisableCancellation();
}