using UnityEngine;publicenum CollectItemType { jump, ammo, health, weapon}publicclassCollectableItem: MonoBehaviour{[SerializeField] CollectItemType collectItemType;public CollectItemType GetCollectItemType(){returncollectItemType;}}
using UnityEngine;publicclassPlayer: MonoBehaviour{voidActivateTripleJump(){Debug.Log("You can make tripple jumps now");}voidAddWeapon(){Debug.Log("You can use a new weapon now");}voidAddAmmo(){Debug.Log("Ammo added");}voidAddHealth(){Debug.Log("Hp increased");}privatevoidOnTriggerEnter2D(Collider2D collision){ CollectableItem collectableItem =collision.GetComponent<CollectableItem>();if(collectableItem!=null){ CollectItemType ctype =collectableItem.GetCollectItemType();switch(ctype){caseCollectItemType.jump:ActivateTripleJump();break;caseCollectItemType.weapon:AddWeapon();break;caseCollectItemType.ammo:AddAmmo();break;caseCollectItemType.health:AddHealth();break;default:break;}}}}