2022-12-19 03:34:45 +01:00
|
|
|
using System;
|
2022-05-15 18:54:59 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2022-12-19 03:34:45 +01:00
|
|
|
using UnityEngine.Events;
|
2022-05-15 18:54:59 +02:00
|
|
|
using UnityEngine.UI;
|
|
|
|
|
2022-05-29 12:33:43 +02:00
|
|
|
[System.Serializable]
|
|
|
|
[CreateAssetMenu(fileName = "New Item", menuName = "Inventory/Items")]
|
|
|
|
public class Item : ScriptableObject
|
2022-05-15 18:54:59 +02:00
|
|
|
{
|
2022-05-29 12:33:43 +02:00
|
|
|
public int id;
|
|
|
|
public int Id
|
|
|
|
{
|
|
|
|
get { return id; }
|
|
|
|
set { id = value; }
|
|
|
|
}
|
|
|
|
|
2022-05-15 18:54:59 +02:00
|
|
|
public string name;
|
|
|
|
public string Name
|
|
|
|
{
|
|
|
|
get { return name; }
|
|
|
|
set { name = value; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public string description;
|
|
|
|
public string Description
|
|
|
|
{
|
|
|
|
get { return description; }
|
|
|
|
set { description = value; }
|
|
|
|
}
|
|
|
|
|
|
|
|
public int level;
|
|
|
|
public int Level
|
|
|
|
{
|
|
|
|
get { return level; }
|
|
|
|
set { level = value; }
|
|
|
|
}
|
|
|
|
|
2022-12-19 03:34:45 +01:00
|
|
|
public int value;
|
|
|
|
public int Value
|
|
|
|
{
|
|
|
|
get { return value; }
|
|
|
|
set { this.value = value; }
|
|
|
|
}
|
|
|
|
|
2022-05-29 12:33:43 +02:00
|
|
|
public Sprite image;
|
|
|
|
public Sprite Image
|
2022-05-15 18:54:59 +02:00
|
|
|
{
|
|
|
|
get { return image; }
|
|
|
|
set { image = value; }
|
|
|
|
}
|
|
|
|
|
|
|
|
// to handle object created on scene for example after removing from inventory
|
|
|
|
public GameObject itemModel;
|
|
|
|
public GameObject ItemModel
|
|
|
|
{
|
|
|
|
get { return itemModel; }
|
|
|
|
set { itemModel = value; }
|
|
|
|
}
|
|
|
|
|
2022-12-19 03:34:45 +01:00
|
|
|
public int price;
|
|
|
|
public int Price
|
|
|
|
{
|
|
|
|
get { return price; }
|
|
|
|
set { price = value; }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public UnityEvent useEffect = new UnityEvent();
|
2022-06-17 22:22:19 +02:00
|
|
|
public Item() {}
|
|
|
|
|
|
|
|
public Item(Item _item)
|
|
|
|
{
|
|
|
|
this.Name = _item.Name;
|
|
|
|
this.Description = _item.Description;
|
|
|
|
this.Level = _item.Level;
|
2022-12-19 03:34:45 +01:00
|
|
|
this.Value = _item.Value;
|
|
|
|
this.Price = _item.price;
|
2022-06-17 22:22:19 +02:00
|
|
|
this.ItemModel = _item.ItemModel;
|
|
|
|
this.Image = _item.Image;
|
|
|
|
}
|
|
|
|
|
2022-12-19 03:34:45 +01:00
|
|
|
public Item(string _name, string _description, int _level, int _value, GameObject _itemModel, Sprite _image)
|
2022-05-15 18:54:59 +02:00
|
|
|
{
|
|
|
|
this.Name = _name;
|
|
|
|
this.Description = _description;
|
|
|
|
this.Level = _level;
|
2022-12-19 03:34:45 +01:00
|
|
|
this.Value = _value;
|
2022-05-29 12:33:43 +02:00
|
|
|
this.ItemModel = _itemModel;
|
2022-05-15 18:54:59 +02:00
|
|
|
this.Image = _image;
|
|
|
|
}
|
2022-06-17 22:22:19 +02:00
|
|
|
|
2022-12-19 03:34:45 +01:00
|
|
|
public Item(string _name, string _description, int _level, int _value, int _price, GameObject _itemModel, Sprite _image)
|
|
|
|
{
|
|
|
|
this.Name = _name;
|
|
|
|
this.Description = _description;
|
|
|
|
this.Level = _level;
|
|
|
|
this.Value = _value;
|
|
|
|
this.Price = _price;
|
|
|
|
this.ItemModel = _itemModel;
|
|
|
|
this.Image = _image;
|
|
|
|
}
|
2022-06-17 22:22:19 +02:00
|
|
|
|
|
|
|
|
2022-12-19 03:34:45 +01:00
|
|
|
public void InvokeEffectAction()
|
|
|
|
{
|
|
|
|
Debug.Log($"Use {name} effect");
|
|
|
|
useEffect.Invoke();
|
|
|
|
}
|
2022-05-15 18:54:59 +02:00
|
|
|
}
|