ccl4/blueberryPeak/Assets/Scripts/Quests/Reward.cs
2025-06-19 01:07:40 +02:00

45 lines
941 B
C#

using System;
using UnityEngine;
// base class for all rewards
[Serializable]
public abstract class InventoryItem : ScriptableObject
{
[SerializeField] public string itemName;
[SerializeField] public int quantity = 1;
public abstract void giveReward(GameObject player);
}
[CreateAssetMenu(menuName = "GameItems/ItemRewardWithScript")]
public class ItemRewardWithScript : InventoryItem
{
public ItemRewardWithScript(string itemName, int quantity)
{
this.itemName = itemName;
this.quantity = quantity;
}
public override void giveReward(GameObject player)
{
var reward = CreateInstance<ItemReward>();
reward.itemName = itemName;
reward.quantity = quantity;
player.GetComponent<PlayerInteraction>().AddToInventory(reward);
// Add logic to give an item to the player
Debug.Log($"You have received {quantity} {itemName}(s)!");
}
}