Created the Inventory Selection Scene

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
This commit is contained in:
Melbyj1125
2021-10-14 22:50:44 -05:00
parent c39ffc26c1
commit a42e802ace
21 changed files with 2046 additions and 318 deletions

View File

@@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class InvSceneSettings : MonoBehaviour
{
GameObject player1;
PlayerInventory pInv;
public GameObject itemOptPrefab;
InventoryManager invMan;
// Start is called before the first frame update
void Awake(){
player1 = GameObject.Find("PlayerPrefab");
pInv = player1.GetComponent<PlayerInventory>();
player1.GetComponent<PlayerMovement>().enabled = false;
player1.transform.GetChild(0).gameObject.SetActive(false);
invMan = GetComponent<InventoryManager>();
}
void Start(){
InitializeItemB();
}
// Update is called once per frame
void Update(){
}
private void InitializeItemB(){
int index = 0;
if(itemOptPrefab != null){
foreach(Item item in invMan.ItemList){
Vector3 position = new Vector3((1+(index)),3,0);
var iOpt = Instantiate(itemOptPrefab, position, Quaternion.identity);
iOpt.name = item.itemName;
iOpt.transform.SetParent(GameObject.Find("Items").transform);
iOpt.transform.localScale = new Vector3(1,1,1);
iOpt.GetComponent<Button>().onClick.AddListener(delegate{pInv.AddItem(item);});
iOpt.GetComponentInChildren<Text>().text = item.itemName;
//iOpt.GetComponentInChildren<Image>() = item.image; // IMPLEMENT WHEN ITEM OBJECT CONTAIN IMAGE REFERENCE
index++;
}
}
else{
Debug.Log("itemOption prefab was not set");
}
}
}