using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; public class DesignLab : MonoBehaviour { [Header("Box opening")] public Building designLabBuilding; public Button btnCommonBox,btnRareBox,btnEpicBox,btnLegendaryBox; public int[] boxPrices; public GameObject newBoxPanel; public GameObject newSkinPanel; public GameObject goldsPanel; public Button btnOpen; public ParticleSystem confettiFX; public ParticleSystem[] fullscreenFX; public Button[] slips; [Header("Blueprints")] public GameObject blueprintsPanel; public GameObject noBlueprintsPanel; public Transform gridParent; public GameObject gridChildPrefab; public Transform selectedCard; public int[] buildGoldPrices,buildMetalPrices; public Button btn_build; void Start() { btn_build.onClick.AddListener(OnBuildClicked); btnCommonBox.onClick.AddListener(()=>{OnBoxSelected(0);}); btnRareBox.onClick.AddListener(()=>{OnBoxSelected(1);}); btnEpicBox.onClick.AddListener(()=>{OnBoxSelected(2);}); btnLegendaryBox.onClick.AddListener(()=>{OnBoxSelected(3);}); btnOpen.onClick.AddListener(OnOpen); foreach(Button btn in slips){ btn.onClick.AddListener(OnSlipSelected); } Refresh(); } public int selectedBoxIndex = -1; int selectedBlueprintIndex= 0; public void OnBoxSelected(int index){ selectedBoxIndex = index; Refresh(); AudioManager.instnace.UIClick(); } void Refresh() { RefreshBoxes(); RefreshBlueprints(); } void RefreshBlueprints(){ for(int i=0; i < gridParent.childCount; i++){ //PURGE Destroy(gridParent.GetChild(i).gameObject); } List blueprints = DBmanager.Blueprints; if(blueprints.Count <= 0){ blueprintsPanel.SetActive(false); noBlueprintsPanel.SetActive(true); return; } blueprintsPanel.SetActive(true); noBlueprintsPanel.SetActive(false); blueprintItems = new List(); //Populate for(int i =0; i < blueprints.Count; i++){ GameObject newItem = Instantiate(gridChildPrefab, gridParent); SkinShopItemData skinData = SkinShopManager.GetSkinDataByName(blueprints[i].name); newItem.transform.GetComponentInChildren().text = SkinShopManager.GetRarityName(skinData.skinType); newItem.transform.GetComponentInChildren().color = SkinShopManager.GetRarityColor(skinData.skinType); newItem.transform.Find("img_skin").GetComponent().sprite = skinData.image; newItem.name = blueprints[i].name; int index = i; newItem.GetComponent