Demo Build Release Candidate 1

This commit is contained in:
RochesterX
2025-02-09 17:18:51 -05:00
parent 657515cc0d
commit 8a9746eeb5
364 changed files with 10036 additions and 174 deletions

View File

@@ -8,6 +8,8 @@ public class AnimationPlayer : MonoBehaviour
public bool backwards;
public bool block = false;
public AnimationClip clip;
private Animator animator;
@@ -22,6 +24,8 @@ public class AnimationPlayer : MonoBehaviour
{
animator.SetInteger("state", (int)state);
transform.localScale = new Vector3(Mathf.Sign(backwards ? -1 : 1) * Mathf.Abs(transform.localScale.x), transform.localScale.y, transform.localScale.z);
animator.SetBool("block", block);
}
public void SetState(AnimationState state)

View File

@@ -2,67 +2,29 @@ using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(PlayerInput))]
[RequireComponent(typeof(Animation))]
public class Block : MonoBehaviour
{
//public bool cancelable = true;
[SerializeField] private BoxCollider2D blockArea;
private InputActionAsset actions;
private Animation animationComponent;
public bool blocking = false;
private InputActionAsset actions;
private void Start()
{
actions = GetComponent<PlayerInput>().actions;
animationComponent = GetComponent<Animation>();
}
private void Update()
{
var blockAction = actions.FindAction("Block");
InputAction blockAction = actions.FindAction("Block");
if (blockAction.ReadValue<float>() == 1f)
{
Debug.Log("Block action triggered!");
//if (!cancelable) return;
//animationComponent.Play("Block");
GetComponent<AnimationPlayer>().Block();
DisableCancellation();
ActivateBlockArea();
blocking = true;
}
else
{
DeactivateBlockArea();
blocking = false;
}
}
public void ActivateBlockArea()
{
blockArea.enabled = true;
}
public void DeactivateBlockArea()
{
blockArea.enabled = false;
}
public void DisableCancellation()
{
//cancelable = false;
}
public void EnableCancellation()
{
//cancelable = true;
}
public bool IsBlocking()
{
return blockArea.enabled;
GetComponent<AnimationPlayer>().block = blocking;
}
}

View File

@@ -14,7 +14,7 @@ public class Damageable : MonoBehaviour
if (collision.gameObject.CompareTag("Punch Hurtbox"))
{
print($"{name}: Ouch");
Damage();
Damage(collision.transform.parent.gameObject);
Recoil(collision.transform.parent.gameObject);
}
}
@@ -25,9 +25,18 @@ public class Damageable : MonoBehaviour
//damageSource.transform.localScale *= 1.1f;
}
private void Damage()
private void Damage(GameObject damageSource)
{
damage += force;
float actualForce = force;
// Recoil
GetComponent<Rigidbody2D>().AddForce(((transform.position - damageSource.transform.position).normalized + Vector3.up * 2) * damage, ForceMode2D.Force);
if (GetComponent<Block>().blocking)
{
damageSource.GetComponent<Damageable>().Damage(gameObject);
actualForce /= 4;
}
damage += actualForce;
damage = Mathf.Clamp(damage, 0f, maxDamage);
}

View File

@@ -145,11 +145,14 @@ public class PlayerMovement : MonoBehaviour
{
if (jumpPhysics)
{
if (body.linearVelocity.y < 0 || !IsPhysicallyGrounded()) body.linearVelocity = new Vector2(body.linearVelocity.x, 0);
body.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse);
if (Mathf.Abs(body.linearVelocityX) > maxSpeed)
if (!GetComponent<Block>().blocking)
{
body.linearVelocity = new Vector2(Mathf.Sign(body.linearVelocityX) * maxSpeed, body.linearVelocity.y);
if (body.linearVelocity.y < 0 || !IsPhysicallyGrounded()) body.linearVelocity = new Vector2(body.linearVelocity.x, 0);
body.AddForce(Vector2.up * jumpSpeed, ForceMode2D.Impulse);
if (Mathf.Abs(body.linearVelocityX) > maxSpeed)
{
body.linearVelocity = new Vector2(Mathf.Sign(body.linearVelocityX) * maxSpeed, body.linearVelocity.y);
}
}
jumpPhysics = false;
}
@@ -170,7 +173,7 @@ public class PlayerMovement : MonoBehaviour
float temporaryMax = IsPhysicallyGrounded() ? maxSpeedOverride : Mathf.Infinity;
float temporarySlowdown = IsPhysicallyGrounded() ? slowdownMultiplier : 1;
if (Mathf.Abs(body.linearVelocityX) <= maxSpeed || Mathf.Sign(body.linearVelocityX) != Mathf.Sign(virtualAxisX))
if (!GetComponent<Block>().blocking && (Mathf.Abs(body.linearVelocityX) <= maxSpeed || Mathf.Sign(body.linearVelocityX) != Mathf.Sign(virtualAxisX)))
{
body.AddForce(new Vector2(virtualAxisX * walkSpeed * walkSpeedFactor, 0), ForceMode2D.Force);
}
@@ -186,6 +189,11 @@ public class PlayerMovement : MonoBehaviour
virtualAxisX = 0;
}
if (GetComponent<Block>().blocking)
{
body.AddForce(new Vector2(-body.linearVelocityX * 0.8f, 0), ForceMode2D.Force);
}
positionLastFrame = transform.position;
}

View File

@@ -28,7 +28,6 @@ public class Punch : MonoBehaviour
private void ExecutePunch()
{
print("Execution");
GetComponent<AnimationPlayer>().Punch();
DisableCancellation();
GetComponent<PlayerMovement>().maxSpeedOverride = 1f;

View File

@@ -0,0 +1,21 @@
using UnityEngine;
[RequireComponent(typeof(Rigidbody2D))]
public class TerminalVelocity : MonoBehaviour
{
[SerializeField] private float terminalVelocity = -10f;
private Rigidbody2D rb;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void FixedUpdate()
{
if (rb.linearVelocity.y < terminalVelocity)
{
rb.linearVelocity = new Vector2(rb.linearVelocity.x, terminalVelocity);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 36267595aa66046ac9e2e140190bbc16