MiniGame Mods
MiniGame Modifications to Integrate Inventory System
/// <summary>
/// THIS IS THE EVENT that starts the chain reaction of events
/// </summary>
/// <param name="collision">Collision.</param>
//Customize to your game needs
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Collectible"))
{
//update score
PickUp collectibleItem = collision.GetComponent<PickUp>();
GameData.instanceRef.Add(collectibleItem.Value); //points for each specific item's value
//ADD THIS NEW CODE FOR INVENTORY SYSTEM
GameData.instanceRef.AddItem(collectibleItem.itemInstance); //points for each specific item's value
Debug.Log("Hit collectible");
Destroy(collision.gameObject);
}
else if (collision.CompareTag("Hazard"))
{
//decrease health
//what type of object has tag "Hazard"
//ADD THIS NEW CODE FOR INVENTORY SYSTEM - HAZARD COMPONENT
Hazard hazardItem = collision.GetComponent<Hazard>();
if (hazardItem != null)
{
GameData.instanceRef.TakeDamage(hazardItem.Value);
}
else
{
Debug.Log("Collided with a different type Hazard");
//TODO add code for Hazard-type items
PickUp item = collision.GetComponent<PickUp>();
GameData.instanceRef.TakeDamage(item.Value);
}
Destroy(collision.gameObject);
}
else
{
Debug.Log("Hit Something Else");
}
} //end functionUpdate Spawned Prefabs:

Updated GameData.cs - 4/13/20
Last updated