public void ShowSimtoms() { if (Data.Instance.UserSimtoms == null || Data.Instance.UserSimtoms.Count == 0) { foreach (var simComp in _simtomsPool) { simComp.GameObject.SetActive(false); } return; } foreach (Simtom simtom in Data.Instance.UserSimtoms) { var wasNull = UsefullUtils.CheckInPool( simtom.id, GameHiddenOptions.Instance.SimtomPrefab, SimtomsParent, out IPrefabComponent simtomComponent, ref _simtomsPool ); simtomComponent.Id = simtom.id; simtomComponent.GameObject.name = simtom.nume; (simtomComponent as SimtomComponent).Text.text = simtom.nume; //Sprite sprite = Resources.Load("ProductImages/" + product.PicturePath, typeof(Sprite)) as Sprite; //(simtomComponent as SimtomComponent).SetImage(sprite); if (wasNull) { _simtomsPool.Add(simtomComponent); } } }
public void OnMedicamentePropuse() { foreach (Medicament medicament in _medicamentePropuse) { var wasNull = UsefullUtils.CheckInPool( medicament.id, MedicamentPrefab, MedicamentParent.transform, out IPrefabComponent medicamentComponent, ref _medicamentsPool ); medicamentComponent.Id = medicament.id; medicamentComponent.GameObject.name = medicament.nume; (medicamentComponent as MedicamentComponent).Name.text = medicament.nume; Debug.Log(medicament.nume); Sprite sprite = Resources.Load("Images/" + medicament.pic, typeof(Sprite)) as Sprite; (medicamentComponent as MedicamentComponent).SetImage(sprite); if (wasNull) { _medicamentsPool.Add(medicamentComponent); } } var newHeight = (_medicamentePropuse.Count / 2) * 440; MedicamentParent.sizeDelta = new Vector2(MedicamentParent.sizeDelta.x, newHeight); }
private void InitList() { if (_itemsPool != null) { foreach (IPrefabComponent ipc in _itemsPool) { ipc.GameObject.SetActive(false); } } foreach (ItemOption item in Items) { var wasNull = UsefullUtils.CheckInPool( (component) => { return(component.Id == item.Value); }, ItemPrefab, transform, out IPrefabComponent el, ref _itemsPool ); el.GameObject.name = item.Value + "_" + item.Text; (el as InLineItemComponent).Init(item, OnSelectedItemCallback); if (wasNull) { _itemsPool.Add(el); } } }
private IPrefabComponent AddElementInPool(Element element, bool isInitializingElements = false) { var prefab = GameHiddenOptions.Instance.GetPrefabElement(element.ElementType); var wasNull = UsefullUtils.CheckInPool( (IPrefabComponent component) => { var typeId = (ElementType)((component as IElementComponent).TypeId); if (component.GameObject.activeSelf == false && typeId == element.ElementType) { return(true); } return(false); }, prefab, transform, out IPrefabComponent el, ref _elementsPool ); el.UniqueId = element.UniqueId(); el.GameObject.name = ElementsService.GetElementName(element); if (element.ElementType != ElementType.Picture) { var elementComponent = (el as ITextComponent); elementComponent.SetText(element.Text); } else { if (element.Paths != null) { (el as IPictureComponent).Paths = element.Paths; (el as IPictureComponent).FillImages(); } } (el as IElementComponent).TypeId = element.TypeId; if (wasNull) { if (isInitializingElements) { _elementsPool.Add(el); } else { _elementsPool.Insert(element.Index, el); } } return(el); }
public void onCartProductsLoaded(List <CartProduct> cartProducts) { _cartProducts = cartProducts; if (_cartProductsPool != null) { foreach (var item in _cartProductsPool) { item.GameObject.SetActive(false); } } float totalPrice = 0; foreach (CartProduct cartProduct in _cartProducts) { var wasNull = UsefullUtils.CheckInPool( cartProduct.id_product_options, GameHiddenOptions.Instance.CartProductPrefab, CartProductsParent.transform, out IPrefabComponent cartProductComponent, ref _cartProductsPool ); cartProductComponent.Id = cartProduct.id_product_options; cartProductComponent.Route = new Route(); cartProductComponent.GameObject.name = cartProduct.product_name; (cartProductComponent as CartProductComponent).Name.text = cartProduct.product_name; (cartProductComponent as CartProductComponent).Description.text = GetComandaDescription(cartProduct); (cartProductComponent as CartProductComponent).Quantity.text = cartProduct.quantity.ToString(); (cartProductComponent as CartProductComponent).PriceTotal.text = cartProduct.total_price.ToString() + " Lei"; totalPrice += cartProduct.total_price; (cartProductComponent as CartProductComponent).OnChangeQuantity = OnChangeQuantity; Sprite sprite = Resources.Load("ProductImages/" + cartProduct.picture_path, typeof(Sprite)) as Sprite; (cartProductComponent as CartProductComponent).SetImage(sprite); if (wasNull) { _cartProductsPool.Add(cartProductComponent); } } var newHeight = (_cartProducts.Count) * 100; CartProductsParent.sizeDelta = new Vector2(CartProductsParent.sizeDelta.x, newHeight); TotalPrice.text = totalPrice.ToString(); }
private void OnProductsLoaded(List <Product> products) { _products = products; if (_productsPool != null) { foreach (var item in _productsPool) { item.GameObject.SetActive(false); } } foreach (Product product in _products) { var wasNull = UsefullUtils.CheckInPool( product.id, GameHiddenOptions.Instance.ProductPrefab, ProductsParent.transform, out IPrefabComponent productComponent, ref _productsPool ); productComponent.Id = product.id; productComponent.Route = new Route() { RoutePath = "Product", RouteKey = product.id }; productComponent.GameObject.name = product.name; (productComponent as ProductComponent).Name.text = product.name; (productComponent as ProductComponent).PriceOld.text = product.product_price.ToString() + " Lei"; var randomNr = ((int)Random.Range(1, 4)) * 10; var oldPrice = UsefullUtils.GetPercent(product.product_price, 100 - randomNr); (productComponent as ProductComponent).ReducePercent.text = "- " + randomNr.ToString() + " %"; (productComponent as ProductComponent).Price.text = oldPrice + " Lei"; Sprite sprite = Resources.Load("ProductImages/" + product.picture_path, typeof(Sprite)) as Sprite; (productComponent as ProductComponent).SetImage(sprite); if (wasNull) { _productsPool.Add(productComponent); } } var newHeight = (_products.Count / 2) * 240; ProductsParent.sizeDelta = new Vector2(ProductsParent.sizeDelta.x, newHeight); }
private void OnCategoriesLoaded(List <Category> categories) { Categories = categories; if (_categoriesPool != null) { foreach (CategoryComponent cc in _categoriesPool) { cc.gameObject.SetActive(false); } } foreach (Category category in Categories) { var wasNull = UsefullUtils.CheckInPool( category.id, GameHiddenOptions.Instance.CategoryPrefab, this.transform, out IPrefabComponent categoryComponent, ref _categoriesPool ); categoryComponent.Id = category.id; categoryComponent.Route = new Route() { RoutePath = _actionRoutePath, RouteKey = category.id, ExtraRouteKeys = (_actionRoutePath == "Products" ? new Dictionary <string, int>() { { "categoryId", _categoryId } } : null) }; (categoryComponent as CategoryComponent).CategoryName.text = category.description; if (wasNull) { _categoriesPool.Add(categoryComponent); } } }
void Start() { _stories = StoryService.Instance.GetStories(); if (_stories == null || _stories.Count == 0) { ShowNewStoryFields(); ProjectHotkeyEditor.Instance.ShowNewStoryMenu(); return; } UsefullUtils.DumpToJsonConsole(_stories.Cast <IJsonConsole>().ToArray()); foreach (Story story in _stories) { var prefab = GameHiddenOptions.Instance.StoryComponentPrefab; var wasNull = UsefullUtils.CheckInPool( (IPrefabComponent component) => { return(false); }, prefab, OpenStoryPanel.transform, out IPrefabComponent s, ref _storiesPool ); s.UniqueId = s.Id = story.Id; (s as StoryComponent).StoryId.text = story.Id.ToString(); (s as StoryComponent).StoryName.text = story.Name; (s as StoryComponent).StoryPath.text = story.Path; if (wasNull) { _storiesPool.Add(s); } } SelectStory(ArrowDirection.Down, 0); }