private IEnumerator LoopTarget() { while (true) { // Select randomly next target target = (IngredientID)Random.Range(1, (int)IngredientID.Count); targetImage.sprite = Resources.Load <Sprite> ("UI/" + target); targetImage.color = Color.white; puff.Play(true); // Switch Boat supplies Boat.SwitchAll(target); // Wait until next change float clock = 0f; while (clock <= changeRate) { // Update timer timer.value = clock / changeRate; yield return(null); clock += Time.deltaTime; } } }
public static void SwitchAll(IngredientID target) { var chosen = Random.Range(0, boats.Count); for (int i = 0; i != boats.Count; i++) { if (i != chosen) { // Select a "random" ingredient IngredientID random = target; for (int a = 0; a != i + 1; a++) { random++; if (random == IngredientID.Count) { random = IngredientID.Seta; } } boats[i].supply.ingredient = random; // Save selection boats[i].supply.ingredient = random; } // Chosen boat carries cauldron target else { boats[i].supply.ingredient = target; } // Update boat boats[i].puff.Play(true); boats[i].UpdateBoatType(); } }
public static void BuyIngredientFromCurrentMarket(IngredientID ingredient) { Hero.GainIngredient(ingredient, 1); Hero.Aurum -= currentMarket.Wares[ingredient].cost; currentMarket.Wares[ingredient].quantity--; LayoutManager.Main.UpdateAll(); }
private void TakeIngredient(GameObject target) { IngredientID id = target.GetComponent <IngredientInfo>().id; //Debug.Log("picked up ingredient of type: " + id); managePlayerData.updateIngredients(id, true); //Destroy(target); }
public void GainIngredient(IngredientID ingr, int amount = 1) { if (!myIngredients.ContainsKey(ingr)) { myIngredients.Add(ingr, 0); } myIngredients[ingr] += amount; }
public void tryBuyIngredient(IngredientID ingredient, Market market) { if (canBuyIngredient(ingredient, market)) { market.Wares[ingredient].quantity--; Aurum -= market.Wares[ingredient].cost; GainIngredient(ingredient); } }
public Reward AddIngredient(IngredientID ingredient, int quantity) { if (!Ingredients.ContainsKey(ingredient)) { Ingredients.Add(ingredient, 0); } Ingredients[ingredient] += quantity; return(this); }
//function for updating the players ingredient inventory given the id of //the ingredient to be updated //isAdding is a bool to tell if the item is being added to players inventory //if !isAdded item is being removed from players inventory public void updateIngredients(IngredientID id, bool isAdding) { if (isAdding) { playerData.ingredients[(int)id] += 1; } else { playerData.ingredients[(int)id] -= 1; } }
public static bool CanBuyIngredientFromCurrentMarket(IngredientID ingredient) { //if (!currentMarket.sellsIngredients) // return false; if (!currentMarket.Wares.ContainsKey(ingredient)) { return(false); } return(CanBuyFromListing(currentMarket.Wares[ingredient])); }
public IngredientData GetIngredientData(IngredientID id) { foreach (IngredientData data in ingredientDatas) { if (id == data.id) { return(data); } } Debug.LogError("Ingredient data not found for id: " + id); return(null); }
public Ingredient(string name, IngredientID id, int minCost, int usualCost, int maxCost, Sprite sprite) { this.name = name; this.id = id; this.usualCost = usualCost; this.minCost = minCost; this.maxCost = maxCost; this.sprite = sprite; Definitions.Add(id, this); }
public bool canBuyIngredient(IngredientID ingredient, Market market) { if (!market.Wares.ContainsKey(ingredient)) { return(false); } Listing listing = market.Wares[ingredient]; if (Aurum < listing.cost) { return(false); } if (listing.quantity <= 0) { return(false); } return(true); }
public void Spawn(IngredientID ingredient, IngredientType type) { // Instantiate prefab var prefab = Resources.Load <Ingredient> ("Prefabs/Ingredients/" + ingredient.ToString()); this.ingredient = Instantiate(prefab, transform); this.ingredient.Process(type); // Correct behaviour this.ingredient.helper.enabled = false; marker = this.ingredient.helper.marker; this.ingredient.body.interpolation = RigidbodyInterpolation.None; this.ingredient.colliders.ForEach(c => c.enabled = false); this.ingredient.helper.colliders.ForEach(c => c.enabled = false); // Relocate this.ingredient.transform.localPosition = (Vector3.up * 0.3f); this.ingredient.transform.localScale *= 1.75f; }
public void HandleBurned(IngredientID id) { GameObject newEnemy = GameObject.Instantiate(lootMapping[id]); newEnemy.SetActive(true); }
public Spell addIngredient(IngredientID ingr, int quantity) { IngredientCost.Add(ingr, quantity); return(this); }
public void RemoveIngredient(IngredientID id) { ingredients[(int)id] -= 1; numItems -= 1; }
public int CompareTo(Ingredient other) { return(IngredientID.CompareTo(other.IngredientID)); }
public void UpdateMarketPanel() { bool newShitInStores = false; foreach (KeyValuePair <MarketID, Market> entry in Market.Definitions) { if (entry.Value.Unlocked && entry.Value.NewWares) { newShitInStores = true; } } LocationButtons[1].gameObject.GetComponentInChildren <Text>().text = newShitInStores ? " (!)" : ""; MarketTitleText.text = currentMarket.name + " " + currentMarket.status; //Disable and enable the appropriate market buttons foreach (ButtonSwitchMarket marketButton in SelectMarketButtons) { marketButton.gameObject.SetActive(Market.Definitions[marketButton.myMarket].Unlocked); marketButton.gameObject.GetComponent <Button>().interactable = marketButton.myMarket != currentMarket.ID; marketButton.gameObject.GetComponentInChildren <Text>().text = Market.Definitions[marketButton.myMarket].GetTabName(); } //Update selection of ingredients foreach (ButtonBuyIngredient ingredientButton in MarketPurchaseIngredientButtons) { IngredientID ingredientID = ingredientButton.myIngredient; Button button = ingredientButton.GetComponent <Button>(); bool marketHasIngredient = currentMarket.sellsIngredients && currentMarket.Wares.ContainsKey(ingredientID); ingredientButton.gameObject.SetActive(marketHasIngredient); if (marketHasIngredient) { Ingredient currentIngredient = Ingredient.Definitions[ingredientID]; Listing currentListing = currentMarket.Wares[ingredientID]; ingredientButton.buttonText.text = currentIngredient.name + " - " + currentListing.cost + "a" + "\n(x" + currentListing.quantity + " left)"; Color setColor = Color.black; if (currentListing.cost < currentIngredient.usualCost || currentListing.cost == currentIngredient.minCost) { ingredientButton.buttonText.text += " Cheap!"; setColor = Color.green; //Set green if good price } else if (currentListing.cost > currentIngredient.usualCost || currentListing.cost == currentIngredient.maxCost) { ingredientButton.buttonText.text += " Pricy!"; setColor = Color.red; //Set red for bad price } ingredientButton.buttonText.color = setColor; } button.interactable = Engine.CanBuyIngredientFromCurrentMarket(ingredientID); } //Update selection of scrolls foreach (ButtonBuyScroll scrollButton in MarketPurchaseScrollButtons) { scrollButton.gameObject.SetActive(false); } int currentButtonPosition = 0; foreach (KeyValuePair <SpellID, Listing> scrollListings in currentMarket.Scrolls) //go through each of the market's scrolls { if (MarketPurchaseScrollButtons.Length > currentButtonPosition) //there's more scrolls to show { MarketPurchaseScrollButtons[currentButtonPosition].gameObject.SetActive(true); ButtonBuyScroll scrollButton = MarketPurchaseScrollButtons[currentButtonPosition]; scrollButton.mySpell = scrollListings.Key; Button button = scrollButton.GetComponent <Button>(); button.interactable = Engine.CanBuySpellFromCurrentMarket(scrollListings.Key); Spell scrollSpell = Spell.Definitions[scrollListings.Key]; //Button Icon scrollButton.icon.sprite = scrollSpell.sprite; //Button Text List <string> effectNames = new List <string>(); foreach (SpellEffect effect in scrollSpell.EffectsProduced) { effectNames.Add("" + effect); } scrollButton.buttonText.text = scrollSpell.name + " - " + currentMarket.Scrolls[scrollListings.Key].cost + "a" + "\n(" + Util.OxfordList(effectNames, true, false) + ")"; //+ (currentMarket.Scrolls[scrollListings.Key].quantity > 1 ? "( x" + currentMarket.Scrolls[scrollListings.Key].quantity + " left)" : ""); currentButtonPosition++; } } }
void AddWares(IngredientID ingr, int maxQuantity) { Wares.Add(ingr, new Listing(Ingredient.Definitions[ingr].usualCost, maxQuantity)); Debug.Log("Adding " + ingr); }
public Ingredient(IngredientID id) { this.id = id; }
//add an ingredient to the pot public void AddIngredient(IngredientID id) { ingredients[(int)id] += 1; numItems += 1; }