A collection of works I completed when studying under the Game Programming module
- The EnemyScript handles enemies that follow the player by casting a ray using RaycastHit2D and checking whether the player is within a specified distance to follow. It also deals damage to the player OnCollisionEnter2D and uses IEnumerator to freeze the enemy after attacking. seeDistance and enemyAttack are undefined within the code to allow customised enemy stats on Unity itself.
When tasked to create a 2D loot collection game in Unity that uses modular code with custom methods and a randomized item system, most of the coding aspect was smooth sailing except for one factor; upon reaching the max loot received, the player can continue to collect more items, causing previous items to be overwritten.
The solution I came up with is simple in hindsight-
When all slots in the player's inventory is filled, the button to continue collecting is disabled, forcing the player to either stop or reset the inventory to collect more.