private void CreateHarvestState() { _harvestState = (fsm, fsmGameObject) => { // target herb is null... if (Target == null) { Herb herb = FindObjectOfType <Herb>(); if (herb == null) { fsm.PopState(); fsm.PushState(_idleState); return; } Target = herb.gameObject; } // target too far... if ((Target.transform.position - transform.position).magnitude > MaxTargetRange) { fsm.PushState(_moveState); } else { Destroy(Target); BackPack++; fsm.PopState(); fsm.PushState(_idleState); } }; }
public static Herb Factory(int cellID, Herbs type) { Herb herb = Herb.Factory(type); herb.Cell = Cell.FromId(cellID); return(herb); }
public static void TriggerHerbUseUI(Herb herb) { if (HerbUseUI != null) { HerbUseUI(herb); } }
public EatHerbBehaviour(Farmer farmer) { Update = () => { if (_target == null) { _target = null; foreach (var keyValuePair in farmer.Data) { if (keyValuePair.Key.Equals("target")) { _target = keyValuePair.Value as Herb; break; } } if (_target == null) { return(Status.Failure); } } GameObject.Destroy(_target.gameObject); farmer.Data.Clear(); _target = null; return(Status.Success); }; }
public IActionResult ApplyEditingHerb(Herb herb) { _db.Herb.Update(herb); _db.SaveChanges(); return(RedirectToAction("HerbsList", "Home")); }
static void Main(string[] args) { var elephant = new Elephant(); var bird = new Bird(); var employee = new Employee(23, "Tom"); var visitor = new Visitor(15, "Bill"); employee.GoToTheZoo(); visitor.GoToTheZoo(); var herb = new Herb(); var birdAviary = new Aviary(); var elephantAviery = new Aviary(); birdAviary.PlaceHerb(herb); birdAviary.PlaceAnimal(bird); elephantAviery.PlaceAnimal(elephant); Console.WriteLine(birdAviary.GetStatus()); employee.FeedAnimal(elephant); employee.FeedAnimal(bird); visitor.Observe(elephant); visitor.Observe(bird); }
private void LoadHerbList() { Herb.Load(); foreach (string mail in Herb.GetList()) { AddHerb(mail); } }
public IActionResult AddHerb(Herb herb) { if (ModelState.IsValid) { _db.Herb.Add(herb); _db.SaveChanges(); } return(RedirectToAction("HerbsList", "Home")); }
private void SaveHerbList() { Herb.Clear(); foreach (Node node in ListHerbItems.Nodes) { Herb.AddHerb(node.Tag.ToString()); } Herb.Save(); }
public void ShowHerbUseActions(Herb item) { herb = item; if (!canUseMoveItems) { freeMoveBtn.interactable = false; } else { } HerbUsePanel.SetActive(true); }
protected void OnDestroy() { if (quitting) { return; } if (GameManager.instance.CurrentPlayer == GameManager.instance.MainHero) { Herb.Factory(Cell.Index); } base.OnDestroy(); }
public static Herb Factory(Herbs type) { herbType = type; GameObject herbGo = PhotonNetwork.Instantiate("Prefabs/Tokens/" + herbType, Vector3.zero, Quaternion.identity, 0); token = herbGo; Herb herb = herbGo.GetComponent <Herb>(); herb.Cell = null; if (type == Herbs.Herb3) { herb.maxUse = 3; } else { herb.maxUse = 4; } return(herb); }
void Awake() { HerbUsePanel = transform.Find("Herb Use UI").gameObject; HerbUsePanelTitle = HerbUsePanel.transform.Find("Panel Title").GetComponent <Text>(); HerbUsePanelDesc = HerbUsePanel.transform.Find("Panel Description").GetComponent <Text>(); HerbUsePanelTitle.text = "With the medicinal herb, you can either increase your willpoints or get free moves."; HerbUsePanelDesc.text = "Herb Action"; herb = null; cancelBtn = HerbUsePanel.transform.Find("Cancel Button").GetComponent <Button>(); cancelBtn.onClick.AddListener(delegate { changeHerbUsage(); HideHerbUse(); }); willpowerBtn = HerbUsePanel.transform.Find("WillPower Button").GetComponent <Button>(); willpowerBtn.onClick.AddListener(delegate { clickWillpower(); }); freeMoveBtn = HerbUsePanel.transform.Find("Free Move Button").GetComponent <Button>(); freeMoveBtn.onClick.AddListener(delegate { EventManager.TriggerFreeMove(this.herb); HideHerbUse(); }); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Herb herbs = db.Herbs.Find(id); if (herbs == null) { return(HttpNotFound()); } // showing the navigation map using the bread crumbs. BreadCrumb.Clear(); BreadCrumb.Add(Url.Action("Index", "Home"), "Home"); BreadCrumb.Add(Url.Action("ReduceFoodWaste", "Home"), "Reduce Food Waste"); BreadCrumb.Add(Url.Action("Index", "Herbs"), "Grow Your Own Herb"); BreadCrumb.Add("", herbs.Herb_Categories); return(View(herbs)); }
public new static Item Create(Floor floor, Cell cell, char data) { var equipment = Equipment.Create(floor, cell, data); if (equipment != null) { return(equipment); } var scroll = Scroll.Create(floor, cell, data); if (scroll != null) { return(scroll); } var wand = Wand.Create(floor, cell, data); if (wand != null) { return(wand); } var pot = Pot.Create(floor, cell, data); if (pot != null) { return(pot); } var herb = Herb.Create(floor, cell, data); if (herb != null) { return(herb); } if (!IDs.Contains(data)) { return(null); } return(new Item(floor, cell, data)); }
public WalkToHerbBehaviour(Farmer farmer) { //Initialize = () => //{ // _target = null; //}; Update = () => { if (_target == null) { _target = null; foreach (var keyValuePair in farmer.Data) { if (keyValuePair.Key.Equals("target")) { _target = keyValuePair.Value as Herb; break; } } if (_target == null) { return(Status.Failure); } } if (!farmer.MoveTo(_target.transform.position, farmer.MoveSpeed)) { return(Status.Running); } return(Status.Success); }; Terminate = () => { _target = null; }; }
public void EatBerry(string berryType) { if (!isServer) CmdEatBerry(berryType); Herb berry = new Herb(); berry.ChangeProperties(berryType, this); berry.EatIt(this); }
public Herb(Herb copyFrom) : base(copyFrom) { healPower = copyFrom.healPower; }
public static GameObject ReturnShoppingObject(RestockItem rItem, SimDescription actor, StoreSetRegister register) { GameObject o = null; bool keepLooping = true; switch (rItem.info.Type) { case ItemType.Herb: case ItemType.Ingredient: foreach (KeyValuePair <string, List <StoreItem> > kvp in Grocery.mItemDictionary) { foreach (StoreItem item in kvp.Value) { if (item.Name.Equals(rItem.info.Name)) { keepLooping = false; IngredientData data = (IngredientData)item.CustomData; if (rItem.info.Type == ItemType.Ingredient) { o = Ingredient.Create(data); } else { o = Herb.Create(data); //PlantableNonIngredientData data = (PlantableNonIngredientData)item.CustomData; //o = (GameObject)PlantableNonIngredient.Create(data); } break; } } if (!keepLooping) { break; } } break; case ItemType.Fish: o = Fish.CreateFishOfRandomWeight(rItem.info.FType); break; case ItemType.Craftable: break; case ItemType.Gem: case ItemType.Metal: o = (GameObject)RockGemMetalBase.Make(rItem.info.RockData, false); break; case ItemType.Nectar: NectarBottle bottle = (NectarBottle)GlobalFunctions.CreateObjectOutOfWorld("NectarBottle"); NectarBottleObjectInitParams nectarBottleObjectInitParams = bottle.CreateAncientBottle(rItem.info.NectarAge, rItem.info.Price); if (nectarBottleObjectInitParams != null) { bottle.mBottleInfo.FruitHash = nectarBottleObjectInitParams.FruitHash; bottle.mBottleInfo.Ingredients = nectarBottleObjectInitParams.Ingredients; bottle.mBottleInfo.Name = rItem.info.Name; //nectarBottleObjectInitParams.Name; bottle.mDateString = nectarBottleObjectInitParams.DateString; bottle.mBottleInfo.DateNum = nectarBottleObjectInitParams.DateNum; bottle.mBaseValue = rItem.info.Price; // nectarBottleObjectInitParams.BaseValue; bottle.ValueModifier = (int)(nectarBottleObjectInitParams.CurrentValue - rItem.info.Price); bottle.mBottleInfo.mCreator = nectarBottleObjectInitParams.Creator; bottle.mBottleInfo.NectarQuality = Sims3.Gameplay.Objects.Quality.Neutral; //NectarBottle.GetQuality((float)rItem.info.Price); bottle.mBottleInfo.MadeByLevel10Sim = nectarBottleObjectInitParams.MadeByLevel10Sim; bottle.UpdateVisualState(); } o = bottle; break; case ItemType.AlchemyPotion: foreach (AlchemyRecipe recipe in AlchemyRecipe.GetAllAwardPotionRecipes()) { if (rItem.info.Name.Equals(recipe.Name)) { string[] array = new string[] { recipe.Key }; AlchemyRecipe randomAwardPotionRecipe = AlchemyRecipe.GetRandomAwardPotionRecipe(); PotionShopConsignmentRegister.PotionShopConsignmentRegisterData potionShopConsignmentRegisterData = new PotionShopConsignmentRegister.PotionShopConsignmentRegisterData(); potionShopConsignmentRegisterData.mParameters = array; potionShopConsignmentRegisterData.mObjectName = randomAwardPotionRecipe.MedatorName; potionShopConsignmentRegisterData.mGuid = potionShopConsignmentRegisterData.mObjectName.GetHashCode(); potionShopConsignmentRegisterData.mSellerAge = CASAgeGenderFlags.None; potionShopConsignmentRegisterData.mWeight = 100f; potionShopConsignmentRegisterData.mSellPriceMinimum = 0.75f; potionShopConsignmentRegisterData.mSellPriceMaximum = 1.25f; potionShopConsignmentRegisterData.mDepreciationAgeMinimum = 0; potionShopConsignmentRegisterData.mDepreciationAgeMaximum = 5; potionShopConsignmentRegisterData.mLifespan = 3f; string text = string.Empty; if (!string.IsNullOrEmpty(randomAwardPotionRecipe.CustomClassName)) { text = randomAwardPotionRecipe.CustomClassName; } else { text = "Sims3.Gameplay.Objects.Alchemy.AlchemyPotion"; } potionShopConsignmentRegisterData.mScriptClass = text; potionShopConsignmentRegisterData.mIsRotatable = true; PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData potionShopConsignmentRegisterObjectData2 = PotionShopConsignmentRegister.PotionShopConsignmentRegisterObjectData.Create(potionShopConsignmentRegisterData); potionShopConsignmentRegisterObjectData2.ShowTooltip = true; o = (GameObject)potionShopConsignmentRegisterObjectData2.mObject; break; } } break; case ItemType.Bug: Terrarium t = Terrarium.Create(rItem.info.BugType); if (t != null) { t.StartVfx(); } o = t; break; case ItemType.Food: int servingPrice = 25; if (register != null) { servingPrice = register.Info.ServingPrice; } IFoodContainer container = rItem.info.cookingProcess.Recipe.CreateFinishedFood(rItem.info.cookingProcess.Quantity, rItem.info.cookingProcess.Quality); if (rItem.info.cookingProcess.Quantity == Recipe.MealQuantity.Group) { ((ServingContainerGroup)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice * ((ServingContainerGroup)container).mNumServingsLeft); ((ServingContainerGroup)container).RemoveSpoilageAlarm(); } else { ((ServingContainerSingle)container).mPurchasedPrice = StoreHelperClass.ReturnPriceByQuality(rItem.info.cookingProcess.Quality, servingPrice); ((ServingContainerSingle)container).RemoveSpoilageAlarm(); } o = (GameObject)container; break; case ItemType.Flowers: o = Wildflower.CreateWildflowerOfType(rItem.info.TypeOfWildFlower, Wildflower.WildflowerState.InVase); break; case ItemType.BookAlchemyRecipe_: case ItemType.BookComic_: case ItemType.BookFish_: case ItemType.BookGeneral_: case ItemType.BookRecipe_: case ItemType.BookSkill_: case ItemType.BookToddler_: case ItemType.SheetMusic_: case ItemType.AcademicTextBook_: foreach (KeyValuePair <string, List <StoreItem> > kvp in Bookstore.sItemDictionary) { foreach (StoreItem item in kvp.Value) { if (item.Name.Equals(rItem.info.Name)) { keepLooping = false; if (rItem.info.Type == ItemType.BookGeneral_) { o = (GameObject)BookGeneral.CreateOutOfWorld(item.CustomData as BookGeneralData); } if (rItem.info.Type == ItemType.BookSkill_) { o = (GameObject)BookSkill.CreateOutOfWorld(item.CustomData as BookSkillData); } if (rItem.info.Type == ItemType.BookRecipe_) { o = (GameObject)BookRecipe.CreateOutOfWorld(item.CustomData as BookRecipeData); } if (rItem.info.Type == ItemType.SheetMusic_) { o = (GameObject)SheetMusic.CreateOutOfWorld(item.CustomData as SheetMusicData); } if (rItem.info.Type == ItemType.BookToddler_) { o = (GameObject)BookToddler.CreateOutOfWorld(item.CustomData as BookToddlerData); } if (rItem.info.Type == ItemType.BookFish_) { o = (GameObject)BookFish.CreateOutOfWorld(item.CustomData as BookFishData); } if (rItem.info.Type == ItemType.BookAlchemyRecipe_) { o = (GameObject)BookAlchemyRecipe.CreateOutOfWorld(item.CustomData as BookAlchemyRecipeData); } if (rItem.info.Type == ItemType.AcademicTextBook_) { o = (GameObject)AcademicTextBook.CreateOutOfWorld(item.CustomData as AcademicTextBookData, actor); } if (rItem.info.Type == ItemType.BookComic_) { o = (GameObject)BookComic.CreateOutOfWorld(item.CustomData as BookComicData); } break; } } if (!keepLooping) { break; } } break; case ItemType.JamJar: JamJar jamJar = GlobalFunctions.CreateObjectOutOfWorld("canningJarJam", ProductVersion.Store) as JamJar; if (jamJar != null) { Type tInfo = jamJar.GetType(); BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; FieldInfo ingredientDataField = tInfo.GetField("mData", flags); FieldInfo ingredientKeyField = tInfo.GetField("mIngredientKey", flags); FieldInfo qualityField = tInfo.GetField("mQuality", flags); FieldInfo preservesField = tInfo.GetField("mIsPreserves", flags); MethodInfo materialStateMethod = tInfo.GetMethod("SetMaterialState", flags); ingredientDataField.SetValue(jamJar, rItem.info.IngData); ingredientKeyField.SetValue(jamJar, rItem.info.IngredientKey); qualityField.SetValue(jamJar, rItem.info.JamQuality); preservesField.SetValue(jamJar, rItem.info.JamIsPreserve); materialStateMethod.Invoke(jamJar, null); } o = (GameObject)jamJar; break; default: break; } return(o); }
public async Task <IActionResult> Edit(int id, [Bind("Name,Calories,Place_of_Origin")] Seasoning seasoning, Herb herb) { if (id != herb.Id) { return(NotFound()); } if (ModelState.IsValid) { try { seasoning.Id = id; _context.Seasoning.Update(seasoning); _context.Update(herb); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HerbExists(herb.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Id"] = new SelectList(_context.Ingredient, "Id", "Id", herb.Id); return(View(herb)); }
public static Herb Factory(int cellID) { return(Herb.Factory(cellID, Herbs.Herb3)); }
public static void Main() { bool play = false; Console.WriteLine("Let's go on a herb adventure! Do you want to play?"); string response = Console.ReadLine(); if (response == "yes") { play = true; Console.WriteLine("Great! Let's get growing! What would you like to name your plant?"); } else { play = false; Console.WriteLine("Too bad! See you later!"); } string myName = Console.ReadLine(); Herb myHerb = new Herb(myName, 1, 0, 1); Console.WriteLine("Your plant " + myHerb.Name + " is ready for you to take care of it!"); while (play == true) { Console.WriteLine(myHerb.Name + " is " + myHerb.Height + " inch tall and has " + myHerb.Flowers + " flowers. It has " + myHerb.Health + " health points."); Console.WriteLine("What would you like to do? Your action choices are: 'water', 'sun', 'feed', or 'exit'."); string action = Console.ReadLine(); if (action == "water") { myHerb.Height = myHerb.Height + 1; Console.WriteLine(myHerb.Name + " is " + myHerb.Height); } else if (action == "sun") { myHerb.Flowers = myHerb.Flowers + 1; Console.WriteLine(myHerb.Name + " has " + myHerb.Flowers + " flowers."); } else if (action == "feed") { myHerb.Health = myHerb.Health + 1; Console.WriteLine(myHerb.Name + " has " + myHerb.Health + " health points."); } else if (myHerb.Health <= 0) { Console.WriteLine("Uh-oh! Your plant died!"); play = false; } else if (action == "exit") { Console.WriteLine("Hope you enjoyed growing!"); play = false; } else { Console.WriteLine("Sorry I didn't understand your input"); } Events myEvent = new Events(); myEvent.Disaster(); if (myEvent.WindStorm == true) { myHerb.Height = myHerb.Height - 1; } else if (myEvent.AphidAttack == true) { myHerb.Health = myHerb.Health - 1; } else if (myEvent.SlugBite == true) { myHerb.Flowers = myHerb.Flowers - 1; } else { myHerb.Health = myHerb.Health + 1; } } }
public async Task <IActionResult> Create([Bind("Name,Calories,Place_of_Origin")] Seasoning seasoning, Herb herb) { if (ModelState.IsValid) { _context.Seasoning.Add(seasoning); herb.Id = seasoning.Id; _context.Add(herb); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Id"] = new SelectList(_context.Seasoning, "Id", "Id", herb.Id); return(View(herb)); }
public void PlaceHerb(Herb herb) { _herb = herb; }
public void HideHerbUse() { this.herb = null; freeMoveBtn.interactable = true; HerbUsePanel.SetActive(false); }
public void pickupBerry(Herb.Condition value) { if (isLocalPlayer) { int quality = 0; if (value == Herb.Condition.Random) quality = inventory.pickupBerry(Random.Range(0, 100), GetComponent<PlayerStats>().Wisdom); else quality = inventory.pickupBerry(value); veryBerryThings(quality); } }
public int pickupBerry(Herb.Condition cond) { int type = 0; switch(cond) { case (Herb.Condition.Regeneration): berryG++; transform.FindChild("BerryG").GetComponentInChildren<Text>().text = "" + berryGCount; type = 1; break; case (Herb.Condition.Degenration): berryB++; transform.FindChild("BerryB").GetComponentInChildren<Text>().text = "" + berryBCount; type = 2; break; default: berryR++; transform.FindChild("BerryR").GetComponentInChildren<Text>().text = "" + berryRCount; break; } return type; }
public static Herb Factory() { return(Herb.Factory(Herbs.Herb3)); }
public IActionResult AddDrug(DrugAndHerbViewModel drugAndHerbs, IEnumerable <string> TBoxes) { var herbsList = new List <Herb>(); foreach (var str in TBoxes) { if (!string.IsNullOrEmpty(str)) { var herb = new Herb { Name = str.Trim(), Description = "", Species = "" }; herbsList.Add(herb); if (_db.Herb.FirstOrDefault(h => string.Equals(h.Name, herb.Name, StringComparison.CurrentCultureIgnoreCase)) == null) { _db.Herb.Add(herb); } } } var drugToAdd = drugAndHerbs.Drug; _db.Drug.Add(drugToAdd); _db.SaveChanges(); var drugToC = _db.Drug.OrderBy(d => d.DrugId).LastOrDefault(); var herbsToC = new List <Herb>(); foreach (var h in herbsList) { herbsToC.Add(_db.Herb.Single(p => p.Name == h.Name)); } if (herbsToC.Count != 0) { foreach (var herb in herbsToC) { var compound = new Compound() { Drug = drugToC, Herb = herb, DrugId = drugToC.DrugId, HerbId = herb.HerbId }; _db.Compound.Add(compound); } } var drugchanges = new DrugChanges() { Date = DateTime.Now, DrugId = drugToC.DrugId, Drug = drugToC, Increasing = false, Quantity = drugToC.Quantity, SupplierName = "" }; _db.DrugChanges.Add(drugchanges); _db.SaveChanges(); return(RedirectToAction("DrugsList", "Home")); }
public override void DoJob() { base.DoJob(); int herbCount = 0; foreach (Item item in me.inventory) { if (item.type.Contains("Herb")) { herbCount++; } } // First, gather herbs for (int i = 0; i < timesToGather; i++) { if (herbCount >= maxHerbs) { me.Speak("I can't carry any more herbs in my bag."); //Debug.Log("maxHerbs: " + maxHerbs + " -- inventorySize: " + me.inventory.Count + " -- herbCount: " + herbCount); break; } // Determine what the citizen is trying to find, then calculate success chance based on that. The more potent the herb, the rarer it is. Herb toFind = new Herb(possibleHerbs[Random.Range(0, possibleHerbs.Count)]); int successChance = 60; if (toFind.healPower > 20) // Herbs with a healpower > 20 are considered "rare" and are more difficult to find. { successChance -= toFind.healPower; } // Success chance is influenced by jobskill. jobSkill > 50 makes it easier to find things, < 50 makes it more difficult. successChance += Mathf.RoundToInt((me.GetEffectiveJobSkill() - 50) * 0.8f); gc.LogMessage(me.myName + " searches the woods for some " + toFind.name + ".", "LGray"); // See if they're successful int searchRoll = Random.Range(0, 100); if (searchRoll < successChance) { me.Speak("Perfect. This is just what I was looking for!"); // Theoretically, I should be able to create a dictionary of dialogue for each race. me.inventory.Add(toFind); herbCount++; } else { me.Speak("Doesn't look like there's any " + toFind.name + " around..."); } } // If the citizen has at least 1 herb, a potion is made and the citizen gets paid. Potions can be made from up to timesToGather herbs. // Roll for # of herbs to use int herbsToUse = Random.Range(1, timesToGather + 1); foreach (Item item in me.inventory) { if (item.type.Contains("Herb")) { herbsToUse--; herbs.Add((Herb)item); } if (herbsToUse < 1) { break; } } if (herbs.Count > 0) { // Make the potion float potionPower = 0; foreach (Herb herb in herbs) { potionPower += herb.healPower; gc.LogMessage(me.commonName + " adds a " + herb.name + " to the brew.", "LGray"); me.inventory.Remove(herb); //Debug.Log("Added herb has healpower of " + herb.healPower); //herbs.RemoveAt(0); } // Add some additional healpower based on jobSkill int additionalPower = (me.GetEffectiveJobSkill() - 50) / 10; potionPower += additionalPower; // Base value of the potion is 3 gold, and increases as potionPower passes certain thresholds. int potionValue = 3; string potionType = "Crude"; if (potionPower >= 15) { potionValue += 2; potionType = "Basic"; } if (potionPower >= 25) { potionValue += 2; potionType = "Strong"; } if (potionPower >= 40) { potionValue += 3; potionType = "Potent"; } // A potent potion is worth 10 gold. //Debug.Log(me.myName + "'s Potion: \npotionPower " + potionPower + "\npotionValue " + potionValue + "\nadditionalPower: " + additionalPower); gc.LogMessage(me.myName + " has brewed a " + potionType + " Healing Potion, earning " + potionValue + " gold.", "LGray"); me.GetPaid(potionValue, true); } else { me.Speak("Hmm, I don't have anything to make potions with."); } herbs.Clear(); }