private void Start() { resourceDisplayGroups = new List <ResourceDisplayGroup>(); resourceCategories = new List <ResourceCategory>(); System.Array.Sort(allResources, delegate(Resource x, Resource y) { return(x.resourceCategory.CompareTo(y.resourceCategory)); }); for (int i = 0; i < allResources.Length; i++) { Resource item = allResources[i]; if (!resourceCategories.Contains(item.resourceCategory)) { GameObject gO = Instantiate(resourceDisplayGroupPrefab, resourceDisplayParent) as GameObject; ResourceDisplayGroup group = gO.GetComponent <ResourceDisplayGroup>(); string title = item.resourceCategory.ToString(); title = title.Replace("_", " "); group.SetTitleText(title); group.resourceCategory = item.resourceCategory; resourceDisplayGroups.Add(group); resourceCategories.Add(item.resourceCategory); gO.SetActive(false); } } requiermentsMeet = new List <ResoureRequierment>(); requiermentsMeet.Add(ResoureRequierment.Start); }
public void ActivateResource(Resource _resource) { if (!_resource.isEnabled) { _resource.isEnabled = true; ResourceDisplayGroup displayGroup = null; foreach (var group in resourceDisplayGroups) { if (group.resourceCategory == _resource.resourceCategory) { displayGroup = group; displayGroup.gameObject.SetActive(true); } } if (displayGroup == null) { return; } GameObject gO = Instantiate(resourceDisplayPrefab, displayGroup.GetContentTransform()) as GameObject; gO.GetComponent <ResourceDisplay>().SetResource(_resource); StartCoroutine(ResetLayout()); } }