mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-03-22 01:34:22 -05:00
Added an ItemOption Prefab Created Player Prefab The player now will get their items in the inventory selection screen Only within this scene will items be able to be added and removed Updated player files to check for characterController being enabled This will make it easier to implement the dual RigidBody system
46 lines
977 B
C#
46 lines
977 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>();
|
|
|
|
}
|
|
|
|
public void AddItem(Item item){
|
|
if(!items.Contains(item)){
|
|
Debug.Log("Item Added");
|
|
items.Add(item);
|
|
item.Equip(pStats);
|
|
}
|
|
else{
|
|
Debug.Log("Item Removed");
|
|
RemoveItem(item);
|
|
}
|
|
|
|
}
|
|
|
|
public void AddSpecialItem<T>(T itemCandidate) { // Unless we don't want the four special items to be handled by inventory/inventory manager?
|
|
if (itemCandidate is Item) {
|
|
items.Add(itemCandidate as Item);
|
|
}
|
|
}
|
|
|
|
|
|
public void RemoveItem(Item item){
|
|
if(items.Remove(item)){
|
|
item.Unequip(pStats);
|
|
}
|
|
}
|
|
|
|
|
|
}
|