private void SetNewFavorites() { if (StoreManager.Singleton.Day == 1) { TopCategory = StockItem.StockCategory.FruitAndVeg; SecondCategory = StockItem.StockCategory.Dairy; ThirdCategory = StockItem.StockCategory.BakedGoods; return; } List <StockItem.StockCategory> stockCategories = new List <StockItem.StockCategory>(); do { //Get random index for a category int random = Random.Range(0, Enum.GetNames(typeof(StockItem.StockCategory)).Length); StockItem.StockCategory category = (StockItem.StockCategory) Enum.Parse(typeof(StockItem.StockCategory), Enum.GetNames(typeof(StockItem.StockCategory))[random]); //Check if already in list if (!stockCategories.Contains(category)) { stockCategories.Add(category); } //Add to list } while (stockCategories.Count < 3); TopCategory = stockCategories[0]; SecondCategory = stockCategories[1]; ThirdCategory = stockCategories[2]; }
public void SetCategory(int categoryIndex) { if (categoryIndex == _stockIndex) { return; } SoundManager.Singleton.PlayButtonClickSound(); _stockIndex = categoryIndex; _stockCategory = (StockItem.StockCategory)categoryIndex; TxtCategory.text = _stockCategory.ToString(); switch (WindowType) { case StockItemWindowType.Inventory: LoadInventoryItems(); break; case StockItemWindowType.Order: LoadOrderItems(); break; } }
private void FillInventoryItemList() { if (ActiveContainer.RestrictItemCategory) { _stockCategory = ActiveContainer.RestrictedCategories[0]; TxtCategory.text = _stockCategory.ToString(); } foreach (var stockItem in StoreManager.Singleton.Inventory) { if (stockItem.Category == _stockCategory) { GameObject newStockEntry = Instantiate(StockItemEntryPrefab) as GameObject; newStockEntry.transform.SetParent(_grid, true); newStockEntry.transform.localScale = Vector3.one; newStockEntry.transform.FindChild("txtText").GetComponent <Text>().text = stockItem.Name + "\n" + stockItem.Amount + "/" + stockItem.MaxAmount + " pack" + "\n" + stockItem.Price.ToString("C") + " pp"; newStockEntry.transform.FindChild("Image").GetComponent <Image>().sprite = StockItemManager.Singleton.GetInventorySprite(stockItem.SpriteName); newStockEntry.GetComponent <StockItemReferenceHolder>().StockItemReference = stockItem; //Sets the OnClick event for the button Button b = newStockEntry.GetComponent <Button>(); b.GetComponent <Button>().onClick.AddListener(() => OnClickedStockItemForSlotting(b)); } } }
public EconomyData(StockItem.StockCategory topCategory, StockItem.StockCategory secondCategory, StockItem.StockCategory thirdCategory, int daysSinceLastChange, EconomyManager.Weather weather) { TopCategory = topCategory; SecondCategory = secondCategory; ThirdCategory = thirdCategory; DaysSinceLastChange = daysSinceLastChange; Weather = weather; }
public Sprite GetCategorySprite(StockItem.StockCategory category) { Sprite spr = CategorySprites.Find(sprite => sprite.Category == category).Sprite; if (spr == null) { spr = UnknownItemSprite; } return(spr); }
private void AddStockItem(string name, int amount, string description, StockItem.StockCategory category, string spriteName, float price, int unlockLevel) { StockItem newStockItem = new StockItem(); newStockItem.Name = name; newStockItem.Description = description; newStockItem.MaxAmount = amount; newStockItem.Amount = amount; newStockItem.Category = category; newStockItem.SpriteName = spriteName; newStockItem.Price = price; newStockItem.UnlockLevel = unlockLevel; PossibleItems.Add(newStockItem); }
/// <summary> /// Searches all containers and returns the ones containing an item of the given category /// </summary> /// <param name="category"></param> /// <returns></returns> public List <GameObject> GetContainersWithCategory(StockItem.StockCategory category) { //Find all store objects with a certain category of item slotted in them List <GameObject> outputList = new List <GameObject>(); foreach (GameObject storeObject in StoreObjectManager.Singleton.StoreObjects) { if (storeObject.GetComponent <ItemStockContainer>().InventoryItem != null && storeObject.GetComponent <ItemStockContainer>().InventoryItem.Category == category) { outputList.Add(storeObject); } } return(outputList); }
public void NextCategory() { _stockIndex++; _stockIndex = _stockIndex % Enum.GetNames(typeof(StockItem.StockCategory)).Length; //Makes sure index can't be out of bounds _stockCategory = (StockItem.StockCategory)_stockIndex; TxtCategory.text = _stockCategory.ToString(); switch (WindowType) { case StockItemWindowType.Inventory: LoadInventoryItems(); break; case StockItemWindowType.Order: LoadOrderItems(); break; } }
private void SetCategory() { int rand = Random.Range(0, 101); if (rand < 40) { CategorySearchingFor = EconomyManager.Singleton.TopCategory; } else if (rand > 40 && rand < 65) { CategorySearchingFor = EconomyManager.Singleton.SecondCategory; } else if (rand > 65 && rand < 80) { CategorySearchingFor = EconomyManager.Singleton.ThirdCategory; } else if (rand > 80 && rand < 101) { int index = Random.Range(0, Enum.GetValues(typeof(StockItem.StockCategory)).Length); CategorySearchingFor = (StockItem.StockCategory)Enum.GetValues(typeof(StockItem.StockCategory)).GetValue(index); } }
public void PreviousCategory() { _stockIndex--; if (_stockIndex < 0) { _stockIndex = Enum.GetNames(typeof(StockItem.StockCategory)).Length - 1; } _stockCategory = (StockItem.StockCategory)_stockIndex; TxtCategory.text = _stockCategory.ToString(); switch (WindowType) { case StockItemWindowType.Inventory: LoadInventoryItems(); break; case StockItemWindowType.Order: LoadOrderItems(); break; } }
public void ShowCategoryBubble(StockItem.StockCategory category) { SetThoughtSprite(StockItemManager.Singleton.GetCategorySprite(category)); EnableThoughtBubble(); }