private static void OnEatComplete(Edible edible) { if ((Object)edible != (Object)null) { int num = 0; float unitsConsumed = edible.unitsConsumed; int num2 = Mathf.FloorToInt(unitsConsumed); float num3 = unitsConsumed % 1f; if (Random.value < num3) { num2++; } for (int i = 0; i < num2; i++) { if (Random.value < SEEDS_PER_FRUIT_CHANCE) { num++; } } if (num > 0) { Vector3 pos = edible.transform.GetPosition() + new Vector3(0f, 0.05f, 0f); pos = Grid.CellToPosCCC(Grid.PosToCell(pos), Grid.SceneLayer.Ore); GameObject gameObject = GameUtil.KInstantiate(Assets.GetPrefab(new Tag("PrickleFlowerSeed")), pos, Grid.SceneLayer.Ore, null, 0); PrimaryElement component = edible.GetComponent <PrimaryElement>(); PrimaryElement component2 = gameObject.GetComponent <PrimaryElement>(); component2.Temperature = component.Temperature; component2.Units = (float)num; gameObject.SetActive(true); } } }
public void Sim1000ms(float dt) { if (!(this.IsOperational)) { return; } if (this.AmountStored < this.UserMaxCapacity) { Debug.Log("UserMaxCapacity: " + this.UserMaxCapacity.ToString()); Debug.Log("AmountStored: " + this.AmountStored.ToString()); Debug.Log("IsFull: " + this.filteredStorage.IsFull().ToString()); List <Tag> acceptedTags = this.treeFilterable.AcceptedTags; foreach (Tag tag in acceptedTags) { GameObject myFood = Edible.Instantiate(tag.Prefab()); myFood.SetActive(true); storage.Store(myFood, false, false, false, false); storage.Drop(myFood); storage.Store(myFood, false, false, false, true); } } //this.filteredStorage.FilterChanged(); this.UpdateLogicCircuit(); return; }
static void Main(string[] args) { Animal[] animals = new Animal[2]; animals[0] = new Tiger(); animals[1] = new Chicken(); foreach (Animal animal in animals) { Console.WriteLine(animal.MakeSound()); if (animal is Chicken) { Edible edibler = (Chicken)animal; Console.WriteLine(edibler.HowToEat()); } } Fruit[] fruits = new Fruit[2]; fruits[0] = new Apple(); fruits[1] = new Orange(); foreach (Fruit fruit in fruits) { Console.WriteLine(fruit.HowToEat()); } }
// Start is called before the first frame update void Start() { // Gets number of enemies text script _enemyTextScript = FindObjectOfType <EnemyTextScript>(); // Gets components _edible = GetComponent <Edible>(); _harmful = GetComponent <Harmful>(); // Sets up events _edible.CaughtEvent = () => { // Destroy horizontal movement Destroy(GetComponent <HorizontalMovement>()); // Stops us from being harmful _harmful.enabled = false; // Deduct enemy count if (_enemyTextScript != null) { _enemyTextScript.DeductCount(); } // Disables exploder, if we have one Exploder exploder = GetComponent <Exploder>(); if (exploder != null) { exploder.enabled = false; } }; _edible.EatenEvent = () => { }; }
public void Eat(Edible edible) { if (!edible.DestroyOnEat) { ShowWin(); } PlayRandomSound(eats); edible.Eat(); if (!edible.isPoison()) { Hunger += edible.HungerRestored; } else { Invoke("Poisoned", 0.5f); Invoke("Poisoned", 0.9f); } if (Hunger > MaxHunger) { Hunger = MaxHunger; } }
public static GameObject ExtendEntityToFood(GameObject template, EdiblesManager.FoodInfo foodInfo) { template.AddOrGet <EntitySplitter>(); if (foodInfo.CanRot) { Rottable.Def def = template.AddOrGetDef <Rottable.Def>(); def.rotTemperature = foodInfo.RotTemperature; def.spoilTime = foodInfo.SpoilTime; def.staleTime = foodInfo.StaleTime; CreateAndRegisterCompostableFromPrefab(template); } KPrefabID component = template.GetComponent <KPrefabID>(); component.AddTag(GameTags.PedestalDisplayable, false); if (foodInfo.CaloriesPerUnit > 0f) { Edible edible = template.AddOrGet <Edible>(); edible.FoodInfo = foodInfo; component.instantiateFn += delegate(GameObject go) { go.GetComponent <Edible>().FoodInfo = foodInfo; }; GameTags.DisplayAsCalories.Add(component.PrefabTag); } else { component.AddTag(GameTags.CookingIngredient, false); template.AddOrGet <HasSortOrder>(); } return(template); }
public string GetProductInfo(Product product) { switch (product.productType) { case Product.type_.storageJar: StorageJar jar = (StorageJar)product; return("Strain: " + jar.GetStrain().name); case Product.type_.glassBong: case Product.type_.acrylicBong: Bong bong = (Bong)product; return("Height: " + bong.height); case Product.type_.glassPipe: case Product.type_.acrylicPipe: Pipe pipe = (Pipe)product; return("Length: " + pipe.length); case Product.type_.rollingPaper: RollingPaper paper = (RollingPaper)product; return(paper.paperType.ToString()); case Product.type_.edible: Edible edible = (Edible)product; return(edible.edibleType.ToString()); case Product.type_.box: StorageBox box = (StorageBox)product; return("Products: " + box.products.Count); } return("ProductType"); }
public ActionResult Create(FormCollection collection) { try { EdibleDataLayer edbldtcx = new EdibleDataLayer(); Edible store = new Edible { Name = Convert.ToString(collection["Name"]), Email = Convert.ToString(collection["Email"]), Zipcode = Convert.ToString(collection["Zipcode"]), ClosingTime = DateTime.Now }; Random rnd = new Random(); int minute = rnd.Next(1, 60); DateTime dt = new DateTime(store.ClosingTime.Year, store.ClosingTime.Month, store.ClosingTime.Day, rnd.Next(18, 23), minute, 0); store.ClosingTime = dt; //store.ClosingTime.AddHours(8); //store.ClosingTime.AddMinutes(minute); Console.WriteLine(store.ClosingTime); // TODO: Add insert logic here edbldtcx.AddStore(store); return(RedirectToAction("Store")); } catch { return(View()); } }
public static void SpawnFruit(Crop inst, string fruitId, int amount) { if (inst == null || string.IsNullOrEmpty(fruitId)) { return; } GameObject gameObject = Scenario.SpawnPrefab(Grid.PosToCell(inst.gameObject), 0, 0, fruitId, Grid.SceneLayer.Ore); if (gameObject != null) { float y = 0.75f; gameObject.transform.SetPosition(gameObject.transform.GetPosition() + new Vector3(0.0f, y, 0.0f)); gameObject.SetActive(true); PrimaryElement component1 = gameObject.GetComponent <PrimaryElement>(); component1.Units = amount; component1.Temperature = inst.gameObject.GetComponent <PrimaryElement>().Temperature; Edible component2 = gameObject.GetComponent <Edible>(); if ((bool)component2) { ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, component2.Calories, StringFormatter.Replace(STRINGS.UI.ENDOFDAYREPORT.NOTES.HARVESTED, "{0}", component2.GetProperName()), STRINGS.UI.ENDOFDAYREPORT.NOTES.HARVESTED_CONTEXT); } } else { Debug.LogWarning("Tried to spawn an invalid crop prefab: " + fruitId); } }
static void Main(string[] args) { /* Animal[] animals = new Animal[2]; * animals[0] = new Tiger(); * animals[1] = new Chicken(); * * foreach (Animal animal in animals) * { * Console.WriteLine(animal.MakeSound()); * }*/ Animal[] animals = new Animal[2]; animals[0] = new Tiger(); animals[1] = new Chicken(); foreach (Animal animal in animals) { Console.WriteLine(animal.MakeSound()); if (animal is Chicken) { Edible edibler = (Chicken)animal; Console.WriteLine(edibler.HowToEat()); } } }
public float CountRations(Dictionary <string, float> unitCountByFoodType, bool excludeUnreachable = true) { float num = 0f; List <Pickupable> pickupables = WorldInventory.Instance.GetPickupables(GameTags.Edible); if (pickupables != null) { foreach (Pickupable item in pickupables) { if (!item.KPrefabID.HasTag(GameTags.StoredPrivate)) { Edible component = item.GetComponent <Edible>(); num += component.Calories; if (unitCountByFoodType != null) { if (!unitCountByFoodType.ContainsKey(component.FoodID)) { unitCountByFoodType[component.FoodID] = 0f; } Dictionary <string, float> dictionary; string foodID; (dictionary = unitCountByFoodType)[foodID = component.FoodID] = dictionary[foodID] + component.Units; } } } return(num); } return(num); }
// // We ARE wall-sliding! // if (isWallSliding()) { // // Should we stop wall-sliding?? // if (wallSlideDir==-1 && !onSurfaces[Sides.L]) { // StopWallSlide(); // } // else if (wallSlideDir==1 && !onSurfaces[Sides.R]) { // StopWallSlide(); // } // } // // We're NOT wall-sliding... // else { // // Should we START wall-sliding?? // if (!feetOnGround() && !isPlunging) { // if (onSurfaces[Sides.L] && vel.x<-0.001f) { // StartWallSlide(-1); // } // else if (onSurfaces[Sides.R] && vel.x>0.001f) { // StartWallSlide(1); // } // } // } // private void OnTriggerExit2D(Collider2D col) { // Collidable collidable = col.GetComponent<Collidable>(); // if (collidable != null) { // // } // } public void OnTouchEdible(Edible edible) { ediblesHolding.Add(edible); edible.OnPlayerPickMeUp(this); if (MayEatEdibles()) { EatEdiblesHolding(); } }
public void eat() { Edible e = MapManager.getEdibleAt(transform.position); if (e) { food.restore(e.eat()); } }
void OnTriggerEnter2D(Collider2D other) { Edible edible = other.GetComponent <Edible>(); if (edible != null) { health += edible.healthValue * scoreManager.multiplier; } }
private void OnEat(object data) { Edible edible = (Edible)data; if ((UnityEngine.Object)edible != (UnityEngine.Object)null) { base.smi.sm.bingeremaining.Set(Mathf.Max(0f, base.smi.sm.bingeremaining.Get(base.smi) - edible.unitsConsumed), base.smi); } }
public async Task <ActionResult <Edible> > PostEdible(EdibleDto edible) { //Create a new edible value based on the DTO provided Edible newEdible = new Edible(); newEdible.EdibleS = edible.info; _context.Edibles.Add(newEdible); await _context.SaveChangesAsync(); return(CreatedAtAction("GetEdible", new { id = newEdible.EdibleID }, newEdible)); }
public void UpdatePortrait(GameObject target) { KSelectable component = target.GetComponent <KSelectable>(); if (!((UnityEngine.Object)component == (UnityEngine.Object)null)) { TabTitle.portrait.ClearPortrait(); Building component2 = component.GetComponent <Building>(); if ((bool)component2) { Sprite sprite = null; sprite = component2.Def.GetUISprite("ui", false); if ((UnityEngine.Object)sprite != (UnityEngine.Object)null) { TabTitle.portrait.SetPortrait(sprite); return; } } MinionIdentity component3 = target.GetComponent <MinionIdentity>(); if ((bool)component3) { TabTitle.SetPortrait(component.gameObject); } else { Edible component4 = target.GetComponent <Edible>(); if ((UnityEngine.Object)component4 != (UnityEngine.Object)null) { KBatchedAnimController component5 = component4.GetComponent <KBatchedAnimController>(); Sprite uISpriteFromMultiObjectAnim = Def.GetUISpriteFromMultiObjectAnim(component5.AnimFiles[0], "ui", false, string.Empty); TabTitle.portrait.SetPortrait(uISpriteFromMultiObjectAnim); } else { PrimaryElement component6 = target.GetComponent <PrimaryElement>(); if ((UnityEngine.Object)component6 != (UnityEngine.Object)null) { TabTitle.portrait.SetPortrait(Def.GetUISpriteFromMultiObjectAnim(ElementLoader.FindElementByHash(component6.ElementID).substance.anim, "ui", false, string.Empty)); } else { CellSelectionObject component7 = target.GetComponent <CellSelectionObject>(); if ((UnityEngine.Object)component7 != (UnityEngine.Object)null) { string animName = (!component7.element.IsSolid) ? component7.element.substance.name : "ui"; Sprite uISpriteFromMultiObjectAnim2 = Def.GetUISpriteFromMultiObjectAnim(component7.element.substance.anim, animName, false, string.Empty); TabTitle.portrait.SetPortrait(uISpriteFromMultiObjectAnim2); } } } } } }
private void EatFood(GameObject obj, TargetEdible food) { if (food.Target != null && Vector3.Distance(obj.transform.position, food.Target.transform.position) <= 1.2f) { Edible pocky = food.Target.GetECSComponent <Edible>(); pocky.Active = false; EntityActionBuffer.Instance.ApplyComponentChanges(food.Target, pocky); Score score = obj.GetECSComponent <Score>(); score.Value += 1; EntityActionBuffer.Instance.ApplyComponentChanges(obj, score); } }
public void Eat(Edible food) { // Handle achieventment if(!achHungryPanda.HasAchieved()) { var goal = achHungryPanda.GetDefinitionValue<int>("goal").Value; var progress = achHungryPanda.GetProgessionValue<int>("count"); progress.Value += 1; if(progress.Value >= goal) achHungryPanda.Achieved(); } // Can only eat from storage, so dont need to remove from inventory this.lifeEnergy += food.RestoreAmount; }
public static Edible getEdibleAt(Vector2 position) { Edible retEdible = null; foreach (Edible e in edibles) { if ((Vector2)e.transform.position == position) { retEdible = e; } } return(retEdible); }
private Edible GetClosestEdible() { List <Edible> edibles = EdibleManager.GetInstance().GetAll(); Edible closestEdible = null; foreach (var edible in edibles) { if (closestEdible == null || DistanceTo(edible) < DistanceTo(closestEdible)) { closestEdible = edible; } } return(closestEdible); }
public static void OnDeathPost(MinionModifiers __instance) { int[] pos = getDropSpawnLocation(__instance.gameObject); foreach (int p in pos) { GameObject gameObject = Scenario.SpawnPrefab(p, 0, 0, "Meat", Grid.SceneLayer.Ore); gameObject.SetActive(true); Edible component2 = gameObject.GetComponent <Edible>(); if (component2 != null) { ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, component2.Calories, StringFormatter.Replace(UI.ENDOFDAYREPORT.NOTES.BUTCHERED, "{0}", gameObject.GetProperName()), UI.ENDOFDAYREPORT.NOTES.BUTCHERED_CONTEXT); } } }
public void RegisterRationsConsumed(Edible edible) { currentFrame.caloriesConsumed += edible.caloriesConsumed; if (!caloriesConsumedByFood.ContainsKey(edible.FoodInfo.Id)) { caloriesConsumedByFood.Add(edible.FoodInfo.Id, edible.caloriesConsumed); } else { Dictionary <string, float> dictionary; string id; (dictionary = caloriesConsumedByFood)[id = edible.FoodInfo.Id] = dictionary[id] + edible.caloriesConsumed; } }
public static Edible EdibleStringToEnum(string name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Edible string cannot be empty", nameof(name)); } Edible result = default; switch (name) { case "Buen comestible": result = Edible.BuenComestible; break; case "Tóxica": result = Edible.Toxica; break; case "Sin interés culinario": result = Edible.SinInteres; break; case "Comestible con precauciones": result = Edible.ComestibleConPrecaucion; break; case "Comestible pero peligrosa": result = Edible.ComestiblePeroPeligrosa; break; case "Comestible de calidad media": result = Edible.ComestibleCalidadMedia; break; case "Comestible de baja calidad": result = Edible.ComestibleBajaCalidad; break; case "Comestible dudoso, posible toxicidad": result = Edible.PosibleToxico; break; case "No comestible generalmente": result = Edible.NoComestible; break; } return(result); }
public static void OpdrachtR9_14() { Sandwich sub = new Sandwich(); Rectangle cerealBox = new Rectangle(5, 10, 20, 30); Edible e = null; e = sub; //sub = e; sub = (Sandwich)e; // sub = cerealBox; // e = cerealBox; e = (Edible)cerealBox; // e = (Rectangle)cerealBox; // e = (Rectangle)null; }
private void Create() { for (int i = 0; i < _number; i++) { //component Edible edible = new Edible(); //entity GameObject tmp = EntityActionBuffer.Instance.CreateEntity(_prefab); tmp.transform.position = GameMananger.RandomNavmeshLocation(40, tmp); //merging both EntityActionBuffer.Instance.AddComponent(tmp, edible); } }
public void CmdEatFood(GameObject food, NamedSlot fromSlot, bool isDrink) { if (!Validations.CanInteract(playerScript, NetworkSide.Server)) { return; } var slot = itemStorage.GetNamedItemSlot(fromSlot); if (slot.Item == null) { //Already been eaten or the food is no longer in hand return; } if (!Cooldowns.TryStartServer(playerScript, CommonCooldowns.Instance.Interaction)) { return; } Edible baseFood = food.GetComponent <Edible>(); if (isDrink) { SoundManager.PlayNetworkedAtPos("Slurp", transform.position); } else { SoundManager.PlayNetworkedAtPos("EatFood", transform.position); } PlayerHealth playerHealth = GetComponent <PlayerHealth>(); //FIXME: remove blood changes after TDM //and use this Cmd for healing hunger and applying //food related attributes instead: playerHealth.bloodSystem.BloodLevel += baseFood.healAmount; playerHealth.bloodSystem.StopBleedingAll(); Inventory.ServerDespawn(slot); GameObject leavings = baseFood.leavings; if (leavings != null) { leavings = Spawn.ServerPrefab(leavings).GameObject; Inventory.ServerAdd(leavings.GetComponent <Pickupable>(), slot); } }
public override void Update() { new EntityQuery() .With <Edible>() .ForEach(obj => { //check if food as been eaten Edible edible = obj.GetECSComponent <Edible>(); if (!edible.Active) { obj.transform.position = GameMananger.RandomNavmeshLocation(40f, obj); edible.Active = true; EntityActionBuffer.Instance.ApplyComponentChanges(obj, edible); } }); }
public void SingleEdibleRequestTest() { //ARRANGE var edible = new Edible(); //ACT edible = EdibleController.GetEdible("4KXM32V9YFC3G2EUNWP400000"); //ASSERT Assert.IsNotNull(edible); Assert.IsTrue(edible.IsValid()); Assert.IsTrue(edible.Name == "Soda - Girl Scout Cookies and Cream"); //OUTPUT Console.WriteLine("Edible: " + edible.Name); }
private void SpawnExtraMeat(object data) { if (onDeathDropID != string.Empty && onDeathDropCount > 0 && onDeathDropMultiplier > 0) { GameObject extraMeat = Scenario.SpawnPrefab(Grid.PosToCell(gameObject), 0, 0, onDeathDropID); extraMeat.SetActive(true); PrimaryElement component = extraMeat.GetComponent <PrimaryElement>(); component.Units = onDeathDropMultiplier * onDeathDropCount; component.Temperature = gameObject.GetComponent <PrimaryElement>().Temperature; Edible edible = extraMeat.GetComponent <Edible>(); if (edible) { ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, edible.Calories, StringFormatter.Replace(UI.ENDOFDAYREPORT.NOTES.BUTCHERED, "{0}", extraMeat.GetProperName()), UI.ENDOFDAYREPORT.NOTES.BUTCHERED_CONTEXT); } } }
public void CmdEatFood(GameObject food, NamedSlot fromSlot, bool isDrink) { if (!Validations.CanInteract(playerScript, NetworkSide.Server)) { return; } var slot = itemStorage.GetNamedItemSlot(fromSlot); if (slot.Item == null) { //Already been eaten or the food is no longer in hand return; } if (!Cooldowns.TryStartServer(playerScript, CommonCooldowns.Instance.Interaction)) { return; } Edible baseFood = food.GetComponent <Edible>(); if (isDrink) { SoundManager.PlayNetworkedAtPos("Slurp", transform.position); } else { SoundManager.PlayNetworkedAtPos("EatFood", transform.position); } Chat.AddActionMsgToChat(gameObject, $"You eat the {food.Item().ArticleName}.", $"{gameObject.Player().Name} eats the {food.Item().ArticleName}."); PlayerHealth playerHealth = GetComponent <PlayerHealth>(); Edible edible = food.GetComponent <Edible>(); playerHealth.Metabolism.AddEffect(new MetabolismEffect(edible.NutrientsHealAmount, 0, MetabolismDuration.Food)); Inventory.ServerDespawn(slot); GameObject leavings = baseFood.leavings; if (leavings != null) { leavings = Spawn.ServerPrefab(leavings).GameObject; Inventory.ServerAdd(leavings.GetComponent <Pickupable>(), slot); } }
IEnumerator shrink(float time, Edible toShrink) { isShrink = true; Vector3 originalScale = toShrink.transform.localScale; Vector3 destinationScale = new Vector3(0.1f,0.1f,0.1f); float currentTime = 0.0f; do { toShrink.transform.localScale = Vector3.Lerp(originalScale, destinationScale, currentTime / time); currentTime += Time.deltaTime; yield return null; } while (currentTime <= time); isShrink = false; toShrink.UseUp(originalScale); }
public Eat(Edible item) { this.item = item; }