This commit is contained in:
RochesterX
2025-04-18 20:11:19 -04:00
parent a7e181a900
commit ce741c87d5
450 changed files with 59358 additions and 963 deletions

View File

@@ -78,6 +78,7 @@ namespace Game
// Wait for the fall delay before making the platform fall
yield return new WaitForSeconds(fallDelay);
rb.bodyType = RigidbodyType2D.Dynamic;
rb.angularVelocity = Random.Range(-30, 30);
// Wait for the reset delay before resetting the platform
yield return new WaitForSeconds(resetDelay);

View File

@@ -6,6 +6,7 @@ using Music;
using Player;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
namespace Game
{
@@ -324,12 +325,13 @@ namespace Game
if (gameMode == GameMode.freeForAll)
{
// In free-for-all mode, the last alive player is the winner
GameObject winner = AlivePlayers()[0];
GameObject winner = FindFirstObjectByType<PlayerMovement>().gameObject;//AlivePlayers()[0];
print(winner.name + " is the winner");
// Show the winner's scene and update the win screen
FindFirstObjectByType<PlayerCameraMovement>().WinScene(winner);
WinScreen.Instance.ShowWinScreen(players.IndexOf(winner) + 1);
print($"Player {int.Parse(winner.name)} won");
WinScreen.Instance.ShowWinScreen(int.Parse(winner.name));
// Hide the life display UI
FindFirstObjectByType<LifeDisplayManager>().HideLifeDisplay();

View File

@@ -117,6 +117,7 @@ namespace Game
/// <returns>An IEnumerator for coroutine execution.</returns>
private IEnumerator RespawnHat()
{
lastInteractionTime = Time.time;
// Play the respawn animation
GetComponentInChildren<Animator>().SetTrigger("respawn");
@@ -128,7 +129,6 @@ namespace Game
GetComponent<Rigidbody2D>().linearVelocity = Vector2.zero;
GetComponent<Rigidbody2D>().angularVelocity = 0f;
transform.rotation = Quaternion.identity;
lastInteractionTime = Time.time;
isDropped = false;
}
}

View File

@@ -111,6 +111,10 @@ namespace Player
public void Punch()
{
animator.SetTrigger("punch");
if (!GetComponent<PlayerMovement>().IsPhysicallyGrounded())
{
AudioManager.Instance.PlaySound("Air Punch");
}
}
}
}

View File

@@ -100,6 +100,7 @@ namespace Player
GameManager.players = new List<GameObject>();
}
playerInput.gameObject.name = card.playerNumber.ToString();
// Add the player to the GameManager's player list and assign a color
GameManager.players.Add(playerInput.gameObject);
Colorize(GameManager.players.Count - 1);

View File

@@ -83,7 +83,20 @@ namespace Player
private void OnCollisionEnter2D(Collision2D collision)
{
// Check if the collided object is a "hat" and the player is not already holding an item
if (collision.gameObject.CompareTag("Hat") && !isHoldingItem && !damageable.dying)
if (collision.gameObject.CompareTag(itemTag) && !isHoldingItem && !damageable.dying)
{
PickUpItem(collision.gameObject);
}
}
/// <summary>
/// Automatically picks up an item when the player enters its triggwer.
/// </summary>
/// <param name="collision">The collision data from the item.</param>
private void OnTriggerEnter2D(Collider2D collision)
{
// Check if the collided object is a "hat" and the player is not already holding an item
if (collision.gameObject.CompareTag(itemTag) && !isHoldingItem && !damageable.dying)
{
PickUpItem(collision.gameObject);
}
@@ -103,7 +116,8 @@ namespace Player
heldItem = item;
isHoldingItem = true;
holdStartTime = Time.time;
item.GetComponent<Collider2D>().enabled = false;
heldItem.GetComponent<Collider2D>().enabled = false;
heldItem.transform.Find("HatPhysical").GetComponent<Collider2D>().enabled = false;
item.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Static;
item.GetComponent<HatRespawn>().Interact();
item.transform.parent = head;
@@ -133,13 +147,14 @@ namespace Player
{
// Enable the item's collider and make it interactable after a short delay
heldItem.GetComponent<Collider2D>().enabled = true;
heldItem.transform.Find("HatPhysical").GetComponent<Collider2D>().enabled = true;
HatRespawn.canBePickedUp = false;
StartCoroutine(WaitForInteractability());
// Make the item dynamic and apply random force and torque to it
heldItem.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
heldItem.GetComponent<Rigidbody2D>().AddForce(Vector2.up * Random.Range(10f, 30f) + Vector2.right * Random.Range(-10, 10), ForceMode2D.Impulse);
heldItem.GetComponent<Rigidbody2D>().AddTorque(Random.Range(-1, 1), ForceMode2D.Impulse);
heldItem.GetComponent<Rigidbody2D>().AddTorque(Random.Range(-5, 5), ForceMode2D.Impulse);
// Notify the item that it has been dropped
heldItem.GetComponent<HatRespawn>().OnHatDropped();