# PickUp, Hazard, ScorePickUp

**updated Apr 10,2019**

**//Included with InventorySystem Scripts**

```java
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

//combines frontEnd UI and BackEnd 
public class PickUp : MonoBehaviour {

    public ItemInstance itemInstance;

    private int value;

    //read-only property
    public int Value
    {
        get { return value; }
    }

    private void Start()
    {
        this.value = itemInstance.item.value;
    }

    /// <summary>
    /// Adds the item to GameData Inventory
    /// Can be executed by button.onClick
    /// when added as a listener
    /// </summary>
    public void AddItem( ) //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**

```java
using UnityEngine;


public class Hazard : MonoBehaviour {

    [SerializeField]
    private int value;

    public int Value
    {
        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.

```java
using UnityEngine;

/// <summary>
/// Score pickup.
/// Add to Prefab that will increase score when collision-trigger with Player
/// </summary>
public class ScorePickUp : MonoBehaviour {

    //set in inspector
    public int Value;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kdoore.gitbook.io/cs2335/cs2335_f20/project-3-code-mods/project-3-code/class-code-examples/pickup-final.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
