mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-21 18:04:27 -05:00
Player Inventory Networking
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MLAPI;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerInventory : MonoBehaviour
|
||||
public class PlayerInventory : NetworkBehaviour
|
||||
{
|
||||
|
||||
//List of items
|
||||
@@ -12,20 +13,13 @@ public class PlayerInventory : MonoBehaviour
|
||||
public PlayerStats pStats;
|
||||
|
||||
void Awake(){
|
||||
pStats = GetComponent<PlayerStats>();
|
||||
DontDestroyOnLoad(transform.parent.gameObject);
|
||||
|
||||
pStats = GetComponent<PlayerStats>();
|
||||
}
|
||||
|
||||
//Add item to player Inventory
|
||||
public void AddItem(Item item, bool ableToAdd){
|
||||
|
||||
public void UpdateInventory(Item item, bool ableToAdd){
|
||||
if(!items.Contains(item) && ableToAdd){
|
||||
Debug.Log("Item Added");
|
||||
|
||||
//Add item to player inventroy list
|
||||
items.Add(item);
|
||||
//Equip item
|
||||
item.Equip(pStats, this.gameObject);
|
||||
AddItem(item);
|
||||
}
|
||||
else if(!ableToAdd && !items.Contains(item)){
|
||||
//Item cannot be added
|
||||
@@ -38,6 +32,30 @@ public class PlayerInventory : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateEquips(){
|
||||
foreach(Item item in items){
|
||||
item.Equip(pStats, this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
//Add item to player Inventory
|
||||
public void AddItem(Item item){
|
||||
|
||||
//Adds and equips Item if it can
|
||||
items.Add(item);
|
||||
|
||||
item.Equip(pStats, this.gameObject);
|
||||
|
||||
}
|
||||
|
||||
//Add item to player Inventory
|
||||
public void AddItemNetwork(Item item){
|
||||
|
||||
//Adds and equips Item if it can
|
||||
items.Add(item);
|
||||
|
||||
}
|
||||
|
||||
//Remove Item player inv
|
||||
public void RemoveItem(Item item){
|
||||
if(items.Remove(item)){
|
||||
|
||||
Reference in New Issue
Block a user