Updated PickUp.cs and Hazard.cs were included in the InventorySystem Package.
updated Apr 10,2019
//Included with InventorySystem Scripts
using System.Collections;using System.Collections.Generic;using UnityEngine;//combines frontEnd UI and BackEnd publicclassPickUp : MonoBehaviour {publicItemInstance itemInstance;privateint value;//read-only propertypublicintValue { get { return value; } }privatevoidStart() {this.value=itemInstance.item.value; }/// <summary>/// Adds the item to GameData Inventory/// Can be executed by button.onClick/// when added as a listener/// </summary>publicvoidAddItem( ) //can be called onClick for a button {GameData.instanceRef.AddItem(this.itemInstance); }}//end class PickUp
Hazard Class
This simple class will be used to replace PickUp for Hazard-type objects.
Included with InventorySystem Scripts
using UnityEngine;publicclassHazard : MonoBehaviour { [SerializeField]privateint value;publicintValue { get { return value; } }}
ScorePickUp
This simple class can be used to replace PickUp.cs script component for objects with Collectible Tag, if the item only impacts the score, with no inventory items added.
using UnityEngine;/// <summary>/// Score pickup./// Add to Prefab that will increase score when collision-trigger with Player/// </summary>publicclassScorePickUp : MonoBehaviour {//set in inspectorpublicint Value;}