mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-03-24 02:34:31 -05:00
48 lines
1016 B
C#
48 lines
1016 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PlayerInventory : MonoBehaviour
|
|
{
|
|
|
|
//List of items
|
|
[SerializeField] List<Item> items;
|
|
|
|
//Scripts
|
|
public PlayerStats pStats;
|
|
|
|
void Awake(){
|
|
pStats = GetComponent<PlayerStats>();
|
|
DontDestroyOnLoad(transform.parent.gameObject);
|
|
|
|
}
|
|
|
|
public void AddItem(Item item, bool ableToAdd){
|
|
if(!items.Contains(item) && ableToAdd){
|
|
Debug.Log("Item Added");
|
|
items.Add(item);
|
|
item.Equip(pStats, this.gameObject);
|
|
}
|
|
else if(!ableToAdd && !items.Contains(item)){
|
|
Debug.Log("Item Cannot Be Added");
|
|
}
|
|
else{
|
|
Debug.Log("Item Removed");
|
|
RemoveItem(item);
|
|
}
|
|
}
|
|
|
|
|
|
public void RemoveItem(Item item){
|
|
if(items.Remove(item)){
|
|
item.Unequip(pStats, this.gameObject);
|
|
}
|
|
}
|
|
|
|
public List<Item> GetItems(){
|
|
return items;
|
|
}
|
|
|
|
|
|
}
|