diff --git a/Assets/Animations/Die.anim b/Assets/Animations/Bones/Die.anim similarity index 100% rename from Assets/Animations/Die.anim rename to Assets/Animations/Bones/Die.anim diff --git a/Assets/Animations/Die.anim.meta b/Assets/Animations/Bones/Die.anim.meta similarity index 100% rename from Assets/Animations/Die.anim.meta rename to Assets/Animations/Bones/Die.anim.meta diff --git a/Assets/Animations/Game.meta b/Assets/Animations/Game.meta new file mode 100644 index 0000000..3c07339 --- /dev/null +++ b/Assets/Animations/Game.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 586436400e0b7d64095ccd5e7a0f6f55 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animations/Falling Platform Default.anim b/Assets/Animations/Game/Falling Platform Default.anim similarity index 100% rename from Assets/Animations/Falling Platform Default.anim rename to Assets/Animations/Game/Falling Platform Default.anim diff --git a/Assets/Animations/Falling Platform Default.anim.meta b/Assets/Animations/Game/Falling Platform Default.anim.meta similarity index 100% rename from Assets/Animations/Falling Platform Default.anim.meta rename to Assets/Animations/Game/Falling Platform Default.anim.meta diff --git a/Assets/Animations/Falling Platform Respawn.anim b/Assets/Animations/Game/Falling Platform Respawn.anim similarity index 100% rename from Assets/Animations/Falling Platform Respawn.anim rename to Assets/Animations/Game/Falling Platform Respawn.anim diff --git a/Assets/Animations/Falling Platform Respawn.anim.meta b/Assets/Animations/Game/Falling Platform Respawn.anim.meta similarity index 100% rename from Assets/Animations/Falling Platform Respawn.anim.meta rename to Assets/Animations/Game/Falling Platform Respawn.anim.meta diff --git a/Assets/Animations/Falling Platform.controller b/Assets/Animations/Game/Falling Platform.controller similarity index 100% rename from Assets/Animations/Falling Platform.controller rename to Assets/Animations/Game/Falling Platform.controller diff --git a/Assets/Animations/Falling Platform.controller.meta b/Assets/Animations/Game/Falling Platform.controller.meta similarity index 100% rename from Assets/Animations/Falling Platform.controller.meta rename to Assets/Animations/Game/Falling Platform.controller.meta diff --git a/Assets/Animations/NotWinning.anim b/Assets/Animations/Game/NotWinning.anim similarity index 100% rename from Assets/Animations/NotWinning.anim rename to Assets/Animations/Game/NotWinning.anim diff --git a/Assets/Animations/NotWinning.anim.meta b/Assets/Animations/Game/NotWinning.anim.meta similarity index 100% rename from Assets/Animations/NotWinning.anim.meta rename to Assets/Animations/Game/NotWinning.anim.meta diff --git a/Assets/Animations/Player Box.controller b/Assets/Animations/Game/Player Box.controller similarity index 100% rename from Assets/Animations/Player Box.controller rename to Assets/Animations/Game/Player Box.controller diff --git a/Assets/Animations/Player Box.controller.meta b/Assets/Animations/Game/Player Box.controller.meta similarity index 100% rename from Assets/Animations/Player Box.controller.meta rename to Assets/Animations/Game/Player Box.controller.meta diff --git a/Assets/Animations/Player Join.anim b/Assets/Animations/Game/Player Join.anim similarity index 100% rename from Assets/Animations/Player Join.anim rename to Assets/Animations/Game/Player Join.anim diff --git a/Assets/Animations/Player Join.anim.meta b/Assets/Animations/Game/Player Join.anim.meta similarity index 100% rename from Assets/Animations/Player Join.anim.meta rename to Assets/Animations/Game/Player Join.anim.meta diff --git a/Assets/Animations/Transition In.anim b/Assets/Animations/Game/Transition In.anim similarity index 100% rename from Assets/Animations/Transition In.anim rename to Assets/Animations/Game/Transition In.anim diff --git a/Assets/Animations/Transition In.anim.meta b/Assets/Animations/Game/Transition In.anim.meta similarity index 100% rename from Assets/Animations/Transition In.anim.meta rename to Assets/Animations/Game/Transition In.anim.meta diff --git a/Assets/Animations/Win.controller b/Assets/Animations/Game/Win.controller similarity index 100% rename from Assets/Animations/Win.controller rename to Assets/Animations/Game/Win.controller diff --git a/Assets/Animations/Win.controller.meta b/Assets/Animations/Game/Win.controller.meta similarity index 100% rename from Assets/Animations/Win.controller.meta rename to Assets/Animations/Game/Win.controller.meta diff --git a/Assets/Animations/WinAnimation.anim b/Assets/Animations/Game/WinAnimation.anim similarity index 100% rename from Assets/Animations/WinAnimation.anim rename to Assets/Animations/Game/WinAnimation.anim diff --git a/Assets/Animations/WinAnimation.anim.meta b/Assets/Animations/Game/WinAnimation.anim.meta similarity index 100% rename from Assets/Animations/WinAnimation.anim.meta rename to Assets/Animations/Game/WinAnimation.anim.meta diff --git a/Assets/Animations/Wipe.controller b/Assets/Animations/Game/Wipe.controller similarity index 100% rename from Assets/Animations/Wipe.controller rename to Assets/Animations/Game/Wipe.controller diff --git a/Assets/Animations/Wipe.controller.meta b/Assets/Animations/Game/Wipe.controller.meta similarity index 100% rename from Assets/Animations/Wipe.controller.meta rename to Assets/Animations/Game/Wipe.controller.meta diff --git a/Assets/Quentin/friday/backgroundddddd-export.png.meta b/Assets/Quentin/friday/backgroundddddd-export.png.meta index 2206bc7..f57c11a 100644 --- a/Assets/Quentin/friday/backgroundddddd-export.png.meta +++ b/Assets/Quentin/friday/backgroundddddd-export.png.meta @@ -147,7 +147,8 @@ TextureImporter: secondaryTextures: [] spriteCustomMetadata: entries: [] - nameFileIdTable: {} + nameFileIdTable: + backgroundddddd-export_0: -6475902312293128869 mipmapLimitGroupName: pSDRemoveMatte: 0 userData: diff --git a/Assets/Scenes/Platformer With Headroom.unity b/Assets/Scenes/Platformer With Headroom.unity index 61de5b8..de4b7cf 100644 --- a/Assets/Scenes/Platformer With Headroom.unity +++ b/Assets/Scenes/Platformer With Headroom.unity @@ -4817,6 +4817,14 @@ PrefabInstance: propertyPath: timer value: objectReference: {fileID: 6442071445436727403} + - target: {fileID: 4907520530801696033, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3} + propertyPath: m_LocalPosition.x + value: 15.35 + objectReference: {fileID: 0} + - target: {fileID: 4907520530801696033, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3} + propertyPath: m_LocalPosition.y + value: -0.77 + objectReference: {fileID: 0} - target: {fileID: 6537344883611667483, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3} propertyPath: m_Camera value: @@ -4865,12 +4873,17 @@ PrefabInstance: propertyPath: m_LocalEulerAnglesHint.z value: 0 objectReference: {fileID: 0} + - target: {fileID: 7889484632530234123, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3} + propertyPath: leaderboardIconPrefab + value: + objectReference: {fileID: 367874778634194597, guid: d9a95e84f7261408c84253a380f8af08, type: 3} - target: {fileID: 8079215911535814924, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3} propertyPath: m_Name value: HealthCanvas objectReference: {fileID: 0} m_RemovedComponents: [] - m_RemovedGameObjects: [] + m_RemovedGameObjects: + - {fileID: 4148327129846918965, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3} m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3} diff --git a/Assets/Scripts/Game.meta b/Assets/Scripts/Game.meta new file mode 100644 index 0000000..4eac72e --- /dev/null +++ b/Assets/Scripts/Game.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cb25285062358bf41aa26cc8ca26b120 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/CreatePlayerJoinCards.cs b/Assets/Scripts/Game/CreatePlayerJoinCards.cs similarity index 75% rename from Assets/Scripts/CreatePlayerJoinCards.cs rename to Assets/Scripts/Game/CreatePlayerJoinCards.cs index 7736633..01c9921 100644 --- a/Assets/Scripts/CreatePlayerJoinCards.cs +++ b/Assets/Scripts/Game/CreatePlayerJoinCards.cs @@ -7,7 +7,7 @@ public class PlayerCardCreator : MonoBehaviour public GameObject playerJoinCardPrefab; - private void Awake() + private void Awake() // Ensures only one instance of PlayerCardCreator exists { if (Instance == null) Instance = this; else @@ -16,7 +16,7 @@ public class PlayerCardCreator : MonoBehaviour } } - public PlayerJoinCard CreateCard() + public PlayerJoinCard CreateCard() // Creates a player join card { GameObject card = Instantiate(playerJoinCardPrefab, transform); return card.GetComponent(); diff --git a/Assets/Scripts/CreatePlayerJoinCards.cs.meta b/Assets/Scripts/Game/CreatePlayerJoinCards.cs.meta similarity index 100% rename from Assets/Scripts/CreatePlayerJoinCards.cs.meta rename to Assets/Scripts/Game/CreatePlayerJoinCards.cs.meta diff --git a/Assets/Scripts/EventSystemizer.cs b/Assets/Scripts/Game/EventSystemizer.cs similarity index 81% rename from Assets/Scripts/EventSystemizer.cs rename to Assets/Scripts/Game/EventSystemizer.cs index ea5e189..a61c605 100644 --- a/Assets/Scripts/EventSystemizer.cs +++ b/Assets/Scripts/Game/EventSystemizer.cs @@ -3,7 +3,7 @@ using UnityEngine.EventSystems; public class EventSystemizer : MonoBehaviour { - private void Update() + private void Update() // Ensures only one instance of EventSystem exists { foreach (EventSystem system in FindObjectsByType(FindObjectsSortMode.None)) { diff --git a/Assets/Scripts/EventSystemizer.cs.meta b/Assets/Scripts/Game/EventSystemizer.cs.meta similarity index 100% rename from Assets/Scripts/EventSystemizer.cs.meta rename to Assets/Scripts/Game/EventSystemizer.cs.meta diff --git a/Assets/Scripts/FallPlatform.cs b/Assets/Scripts/Game/FallPlatform.cs similarity index 75% rename from Assets/Scripts/FallPlatform.cs rename to Assets/Scripts/Game/FallPlatform.cs index 95912e2..dc8eed6 100644 --- a/Assets/Scripts/FallPlatform.cs +++ b/Assets/Scripts/Game/FallPlatform.cs @@ -3,8 +3,8 @@ using UnityEngine; public class FallPlatform : MonoBehaviour { - public float fallDelay = 2f; - public float resetDelay = 4f; + public float fallDelay = 2f; // Delay before the platform falls + public float resetDelay = 4f; // Delay before the platform resets bool falling; Rigidbody2D rb; @@ -15,7 +15,7 @@ public class FallPlatform : MonoBehaviour defposition = transform.parent.position; rb = transform.parent.GetComponent(); } - private void OnTriggerEnter2D(Collider2D collision) + private void OnTriggerEnter2D(Collider2D collision) // Makes platform fall when player or another platform touch it { if (!falling && (collision.gameObject.CompareTag("Player") || collision.transform.GetChild(0).TryGetComponent(out FallPlatform _))) { @@ -23,7 +23,7 @@ public class FallPlatform : MonoBehaviour } } - private IEnumerator FallAfterDelay() + private IEnumerator FallAfterDelay() // Sets platform to fall and respawn { falling = true; yield return new WaitForSeconds(fallDelay); @@ -36,7 +36,7 @@ public class FallPlatform : MonoBehaviour //only resets the object script is attached to, need to fix so platform will reset with fall trigger object // Use transform.parent to get the object it's attatched to - private void Respawn() + private void Respawn() // Resets the platform position { falling = false; rb.bodyType = RigidbodyType2D.Static; diff --git a/Assets/Scripts/FallPlatform.cs.meta b/Assets/Scripts/Game/FallPlatform.cs.meta similarity index 100% rename from Assets/Scripts/FallPlatform.cs.meta rename to Assets/Scripts/Game/FallPlatform.cs.meta diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/Game/GameManager.cs similarity index 76% rename from Assets/Scripts/GameManager.cs rename to Assets/Scripts/Game/GameManager.cs index 7a4a667..925309b 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/Game/GameManager.cs @@ -6,7 +6,6 @@ using UnityEngine.InputSystem; public class GameManager : MonoBehaviour { public static GameManager Instance { get; private set; } - public int maxLives = 3; public float time = 180f; public delegate void GameEvent(); public event GameEvent StartGameEvent; @@ -14,14 +13,22 @@ public class GameManager : MonoBehaviour public static List players = new List(); public static List playerColors = new List(); public float offset = 1f; - public static bool music = true; - public bool gameOver = false; public GameTimer gameTimer; public static Dictionary playerHoldTimes = new Dictionary(); + public static GameMode gameMode = GameMode.freeForAll; // loads a default gamemode as a safety net + public static string map = "Platformer With Headroom"; // loads a default map as a safety net + public Vector2 spawnPosition; + public Vector2 hatSpawnPosition; + public enum GameMode + { + freeForAll, + keepAway, + obstacleCourse + } - private void Awake() + private void Awake() // Ensures only one instance of GameManager exists { if (Instance == null) { @@ -33,20 +40,20 @@ public class GameManager : MonoBehaviour } } - private void Start() + private void Start() // Starts the game and music { MusicManager.Instance.StartPlaylist(); StartGame(); } - public void StartGame() + public void StartGame() // Sets up the proper gamemode { GameManager.playerHoldTimes.Clear(); if (GameManager.players.Count == 0) return; StartGameEvent?.Invoke(); print("Starting game with mode: " + gameMode + " and map: " + map); - if (gameMode == GameMode.freeForAll) + if (gameMode == GameMode.freeForAll) // Sets up the game for free for all mode { foreach (GameObject player in players) { @@ -54,7 +61,7 @@ public class GameManager : MonoBehaviour player.GetComponent().lives = 5; } } - if (gameMode == GameMode.keepAway) + if (gameMode == GameMode.keepAway) // Sets up the game for keep away mode { gameTimer.startTime = time; gameTimer.StartTimer(); @@ -64,7 +71,7 @@ public class GameManager : MonoBehaviour player.GetComponent().lives = 0; } } - if (gameMode == GameMode.obstacleCourse) + if (gameMode == GameMode.obstacleCourse) // Sets up the game for obstacle course mode { foreach (GameObject player in players) { @@ -73,21 +80,9 @@ public class GameManager : MonoBehaviour } } - public enum GameMode + public void PlayerDied(Damageable player) // Handles player deaths for the respective gamemode { - freeForAll, - keepAway, - obstacleCourse - } - - public static GameMode gameMode = GameMode.freeForAll; // loads a default gamemode as a safety net - public static string map = "Platformer With Headroom"; // loads a default map as a safety net - public Vector2 spawnPosition; - public Vector2 hatSpawnPosition; - - public void PlayerDied(Damageable player) - { - if (gameMode == GameMode.freeForAll) + if (gameMode == GameMode.freeForAll) // Respawns player if they have lives left { player.lives--; if (player.lives <= 0 && !gameOver) @@ -95,7 +90,7 @@ public class GameManager : MonoBehaviour player.gameObject.SetActive(false); if (AlivePlayers().Count <= 1) { - GameOver(); + GameOver(); // Winner is called when only one player is left } } else @@ -103,7 +98,7 @@ public class GameManager : MonoBehaviour RespawnPlayer(player.gameObject); } } - if (gameMode == GameMode.keepAway) + if (gameMode == GameMode.keepAway) // Always respawns player regardless of lives { RespawnPlayer(player.gameObject); } @@ -113,7 +108,7 @@ public class GameManager : MonoBehaviour } } - private void RespawnPlayer(GameObject player) + private void RespawnPlayer(GameObject player) // Respawns player at the spawn point and resets health { RespawnOnTriggerEnter respawnScript = player.GetComponent(); if (respawnScript != null) @@ -124,18 +119,19 @@ public class GameManager : MonoBehaviour } } - public void GameOver() + public void GameOver() // Ends game and displays winner { gameOver = true; EndGameEvent?.Invoke(); - if (gameMode == GameMode.freeForAll) + if (gameMode == GameMode.freeForAll) // Last player alive wins { - print(AlivePlayers()[0].name + " is the winner"); - FindFirstObjectByType().WinScene(AlivePlayers()[0]); - WinScreen.Instance.ShowWinScreen(players.IndexOf(AlivePlayers()[0]) + 1); + GameObject winner = AlivePlayers()[0]; + print(winner.name + " is the winner"); + FindFirstObjectByType().WinScene(winner); + WinScreen.Instance.ShowWinScreen(players.IndexOf(winner) + 1); FindFirstObjectByType().HideLifeDisplay(); } - if (gameMode == GameMode.keepAway) + if (gameMode == GameMode.keepAway) // Player with the most time holding the hat wins { GameObject winner = null; float maxHoldTime = 0f; @@ -157,7 +153,7 @@ public class GameManager : MonoBehaviour } } - public List AlivePlayers() + public List AlivePlayers() // Returns a list of all players that are alive { List alivePlayers = new(); @@ -169,7 +165,7 @@ public class GameManager : MonoBehaviour return alivePlayers; } - public void UpdatePlayerHoldTime(GameObject player, float holdTime) + public void UpdatePlayerHoldTime(GameObject player, float holdTime) // Finds each players hold time and updates the leaderboard { if (playerHoldTimes.ContainsKey(player)) { diff --git a/Assets/Scripts/GameManager.cs.meta b/Assets/Scripts/Game/GameManager.cs.meta similarity index 100% rename from Assets/Scripts/GameManager.cs.meta rename to Assets/Scripts/Game/GameManager.cs.meta diff --git a/Assets/Scripts/GameTimer.cs b/Assets/Scripts/Game/GameTimer.cs similarity index 80% rename from Assets/Scripts/GameTimer.cs rename to Assets/Scripts/Game/GameTimer.cs index c87a623..a8a9570 100644 --- a/Assets/Scripts/GameTimer.cs +++ b/Assets/Scripts/Game/GameTimer.cs @@ -18,7 +18,7 @@ public class GameTimer : MonoBehaviour UpdateTimerDisplay(); } - private void Update() + private void Update() // Updates the timer to show the time remaining { if (timerRunning) { @@ -35,7 +35,7 @@ public class GameTimer : MonoBehaviour } } - public void StartTimer() + public void StartTimer() // Starts the timer { if (!timerRunning) { @@ -44,14 +44,14 @@ public class GameTimer : MonoBehaviour } } - private void UpdateTimerDisplay() + private void UpdateTimerDisplay() // Formats and sets the time remaining { int minutes = Mathf.FloorToInt(timeRemaining / 60); int seconds = Mathf.FloorToInt(timeRemaining % 60); timer.text = string.Format("{0}:{1:D2}", minutes, seconds); } - private void OnTimerEnd() + private void OnTimerEnd() // Ends the game when the time runs out { GameManager.Instance.GameOver(); } diff --git a/Assets/Scripts/GameTimer.cs.meta b/Assets/Scripts/Game/GameTimer.cs.meta similarity index 100% rename from Assets/Scripts/GameTimer.cs.meta rename to Assets/Scripts/Game/GameTimer.cs.meta diff --git a/Assets/Scripts/HatRespawn.cs b/Assets/Scripts/Game/HatRespawn.cs similarity index 74% rename from Assets/Scripts/HatRespawn.cs rename to Assets/Scripts/Game/HatRespawn.cs index cc56532..61b7303 100644 --- a/Assets/Scripts/HatRespawn.cs +++ b/Assets/Scripts/Game/HatRespawn.cs @@ -2,7 +2,7 @@ using UnityEngine; public class HatRespawn : MonoBehaviour { - void OnTriggerEnter2D(Collider2D collision) + void OnTriggerEnter2D(Collider2D collision) // Respawns the hat to the hat spawn position if it falls out of bounds { if (collision.gameObject.CompareTag("Platformer Hazard")) { diff --git a/Assets/Scripts/HatRespawn.cs.meta b/Assets/Scripts/Game/HatRespawn.cs.meta similarity index 100% rename from Assets/Scripts/HatRespawn.cs.meta rename to Assets/Scripts/Game/HatRespawn.cs.meta diff --git a/Assets/Scripts/HealthBarManager.cs b/Assets/Scripts/Game/HealthBarManager.cs similarity index 86% rename from Assets/Scripts/HealthBarManager.cs rename to Assets/Scripts/Game/HealthBarManager.cs index 4cc9e9e..0ea9c49 100644 --- a/Assets/Scripts/HealthBarManager.cs +++ b/Assets/Scripts/Game/HealthBarManager.cs @@ -18,7 +18,7 @@ public class HealthBarManager : MonoBehaviour GameManager.Instance.EndGameEvent -= OnGameEnd; } - void Update() + void Update() // Updates position of health bars to follow each player { foreach (var kvp in playerHealthBars) { @@ -26,12 +26,11 @@ public class HealthBarManager : MonoBehaviour if (player == null) continue; GameObject healthBar = kvp.Value; - //healthBar.GetComponent().fullHealthColor = GameManager.playerColors[GameManager.players.IndexOf(player)]; // Color health bars healthBar.transform.SetPositionAndRotation(new Vector3(player.transform.position.x, player.transform.position.y + 1.5f, player.transform.position.z), Quaternion.identity); } } - private void OnGameStart() + private void OnGameStart() // Creates health bars for each player { foreach (GameObject player in GameManager.players) { @@ -45,7 +44,7 @@ public class HealthBarManager : MonoBehaviour } } - private void OnGameEnd() + private void OnGameEnd() // Destroys the health bars when the game ends { foreach (var kvp in playerHealthBars) { diff --git a/Assets/Scripts/HealthBarManager.cs.meta b/Assets/Scripts/Game/HealthBarManager.cs.meta similarity index 100% rename from Assets/Scripts/HealthBarManager.cs.meta rename to Assets/Scripts/Game/HealthBarManager.cs.meta diff --git a/Assets/Scripts/InfiniteScroll.cs b/Assets/Scripts/Game/InfiniteScroll.cs similarity index 91% rename from Assets/Scripts/InfiniteScroll.cs rename to Assets/Scripts/Game/InfiniteScroll.cs index d8a0dda..4e55224 100644 --- a/Assets/Scripts/InfiniteScroll.cs +++ b/Assets/Scripts/Game/InfiniteScroll.cs @@ -6,7 +6,7 @@ public class InfiniteScroll : MonoBehaviour public float start; public float end; - private void Update() + private void Update() // Moves the background { if (transform.position.x > end) { diff --git a/Assets/Scripts/InfiniteScroll.cs.meta b/Assets/Scripts/Game/InfiniteScroll.cs.meta similarity index 100% rename from Assets/Scripts/InfiniteScroll.cs.meta rename to Assets/Scripts/Game/InfiniteScroll.cs.meta diff --git a/Assets/Scripts/LeaderboardManager.cs b/Assets/Scripts/Game/LeaderboardManager.cs similarity index 71% rename from Assets/Scripts/LeaderboardManager.cs rename to Assets/Scripts/Game/LeaderboardManager.cs index 9931c69..b69d9f7 100644 --- a/Assets/Scripts/LeaderboardManager.cs +++ b/Assets/Scripts/Game/LeaderboardManager.cs @@ -8,11 +8,11 @@ public class LeaderboardManager : MonoBehaviour [SerializeField] private GameObject playersParent; [SerializeField] private GameObject playerPrefab; - [SerializeField] private GameObject lifePrefab; + [SerializeField] private GameObject leaderboardIconPrefab; private Dictionary playerIcons = new Dictionary(); - private void Awake() + private void Awake() // Ensures only one instance of LeaderboardManager exists { if (Instance == null) { @@ -29,36 +29,28 @@ public class LeaderboardManager : MonoBehaviour InitializeLeaderboard(); } - private void InitializeLeaderboard() + private void InitializeLeaderboard() // Creates the leaderboard icons for each player { foreach (GameObject player in GameManager.players) { Transform parent = Instantiate(playerPrefab, playersParent.transform).transform; - GameObject life = Instantiate(lifePrefab, parent); - life.GetComponentInChildren().color = GameManager.playerColors[GameManager.players.IndexOf(player)]; + GameObject leaderboardIcon = Instantiate(leaderboardIconPrefab, parent); + leaderboardIcon.GetComponentInChildren().color = GameManager.playerColors[GameManager.players.IndexOf(player)]; playerIcons[player] = parent.gameObject; } } - public void UpdateLeaderboard() + public void UpdateLeaderboard() // Sorts the leaderboard based on player hold times { List> sortedList = new List>(GameManager.playerHoldTimes); sortedList.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value)); - foreach (var player in sortedList) { Debug.Log(player.Key.name + " : " + player.Value); } - // Less fancy sorting system - foreach (var player in sortedList) { playerIcons[player.Key].transform.SetSiblingIndex(sortedList.IndexOf(player)); } - - //foreach (var key in GameManager.playerHoldTimes) - //{ - // print(key.Key.name + " : " + key.Value); - // } } } diff --git a/Assets/Scripts/LeaderboardManager.cs.meta b/Assets/Scripts/Game/LeaderboardManager.cs.meta similarity index 100% rename from Assets/Scripts/LeaderboardManager.cs.meta rename to Assets/Scripts/Game/LeaderboardManager.cs.meta diff --git a/Assets/Scripts/LifeDisplayManager.cs b/Assets/Scripts/Game/LifeDisplayManager.cs similarity index 88% rename from Assets/Scripts/LifeDisplayManager.cs rename to Assets/Scripts/Game/LifeDisplayManager.cs index 302359f..701cfa6 100644 --- a/Assets/Scripts/LifeDisplayManager.cs +++ b/Assets/Scripts/Game/LifeDisplayManager.cs @@ -7,10 +7,9 @@ public class LifeDisplayManager : MonoBehaviour public GameObject players; public GameObject playerPrefab; public GameObject lifePrefab; - public Dictionary> lifeDisplays = new Dictionary>(); - private void Start() + private void Start() // Creates life icons for each player { if (GameManager.gameMode == GameManager.GameMode.freeForAll) { @@ -29,7 +28,7 @@ public class LifeDisplayManager : MonoBehaviour } } - private void Update() + private void Update() // Updates the lives displayed based on player lives { foreach (Damageable damageable in lifeDisplays.Keys) { @@ -40,7 +39,7 @@ public class LifeDisplayManager : MonoBehaviour } } - public void HideLifeDisplay() + public void HideLifeDisplay() // Hides life display { players.SetActive(false); } diff --git a/Assets/Scripts/LifeDisplayManager.cs.meta b/Assets/Scripts/Game/LifeDisplayManager.cs.meta similarity index 100% rename from Assets/Scripts/LifeDisplayManager.cs.meta rename to Assets/Scripts/Game/LifeDisplayManager.cs.meta diff --git a/Assets/Scripts/MapSelect.cs b/Assets/Scripts/Game/MapSelect.cs similarity index 82% rename from Assets/Scripts/MapSelect.cs rename to Assets/Scripts/Game/MapSelect.cs index 462e998..254b301 100644 --- a/Assets/Scripts/MapSelect.cs +++ b/Assets/Scripts/Game/MapSelect.cs @@ -10,7 +10,7 @@ public class MapSelect : MonoBehaviour maps = GetComponent(); } - void Update() + void Update() // Sets the map based on the selected toggle { Toggle toggle = maps.GetFirstActiveToggle(); GameManager.map = toggle.name; diff --git a/Assets/Scripts/MapSelect.cs.meta b/Assets/Scripts/Game/MapSelect.cs.meta similarity index 100% rename from Assets/Scripts/MapSelect.cs.meta rename to Assets/Scripts/Game/MapSelect.cs.meta diff --git a/Assets/Scripts/ModeSelect.cs b/Assets/Scripts/Game/ModeSelect.cs similarity index 90% rename from Assets/Scripts/ModeSelect.cs rename to Assets/Scripts/Game/ModeSelect.cs index e437baa..f2a67b1 100644 --- a/Assets/Scripts/ModeSelect.cs +++ b/Assets/Scripts/Game/ModeSelect.cs @@ -10,7 +10,7 @@ public class ModeSelect : MonoBehaviour maps = GetComponent(); } - void Update() + void Update() // Updates the game mode based on the selected toggle { Toggle toggle = maps.GetFirstActiveToggle(); if (toggle.name == "Free-For-All") diff --git a/Assets/Scripts/ModeSelect.cs.meta b/Assets/Scripts/Game/ModeSelect.cs.meta similarity index 100% rename from Assets/Scripts/ModeSelect.cs.meta rename to Assets/Scripts/Game/ModeSelect.cs.meta diff --git a/Assets/Scripts/MovingPlatform.cs b/Assets/Scripts/Game/MovingPlatform.cs similarity index 75% rename from Assets/Scripts/MovingPlatform.cs rename to Assets/Scripts/Game/MovingPlatform.cs index de48a20..ed204be 100644 --- a/Assets/Scripts/MovingPlatform.cs +++ b/Assets/Scripts/Game/MovingPlatform.cs @@ -6,16 +6,16 @@ public class MovingPlatform : MonoBehaviour public int startPoint; public Transform[] points; public float speed; - private int i; - void Start() + void Start() // Sets the initial position of the platform { transform.position = points[startPoint].position; } void Update() { + // If the platform is close to the target point, it starts moving to the next one if (Vector2.Distance(transform.position, points[i].position) < 0.02f) { i++; @@ -24,7 +24,7 @@ public class MovingPlatform : MonoBehaviour i = 0; } } - + // Moves the platform towards the next point transform.position = Vector2.MoveTowards(transform.position, points[i].position, speed * Time.deltaTime); } } diff --git a/Assets/Scripts/MovingPlatform.cs.meta b/Assets/Scripts/Game/MovingPlatform.cs.meta similarity index 100% rename from Assets/Scripts/MovingPlatform.cs.meta rename to Assets/Scripts/Game/MovingPlatform.cs.meta diff --git a/Assets/Scripts/ObjectVisibility.cs b/Assets/Scripts/Game/ObjectVisibility.cs similarity index 82% rename from Assets/Scripts/ObjectVisibility.cs rename to Assets/Scripts/Game/ObjectVisibility.cs index 0cb5626..a5d7ace 100644 --- a/Assets/Scripts/ObjectVisibility.cs +++ b/Assets/Scripts/Game/ObjectVisibility.cs @@ -12,7 +12,7 @@ public class ObjectVisibility : MonoBehaviour UpdateVisibility(); } - private void UpdateVisibility() + private void UpdateVisibility() // Sets object visible if playing keep away mode { if (GameManager.gameMode == GameManager.GameMode.keepAway) { diff --git a/Assets/Scripts/ObjectVisibility.cs.meta b/Assets/Scripts/Game/ObjectVisibility.cs.meta similarity index 100% rename from Assets/Scripts/ObjectVisibility.cs.meta rename to Assets/Scripts/Game/ObjectVisibility.cs.meta diff --git a/Assets/Scripts/PlayerJoinCard.cs b/Assets/Scripts/Game/PlayerJoinCard.cs similarity index 87% rename from Assets/Scripts/PlayerJoinCard.cs rename to Assets/Scripts/Game/PlayerJoinCard.cs index 619a97a..1e15491 100644 --- a/Assets/Scripts/PlayerJoinCard.cs +++ b/Assets/Scripts/Game/PlayerJoinCard.cs @@ -7,7 +7,7 @@ public class PlayerJoinCard : MonoBehaviour public int playerNumber; public TextMeshProUGUI playerNumberText; - void Start() + void Start() // Sets player number { playerNumberText.text = playerNumber.ToString(); } diff --git a/Assets/Scripts/PlayerJoinCard.cs.meta b/Assets/Scripts/Game/PlayerJoinCard.cs.meta similarity index 100% rename from Assets/Scripts/PlayerJoinCard.cs.meta rename to Assets/Scripts/Game/PlayerJoinCard.cs.meta diff --git a/Assets/Scripts/RespawnOnTriggerEnter.cs b/Assets/Scripts/Game/RespawnOnTriggerEnter.cs similarity index 87% rename from Assets/Scripts/RespawnOnTriggerEnter.cs rename to Assets/Scripts/Game/RespawnOnTriggerEnter.cs index 550f8c3..e795330 100644 --- a/Assets/Scripts/RespawnOnTriggerEnter.cs +++ b/Assets/Scripts/Game/RespawnOnTriggerEnter.cs @@ -6,7 +6,7 @@ public class RespawnOnTriggerEnter : MonoBehaviour public bool spawnPointIsInitialPosition = false; public string respawnTag; - private void Start() + private void Start() // Set the spawn point to the initial maps spawn point { if (spawnPointIsInitialPosition) { @@ -18,7 +18,6 @@ public class RespawnOnTriggerEnter : MonoBehaviour { if (other.CompareTag(respawnTag)) { - //GetComponent().Respawn(); if (TryGetComponent(out Damageable damageable)) { damageable.Damage(9999f); diff --git a/Assets/Scripts/RespawnOnTriggerEnter.cs.meta b/Assets/Scripts/Game/RespawnOnTriggerEnter.cs.meta similarity index 100% rename from Assets/Scripts/RespawnOnTriggerEnter.cs.meta rename to Assets/Scripts/Game/RespawnOnTriggerEnter.cs.meta diff --git a/Assets/Scripts/TerribleHealthBarScript.cs b/Assets/Scripts/Game/TerribleHealthBarScript.cs similarity index 90% rename from Assets/Scripts/TerribleHealthBarScript.cs rename to Assets/Scripts/Game/TerribleHealthBarScript.cs index 4c69b56..2b1eeb0 100644 --- a/Assets/Scripts/TerribleHealthBarScript.cs +++ b/Assets/Scripts/Game/TerribleHealthBarScript.cs @@ -25,19 +25,10 @@ public class TerribleHealthBarScript : MonoBehaviour void Start() { - if (player == null) - { - return; - } - healthScript = player.GetComponent(); - if (healthScript == null) - { - return; - } - Initialize(); + InitializePlayer(player); } - void Update() + void Update() // Updates each player's health bar to display their current health { if (player == null || healthScript == null) { @@ -59,6 +50,11 @@ public class TerribleHealthBarScript : MonoBehaviour } public void SetPlayer(GameObject player) + { + InitializePlayer(player); + } + + private void InitializePlayer(GameObject player) // Adds a health bar for each player { this.player = player; if (this.player == null) @@ -73,7 +69,7 @@ public class TerribleHealthBarScript : MonoBehaviour Initialize(); } - private void Initialize() + private void Initialize() // Sets up the health bars { initialScale = healthVisual.transform.localScale; initialPosition = healthVisual.transform.position; diff --git a/Assets/Scripts/TerribleHealthBarScript.cs.meta b/Assets/Scripts/Game/TerribleHealthBarScript.cs.meta similarity index 100% rename from Assets/Scripts/TerribleHealthBarScript.cs.meta rename to Assets/Scripts/Game/TerribleHealthBarScript.cs.meta diff --git a/Assets/Scripts/WinScreen.cs b/Assets/Scripts/Game/WinScreen.cs similarity index 82% rename from Assets/Scripts/WinScreen.cs rename to Assets/Scripts/Game/WinScreen.cs index 74d0a65..e3c104f 100644 --- a/Assets/Scripts/WinScreen.cs +++ b/Assets/Scripts/Game/WinScreen.cs @@ -7,7 +7,7 @@ public class WinScreen : MonoBehaviour public static WinScreen Instance; public List playerTexts; - private void Awake() + private void Awake() // Ensures only one instance of WinScreen exists { if (Instance == null) { @@ -19,7 +19,7 @@ public class WinScreen : MonoBehaviour } } - public void ShowWinScreen(int player) + public void ShowWinScreen(int player) // Triggers the win screen to appear { foreach (TextMeshProUGUI playerText in playerTexts) { diff --git a/Assets/Scripts/WinScreen.cs.meta b/Assets/Scripts/Game/WinScreen.cs.meta similarity index 100% rename from Assets/Scripts/WinScreen.cs.meta rename to Assets/Scripts/Game/WinScreen.cs.meta diff --git a/Assets/Scripts/Music/MusicManager.cs b/Assets/Scripts/Music/MusicManager.cs index 6ecd094..844b926 100644 --- a/Assets/Scripts/Music/MusicManager.cs +++ b/Assets/Scripts/Music/MusicManager.cs @@ -12,7 +12,7 @@ public class MusicManager : MonoBehaviour private Dictionary sceneToPlaylist = new Dictionary(); public GameObject songPrefab; - private void Awake() + private void Awake() // Creates only one MusicManager instance at a time { if (Instance == null) { @@ -32,7 +32,7 @@ public class MusicManager : MonoBehaviour } } - public void StartPlaylist() + public void StartPlaylist() // Starts music playlist for each scene { if (GetActiveSceneNotTitleScreen() == "Player Select") return; StopAllCoroutines(); @@ -51,7 +51,7 @@ public class MusicManager : MonoBehaviour } } - public void StartPlaylist(string scene) + public void StartPlaylist(string scene) // Sets music for Title Screen { if (GetActiveSceneNotTitleScreen() == "Player Select") return; StopAllCoroutines(); @@ -66,6 +66,7 @@ public class MusicManager : MonoBehaviour { while (true) { + // Shuffles the playlist List randomized = new List(playlist.songs); for (int i = 0; i < randomized.Count; i++) { @@ -75,6 +76,7 @@ public class MusicManager : MonoBehaviour randomized[randomIndex] = temp; } + // Starts the music in the playlist foreach (AudioClip song in randomized) { AudioSource songInstance = Instantiate(songPrefab, transform).GetComponent(); @@ -101,7 +103,7 @@ public class MusicManager : MonoBehaviour } } - public static string GetActiveSceneNotTitleScreen() + public static string GetActiveSceneNotTitleScreen() // Finds the scene name besides Title Screen { for (int sceneIndex = 0; sceneIndex < SceneManager.sceneCount; sceneIndex++) { diff --git a/Assets/Scripts/Player.meta b/Assets/Scripts/Player.meta new file mode 100644 index 0000000..4ba9b51 --- /dev/null +++ b/Assets/Scripts/Player.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c9544c3283a37464f88c711b2bcd2f17 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/AnimationPlayer.cs b/Assets/Scripts/Player/AnimationPlayer.cs similarity index 75% rename from Assets/Scripts/AnimationPlayer.cs rename to Assets/Scripts/Player/AnimationPlayer.cs index f9e505b..37a6c68 100644 --- a/Assets/Scripts/AnimationPlayer.cs +++ b/Assets/Scripts/Player/AnimationPlayer.cs @@ -5,34 +5,30 @@ public class AnimationPlayer : MonoBehaviour { public enum AnimationState { Idle, Run, Jump, Walk }; public AnimationState state; - public bool backwards; - public bool block = false; - public AnimationClip clip; - private Animator animator; - private void Start() + private void Start() // Plays the specified animation clip { animator = GetComponent(); animator.Play(clip.name); } - private void LateUpdate() + private void LateUpdate() // Updates the animation state { 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) + public void SetState(AnimationState state) // Sets the animation state { this.state = state; } - public void Punch() + public void Punch() // Triggers punch animation { animator.SetTrigger("punch"); } diff --git a/Assets/Scripts/AnimationPlayer.cs.meta b/Assets/Scripts/Player/AnimationPlayer.cs.meta similarity index 100% rename from Assets/Scripts/AnimationPlayer.cs.meta rename to Assets/Scripts/Player/AnimationPlayer.cs.meta diff --git a/Assets/Scripts/Block.cs b/Assets/Scripts/Player/Block.cs similarity index 78% rename from Assets/Scripts/Block.cs rename to Assets/Scripts/Player/Block.cs index 71ea5f0..ea13258 100644 --- a/Assets/Scripts/Block.cs +++ b/Assets/Scripts/Player/Block.cs @@ -7,7 +7,7 @@ public class Block : MonoBehaviour public bool blocking = false; private InputActionAsset actions; private float blockPressTime = 0f; - [SerializeField] private float parryThreshold = 0.2f; + [SerializeField] private float parryThreshold = 0.2f; // Time for successful parry private bool isParrying = false; private void Start() @@ -15,25 +15,25 @@ public class Block : MonoBehaviour actions = GetComponent().actions; } - private void Update() + private void Update() // Player blocks when "block" is pressed { InputAction blockAction = actions.FindAction("Block"); if (blockAction.ReadValue() == 1f) { if (!blocking) { - blockPressTime = Time.time; + blockPressTime = Time.time; // Start parry timer } blocking = true; } else { - if (blocking) + if (blocking) // Successful parry if blocked in time { float pressDuration = Time.time - blockPressTime; if (pressDuration <= parryThreshold) { - Parry(); + Parry(); } else { diff --git a/Assets/Scripts/Block.cs.meta b/Assets/Scripts/Player/Block.cs.meta similarity index 100% rename from Assets/Scripts/Block.cs.meta rename to Assets/Scripts/Player/Block.cs.meta diff --git a/Assets/Scripts/Damageable.cs b/Assets/Scripts/Player/Damageable.cs similarity index 75% rename from Assets/Scripts/Damageable.cs rename to Assets/Scripts/Player/Damageable.cs index 19eb64c..07fca3a 100644 --- a/Assets/Scripts/Damageable.cs +++ b/Assets/Scripts/Player/Damageable.cs @@ -7,16 +7,13 @@ using UnityEngine; [RequireComponent(typeof(RespawnOnTriggerEnter))] public class Damageable : MonoBehaviour { - public float force = 50f; + public float force = 50f; // Force applied when hit public float damage = 0f; - public float maxDamage = 1000f; - public int lives = 3; + public float maxDamage = 1000f; // Set max health + public int lives = 0; private Animator animator; - public bool damageSelfDebug = false; - public bool dying = false; - public event System.Action OnPlayerPunched; private void Start() @@ -33,38 +30,37 @@ public class Damageable : MonoBehaviour } } - private void OnTriggerEnter2D(Collider2D collision) + private void OnTriggerEnter2D(Collider2D collision) // Calls Damage method when player is hit { if (collision.gameObject.CompareTag("Punch Hurtbox")) { - //print($"{name}: Ouch"); Damage(collision.transform.parent.gameObject); } } - private void Damage(GameObject damageSource) + private void Damage(GameObject damageSource) // Damages player { if (dying) return; float actualForce = damageSource.GetComponent().force; Block blockComponent = GetComponent(); - GetComponentInChildren().DropItem(); + GetComponentInChildren().DropItem(); // Drops hat if held - if (blockComponent != null && blockComponent.blocking) + if (blockComponent != null && blockComponent.blocking) { - if (blockComponent.IsParrying()) + if (blockComponent.IsParrying()) // Player receives damage if punching a parrying player { damageSource.GetComponent().SuccessfulParry(gameObject, actualForce); return; } - else + else // Player does less damage if punching a blocking player { actualForce /= 4; GetComponent().AddForce(((transform.position - damageSource.transform.position).normalized + Vector3.up * 2) * actualForce, ForceMode2D.Force); } } - else + else // Player does full damage to a non-blocking player { GetComponent().AddForce(((transform.position - damageSource.transform.position).normalized + Vector3.up * 2) * actualForce * (1 + (damage / maxDamage) * 3), ForceMode2D.Force); } @@ -76,7 +72,7 @@ public class Damageable : MonoBehaviour } } - public void Damage(float damage) + public void Damage(float damage) // Adds damage to player when hit { this.damage += damage; if (damage >= maxDamage) @@ -96,7 +92,7 @@ public class Damageable : MonoBehaviour } } - private void Die() + private void Die() // Triggers death animation and sets player to dying state { if (GameManager.Instance != null) { @@ -106,14 +102,14 @@ public class Damageable : MonoBehaviour } } - public void HandleDeath() + public void HandleDeath() // Removes player from dying state after respawn { GameManager.Instance.PlayerDied(this); animator.SetBool("die", false); dying = false; } - public void Respawn() + public void Respawn() // Respawns player to the spawnPosition and resets damage/health bar { transform.position = GameManager.Instance.spawnPosition; if (TryGetComponent(out var rb)) diff --git a/Assets/Scripts/Damageable.cs.meta b/Assets/Scripts/Player/Damageable.cs.meta similarity index 100% rename from Assets/Scripts/Damageable.cs.meta rename to Assets/Scripts/Player/Damageable.cs.meta diff --git a/Assets/Scripts/PlayerCameraMovement.cs b/Assets/Scripts/Player/PlayerCameraMovement.cs similarity index 92% rename from Assets/Scripts/PlayerCameraMovement.cs rename to Assets/Scripts/Player/PlayerCameraMovement.cs index e6b6ed0..bbb87d9 100644 --- a/Assets/Scripts/PlayerCameraMovement.cs +++ b/Assets/Scripts/Player/PlayerCameraMovement.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using UnityEngine; -// This won scene thing is just duct taped on for the presentation. public class PlayerCameraMovement : MonoBehaviour { private Vector3 start; @@ -10,7 +9,6 @@ public class PlayerCameraMovement : MonoBehaviour public float speed; private GameObject playerThatWon; public float lowerBound; - public bool winScene = false; private void Start() @@ -20,7 +18,7 @@ public class PlayerCameraMovement : MonoBehaviour private void Update() { - if (winScene) + if (winScene) // If the game is over, the camera will follow the player that won { if (playerThatWon == null || !playerThatWon.activeInHierarchy) { @@ -39,6 +37,7 @@ public class PlayerCameraMovement : MonoBehaviour return; } + // Moves the camera to follow the players List players = GameManager.players; if (players.Count == 0) return; Vector3 playerAverage = Vector3.zero; @@ -70,7 +69,7 @@ public class PlayerCameraMovement : MonoBehaviour playerThatWon = player; } - private GameObject FindWinner() + private GameObject FindWinner() // Finds the player that won { foreach (GameObject player in GameManager.players) { diff --git a/Assets/Scripts/PlayerCameraMovement.cs.meta b/Assets/Scripts/Player/PlayerCameraMovement.cs.meta similarity index 100% rename from Assets/Scripts/PlayerCameraMovement.cs.meta rename to Assets/Scripts/Player/PlayerCameraMovement.cs.meta diff --git a/Assets/Scripts/PlayerManager.cs b/Assets/Scripts/Player/PlayerManager.cs similarity index 85% rename from Assets/Scripts/PlayerManager.cs rename to Assets/Scripts/Player/PlayerManager.cs index 700a6a5..b5c369f 100644 --- a/Assets/Scripts/PlayerManager.cs +++ b/Assets/Scripts/Player/PlayerManager.cs @@ -23,9 +23,8 @@ public class PlayerManager : MonoBehaviour GetComponent().onPlayerLeft += OnPlayerLeft; } - private void OnPlayerJoined(PlayerInput playerInput) + private void OnPlayerJoined(PlayerInput playerInput) // Adds a player when they join { - //playerInput.transform.SetParent(transform); if (gameStarted) { Destroy(playerInput.gameObject); @@ -41,7 +40,7 @@ public class PlayerManager : MonoBehaviour } - private void OnPlayerLeft(PlayerInput playerInput) + private void OnPlayerLeft(PlayerInput playerInput) // Removes the player if they leave { Destroy(playerInput.gameObject); GameManager.players.Remove(playerInput.gameObject); @@ -60,7 +59,7 @@ public class PlayerManager : MonoBehaviour } } - public void StartGame() + public void StartGame() // Allows game to start after a player has joined { if (GameManager.players.Count == 0) { @@ -70,7 +69,7 @@ public class PlayerManager : MonoBehaviour HubManager.Instance.LoadScene(GameManager.map); } - private void Colorize(int index) + private void Colorize(int index) // Pairs each player with a unique color { GameObject player = GameManager.players[index]; Color color = playerColors[(GameManager.players.Count - 1) % playerColors.Count]; @@ -81,7 +80,7 @@ public class PlayerManager : MonoBehaviour ApplyColor(cards[GameManager.players.IndexOf(player)].playerPreview, color); } - private void ApplyColor(GameObject obj, Color color) + private void ApplyColor(GameObject obj, Color color) // Applies a color to each player { if (obj.TryGetComponent(out _)) { diff --git a/Assets/Scripts/PlayerManager.cs.meta b/Assets/Scripts/Player/PlayerManager.cs.meta similarity index 100% rename from Assets/Scripts/PlayerManager.cs.meta rename to Assets/Scripts/Player/PlayerManager.cs.meta diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs similarity index 85% rename from Assets/Scripts/PlayerMovement.cs rename to Assets/Scripts/Player/PlayerMovement.cs index 41349b2..e84e77d 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -18,20 +18,20 @@ public class PlayerMovement : MonoBehaviour [Header("Movement")] public float walkSpeed; - public float walkSpeedFactor = 1f; - public float maxSpeed = 5f; + public float walkSpeedFactor = 1f; // Sets walk speed + public float maxSpeed = 5f; // Sets max speed public float maxSpeedOverride; - public float slowdownMultiplier = 10f; + public float slowdownMultiplier = 10f; // Sets slow walk speed public float virtualAxisX; public float virtualButtonJump; public float virtualButtonJumpLastFrame; - public float turnaroundMultiplier = 2; + public float turnaroundMultiplier = 2; // Sets speed when turning around public float walkSmooth; public float secondsToFullSpeed; public float jumpSpeed; public float coyoteTime; public float jumpLenience; - public float timeUnableToBeDeclaredNotJumping = 0.1f; + public float timeUnableToBeDeclaredNotJumping = 0.1f; // Jump threshold public float groundCheckDistance; private Rigidbody2D body; @@ -42,19 +42,15 @@ public class PlayerMovement : MonoBehaviour private Damageable damageable; private bool jumpInputStillValid = false; - private float lastTimeJumpPressed; - private bool canBeDeclaredNotJumping = true; - private bool jumpPhysics; - private bool jumping; - + private float lastTimeJumpPressed; private float lastTimeOnGround; private Vector3 positionLastFrame; - void Start() + void Start() // Sets up player components { maxSpeedOverride = maxSpeed; GetComponent().spawnPoint = transform.position; @@ -69,10 +65,10 @@ public class PlayerMovement : MonoBehaviour playerText.text = input.playerIndex.ToString(); } - private void Update() + private void Update() // Updates player movement { if (GameManager.Instance != null && GameManager.Instance.gameOver) maxSpeed = 1f; - if (damageable.dying/* || (GameManager.Instance != null && GameManager.Instance.gameOver)*/) return; + if (damageable.dying) return; Jump(); @@ -88,12 +84,12 @@ public class PlayerMovement : MonoBehaviour Land(); } - private void LateUpdate() + private void LateUpdate() { Animate(); } - private void Animate() + private void Animate() // Sets player animation { if (!IsPhysicallyGrounded()) animationPlayer.SetState(AnimationPlayer.AnimationState.Jump); @@ -111,7 +107,7 @@ public class PlayerMovement : MonoBehaviour animationPlayer.backwards = false; } - private void Land() + private void Land() // Stops jumping when player lands { if (body.linearVelocity.y >= 0f) return; @@ -124,10 +120,8 @@ public class PlayerMovement : MonoBehaviour } } - private void Jump() + private void Jump() // Player jumps when 'jump' is pressed { - //if (!punch.cancelable) return; - if (virtualButtonJumpLastFrame == 1f) { jumpInputStillValid = true; @@ -145,7 +139,7 @@ public class PlayerMovement : MonoBehaviour } } - private void JumpPhysics() + private void JumpPhysics() // Applies jump physics { if (jumpPhysics) { @@ -165,14 +159,14 @@ public class PlayerMovement : MonoBehaviour body.AddForce(Vector2.down * jumpSpeed); } - private IEnumerator NotJumpingDelay() + private IEnumerator NotJumpingDelay() // Sets jump threshold { canBeDeclaredNotJumping = false; yield return new WaitUntil(() => !IsBasicallyGrounded()); canBeDeclaredNotJumping = true; } - private void HorizontalMovement() + private void HorizontalMovement() // Sets player horizontal movement { float temporaryMax = IsPhysicallyGrounded() ? maxSpeedOverride : Mathf.Infinity; float temporarySlowdown = IsPhysicallyGrounded() ? slowdownMultiplier : 1; @@ -184,7 +178,6 @@ public class PlayerMovement : MonoBehaviour if (Mathf.Abs(body.linearVelocityX) >= temporaryMax) { - //body.linearVelocity = new Vector2(Mathf.Sign(body.linearVelocityX) * temporaryMax, body.linearVelocity.y); body.AddForce(new Vector2(-Mathf.Sign(body.linearVelocityX) * (Mathf.Abs(body.linearVelocityX) - temporaryMax) * temporarySlowdown, 0)); } @@ -201,7 +194,7 @@ public class PlayerMovement : MonoBehaviour positionLastFrame = transform.position; } - private void UpdateVirtualAxis() + private void UpdateVirtualAxis() // Updates virtual axis { virtualButtonJump = input.actions.FindAction("Action").ReadValue(); virtualButtonJumpLastFrame = input.actions.FindAction("Action").WasPressedThisFrame() ? 1 : 0; @@ -210,7 +203,7 @@ public class PlayerMovement : MonoBehaviour return; } - public bool IsBasicallyGrounded() + public bool IsBasicallyGrounded() // Checks if player is on land within a threshold { if (IsPhysicallyGrounded()) { @@ -225,7 +218,7 @@ public class PlayerMovement : MonoBehaviour return false; } - public bool IsPhysicallyGrounded() + public bool IsPhysicallyGrounded() // Checks if player is on land { RaycastHit2D leftCheck = Physics2D.Raycast(GetPointInBoxCollider(collide, -1, -1), Vector2.down, groundCheckDistance, ground); RaycastHit2D rightCheck = Physics2D.Raycast(GetPointInBoxCollider(collide, 1, -1), Vector2.down, groundCheckDistance, ground); @@ -239,7 +232,7 @@ public class PlayerMovement : MonoBehaviour return false; } - public Vector2 GetPointInBoxCollider(BoxCollider2D boxCollider2D, float horizontal, float vertical) + public Vector2 GetPointInBoxCollider(BoxCollider2D boxCollider2D, float horizontal, float vertical) { return new Vector2 ( @@ -248,7 +241,7 @@ public class PlayerMovement : MonoBehaviour ); } - public void StopVelocity() + public void StopVelocity() // Stops inertia when landed { if (IsPhysicallyGrounded()) body.linearVelocity = Vector2.zero; } diff --git a/Assets/Scripts/PlayerMovement.cs.meta b/Assets/Scripts/Player/PlayerMovement.cs.meta similarity index 100% rename from Assets/Scripts/PlayerMovement.cs.meta rename to Assets/Scripts/Player/PlayerMovement.cs.meta diff --git a/Assets/Scripts/Punch.cs b/Assets/Scripts/Player/Punch.cs similarity index 78% rename from Assets/Scripts/Punch.cs rename to Assets/Scripts/Player/Punch.cs index 243435c..fd69e5d 100644 --- a/Assets/Scripts/Punch.cs +++ b/Assets/Scripts/Player/Punch.cs @@ -16,7 +16,7 @@ public class Punch : MonoBehaviour actions = GetComponent().actions; } - private void Update() + private void Update() // Executes punch when 'punch' is pressed { if (actions.FindAction("Punch").WasPressedThisFrame()) { @@ -25,12 +25,11 @@ public class Punch : MonoBehaviour } } - private void ExecutePunch() + private void ExecutePunch() // Triggers punch animation { GetComponent().Punch(); DisableCancellation(); - GetComponent().maxSpeedOverride = 1f; - //OnPlayerPunched?.Invoke(gameObject); + GetComponent().maxSpeedOverride = 1f; // Slows player down when punching } public void EnableHurtbox() @@ -53,7 +52,7 @@ public class Punch : MonoBehaviour cancelable = true; } - public void ReturnToMaxSpeed() + public void ReturnToMaxSpeed() // Resets player speed after punch { GetComponent().maxSpeedOverride = GetComponent().maxSpeed; } diff --git a/Assets/Scripts/Punch.cs.meta b/Assets/Scripts/Player/Punch.cs.meta similarity index 100% rename from Assets/Scripts/Punch.cs.meta rename to Assets/Scripts/Player/Punch.cs.meta diff --git a/Assets/Scripts/TeleportPlatform.cs b/Assets/Scripts/Player/TeleportPlatform.cs similarity index 82% rename from Assets/Scripts/TeleportPlatform.cs rename to Assets/Scripts/Player/TeleportPlatform.cs index 8bf33cd..0cd27f2 100644 --- a/Assets/Scripts/TeleportPlatform.cs +++ b/Assets/Scripts/Player/TeleportPlatform.cs @@ -3,25 +3,15 @@ using UnityEngine; public class TeleportPlatform : MonoBehaviour { public Vector2 teleportPoint; - //public bool teleportPosition = false; public string teleportTag; public string playerTag = "Player"; - - public bool isPlatform = true; - //private void Start() - //{ - //if (teleportPosition) - //{ - //teleportPoint = transform.position; - //} - //} - private void OnTriggerEnter2D(Collider2D collision) { if (!isPlatform) { + // Teleports the platform if (collision.CompareTag(teleportTag)) { transform.position = teleportPoint; @@ -33,6 +23,7 @@ public class TeleportPlatform : MonoBehaviour } else { + // Teleports the player if (collision.CompareTag(playerTag)) { collision.transform.position = teleportPoint; diff --git a/Assets/Scripts/TeleportPlatform.cs.meta b/Assets/Scripts/Player/TeleportPlatform.cs.meta similarity index 100% rename from Assets/Scripts/TeleportPlatform.cs.meta rename to Assets/Scripts/Player/TeleportPlatform.cs.meta diff --git a/Assets/Scripts/UseItem.cs b/Assets/Scripts/Player/UseItem.cs similarity index 76% rename from Assets/Scripts/UseItem.cs rename to Assets/Scripts/Player/UseItem.cs index 73cd448..87906c4 100644 --- a/Assets/Scripts/UseItem.cs +++ b/Assets/Scripts/Player/UseItem.cs @@ -12,16 +12,18 @@ public class UseItem : MonoBehaviour { if (isHoldingItem) { + // Keeps hat on the player's head heldItem.transform.position = transform.position + Vector3.up; if (GameManager.gameMode == GameManager.GameMode.keepAway) { + // Adds time to the player's leaderboard standing holdTime += Time.deltaTime; GameManager.Instance.UpdatePlayerHoldTime(gameObject, holdTime); } } } - private void OnCollisionEnter2D(Collision2D collision) + private void OnCollisionEnter2D(Collision2D collision) // Player automatically picks up hat when touching it { if (collision.gameObject.CompareTag("Hat") && !isHoldingItem) { @@ -29,7 +31,7 @@ public class UseItem : MonoBehaviour } } - private void PickUpItem(GameObject item) + private void PickUpItem(GameObject item) // Player picks up hat and starts hold counter { heldItem = item; isHoldingItem = true; @@ -43,7 +45,7 @@ public class UseItem : MonoBehaviour } } - public void DropItem() + public void DropItem() // Player drops hat when hit { if (isHoldingItem) { @@ -58,22 +60,4 @@ public class UseItem : MonoBehaviour } } } - - private void OnEnable() - { - //Punch.OnPlayerPunched += HandlePlayerPunched; - } - - private void OnDisable() - { - //Punch.OnPlayerPunched -= HandlePlayerPunched; - } - /* - private void HandlePlayerPunched(GameObject punchedPlayer) - { - if (punchedPlayer == gameObject) - { - DropItem(); - } - }*/ } diff --git a/Assets/Scripts/UseItem.cs.meta b/Assets/Scripts/Player/UseItem.cs.meta similarity index 100% rename from Assets/Scripts/UseItem.cs.meta rename to Assets/Scripts/Player/UseItem.cs.meta diff --git a/Assets/Scripts/SmoothToTarget.cs b/Assets/Scripts/SmoothToTarget.cs deleted file mode 100644 index 038ab53..0000000 --- a/Assets/Scripts/SmoothToTarget.cs +++ /dev/null @@ -1,7 +0,0 @@ -using System.Collections; -using UnityEngine; - -public class SmoothToTarget : MonoBehaviour -{ - -} diff --git a/Assets/Scripts/SmoothToTarget.cs.meta b/Assets/Scripts/SmoothToTarget.cs.meta deleted file mode 100644 index e8294ed..0000000 --- a/Assets/Scripts/SmoothToTarget.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 617fdbd52246c4352be58c24aef4fd55 \ No newline at end of file