using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; using UnityEngine.EventSystems; using TMPro; public class LobbyItems : MonoBehaviour { GameObject pPar; GameObject player; LobbyUI lobbyUI; PlayerInventory pInv; public GameObject itemOptPrefab; public GameObject costPointer; public GameObject costPointerText; public Vector3[] costPointerPos; private Slider glueGooSlider; private PlayerStats pStats; InventoryManager invMan; public Tooltip tooltip; Vector3 position; private int pointsLeft; //Item Image and Offsets public Transform[] postItPos; public Sprite[] itemBG; public Vector3[] itemImgPos; public Vector3[] itemImgRot; public Vector3[] itemNamePos; public Vector3[] itemNameRot; public Vector3[] itemCostPos; public Vector3[] itemCostRot; public Vector3[] itemPinPos; ////Runner Body Parts Refs public GameObject[] runnerBodyModifiers; //Sound fx public AudioSource hoverButton; public AudioSource selectButton; public AudioSource backButton; // Start is called before the first frame update void Awake(){ pPar = GameObject.Find("NetworkSMPlayerPrefab"); player = pPar.transform.Find("T-Pose").gameObject; pStats = player.GetComponent(); glueGooSlider = GameObject.Find("GlueGoo").GetComponent(); tooltip = GameObject.Find("ItemTooltip").GetComponent(); lobbyUI = this.gameObject.GetComponent(); pInv = player.GetComponent(); player.GetComponent().enabled = false; player.GetComponent().enabled = false; player.GetComponent().enabled = false; player.GetComponent().enabled = false; player.GetComponent().enabled = false; pPar.transform.Find("UICam").gameObject.SetActive(false); invMan = GetComponent(); } void Start(){ player.GetComponent().enabled = true; InitializeItemB(); pointsLeft = pStats.PlayerPoints; //pointText.text = "Points Left: " + pointsLeft; } private void InitializeItemB(){ Debug.Log("Initialize Items"); int index = 0; if(itemOptPrefab != null){ foreach(var item in invMan.ItemDict){ Debug.Log("Create Button"); position = postItPos[index].position; //Creates Button var iOpt = Instantiate(itemOptPrefab, position, Quaternion.identity); //Uses Item Variables to update button iOpt.name = item.Value.itemName; iOpt.transform.SetParent(GameObject.Find("Items").transform); iOpt.transform.localScale = new Vector3(1.5f,1.5f,1.5f); iOpt.transform.GetChild(3).gameObject.SetActive(false); //Button Adds item if it can iOpt.GetComponent