public EatFoodTask(Character character, Node targetNode, IEdible food) { this.AddCommand(new MoveCommand(character.MotionComponent, targetNode.Position)); this.AddCommand(new RotateToCommand(character.MotionComponent, Utils.NodeAt(food.GetEdiblePosition()))); this.AddCommand(new WaitCommand(0.5f)); this.AddCommand(new EatCommand(character.HungerComponent, food)); }
IEnumerator EatCheck() { for (; ;) { yield return(null); Transform edibleTransform = _eatArea.GetClosestEdible(); if (edibleTransform == null) { continue; } IEdible edible = edibleTransform.GetComponent <IEdible>(); if (edible == null) { continue; } _objectiveManager.OnAteEdible(_player); edible.OnEat(); yield return(new WaitForSeconds(_eatCooldown)); } }
static void Main(string[] args) { //Test Animal 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) { IEdible edibler = (Chicken)animal; Console.WriteLine(edibler.HowToEat()); } } // Test Fruit Fruit[] fruits = new Fruit[2]; fruits[0] = new Orange(); fruits[1] = new Apple(); foreach (Fruit fruit in fruits) { Console.WriteLine(fruit.HowToEat()); } }
public override void Eat(IEdible food, int quantity) { if (quantity < 0) { throw new ArgumentOutOfRangeException("quantity", "Quantity cannot be negative!"); } if (food.FoodType == FoodType.Organic) { this.Health += food.HealthEffect * quantity; food.Quantity -= quantity; } else if (food.FoodType == FoodType.Meat) { if (this.Health >= food.HealthEffect * quantity) { this.Health -= food.HealthEffect * quantity; } else { this.Health = 0; } food.Quantity -= quantity; } else { throw new ArgumentException("The cow don't eat this food!", "food"); } }
public override void Eat(IEdible food, int quantity) { // TODO: How the f*****g pig eats. Not described. Kill the business analyst! // Try wit this: var eat = food.HealthEffect * 2 * quantity; this.Health += eat; }
private void OnTriggerEnter(Collider col) { IEdible edible = col.GetComponent <IEdible>(); if (edible != null && !_edibles.Contains(col.transform)) { _edibles.Add(col.transform); } }
private void OnTriggerEnter(Collider other) { IEdible edible = other.GetComponent <IEdible>(); if (other.gameObject.layer == GrabObject.GRABBEDLAYER && edible != null && !_currentEdibles.Contains(other.gameObject)) { _currentEdibles.Add(other.gameObject); } }
private void OnTriggerExit(Collider col) { IEdible edible = col.GetComponent <IEdible>(); if (edible != null && _edibles.Contains(col.transform)) { _edibles.Remove(col.transform); } }
private void OnCollisionEnter2D(Collision2D col) { IEdible edible = col.transform.GetComponent <IEdible>(); if (edible != null) { edible.OnEaten(); Grow(); } }
/// <summary> /// Make Pacman eat something and give him any relevant effects /// </summary> public void Eat(IEdible theEntity) { theEntity.GetEaten(); Sounds.Eat(); if (theEntity is BigDot) { itsPowerUpCounter += 14; } }
public override void Eat(IEdible food, int quantity) { if (IsAlive == true) { this.Health += (2 * food.HealthEffect)*3; } else { throw new InvalidOperationException("The swine is dead!"); } }
public override void Eat(IEdible food, int quantity) { if (food.FoodType == FoodType.Organic) { this.Health += food.HealthEffect * quantity; } else if (food.FoodType == FoodType.Meat) { this.Health -= food.HealthEffect * quantity; } }
public override void Eat(IEdible food, int quantity) { if (IsAlive == true) { this.Health += (2 * food.HealthEffect) * 3; } else { throw new InvalidOperationException("The swine is dead!"); } }
public override void Eat(IEdible food, int quantity) { if (food.Quantity >= quantity) { food.Quantity -= quantity; base.Health += food.HealthEffect*quantity*2; } else { throw new ArgumentException(); } }
public void Feed(Animal animal, IEdible edibleProduct, int productQuantity) { if (edibleProduct.Quantity >= productQuantity) { animal.Eat(edibleProduct, productQuantity); edibleProduct.Quantity -= productQuantity; } else { throw new ArgumentException("There is not enough quantity of the specified product."); } }
public override void Eat(IEdible food, int quantity) { switch (food.FoodType) { case FoodType.Meat: case FoodType.Organic: this.Health += 2 * food.HealthEffect * quantity; break; default: break; } }
private void Update() { for (int i = _currentEdibles.Count - 1; i >= 0; i--) { GameObject edibleObject = _currentEdibles[i]; if (edibleObject.layer != GrabObject.GRABBEDLAYER) { IEdible edible = edibleObject.GetComponent <IEdible>(); edible.OnEat(); _currentEdibles.RemoveAt(i); } } }
public override void Eat(IEdible food, int quantity) { if (food.Quantity < quantity) { throw new Exception("Food Quantity is not enough!"); } if (food.FoodType == FoodType.Organic) { this.Health += food.HealthEffect * quantity; } else if (food.FoodType == FoodType.Meat) { this.Health -= food.HealthEffect * quantity; } food.Quantity -= quantity; }
/// <summary> /// Eats both Organic and Meat food and gains twice the HealthEffect /// </summary> /// <param name="food"></param> /// <param name="quantity"></param> public override void Eat(IEdible food, int quantity) { switch (food.FoodType) { case FoodType.Organic: case FoodType.Meat: this.Health += 2 * food.HealthEffect * quantity; break; default: break; } }
public override void Eat(IEdible food, int quantity) { var eat = food.HealthEffect * quantity; switch (food.FoodType) { case FoodType.Organic: this.Health += eat; break; case FoodType.Meat: this.Health -= eat; break; } }
public override void Eat(IEdible food, int quantity) { switch (food.FoodType) { case FoodType.Organic: this.Health += quantity * food.HealthEffect; break; case FoodType.Meat: this.Health -= quantity * food.HealthEffect; break; default: { throw new NotImplementedException("Unknown food type " + food.FoodType); } } }
public override void Eat(IEdible food, int quantity) { if (quantity < 0) { throw new ArgumentException("Invalid quantity of food to be eaten (negative)"); } // - tuka moje da se naloji da se umnojava po quantity var healthImpact = food.HealthEffect * 2; switch (food.FoodType) { case FoodType.Organic: case FoodType.Meat: this.Health += healthImpact; break; } }
public override void Eat(IEdible food, int quantity) { if (food.Quantity >= quantity) { food.Quantity -= quantity; if (food.FoodType == FoodType.Organic) { this.Health += food.HealthEffect * quantity; } else { this.Health -= food.HealthEffect * quantity; } } else { throw new ArgumentException("There is not enough quantity of food!"); } }
public override void Eat(IEdible food, int quantity) { if (food.Quantity >= quantity) { food.Quantity -= quantity; if (food.FoodType == FoodType.Organic) { base.Health += food.HealthEffect*quantity; } else { base.Health -= food.HealthEffect*quantity; } } else { throw new ArgumentException(); } }
public virtual void Eat(IEdible food) { MonoBehaviour monoBehaviour = food as MonoBehaviour; if (monoBehaviour == null) { return; } GameObject obj = monoBehaviour.gameObject; foreach (IStatus status in food.Statuses) { status.Activate(transform); } hunger.HungerTimer = food.Health; objectPooler.SetObjectInactive(obj); }
public override void Eat(IEdible food, int quantity) { if (this.IsAlive == true) { if (food.FoodType == FoodType.Organic) { this.Health += food.HealthEffect * quantity; } else { this.Health -= food.HealthEffect * quantity; } } else { throw new InvalidOperationException("The cow is dead!"); } }
/// <summary> /// feed (animalId) (foodId) (quantity) – /// feeds animal animalId with quantity of food foodId and reduces the food's quantity /// </summary> /// <param name="animal"></param> /// <param name="edibleProduct"></param> /// <param name="productQuantity"></param> public void Feed(Animal animal, IEdible edibleProduct, int productQuantity) { animal.Eat(edibleProduct, productQuantity); var foundProduct = this.Products .FirstOrDefault(p => p == edibleProduct); // check for existence by reference if (foundProduct != null) { if (foundProduct.Quantity < productQuantity) { throw new ArgumentOutOfRangeException("Incufficient quantity."); } foundProduct.Quantity -= productQuantity; // current quantity -= eaten quantity } else { throw new ArgumentException("Farm does not contain such product."); } }
static void Main(string[] args) { AAnimal[] animals = new AAnimal[2]; animals[1] = new Tiger(); animals[0] = new Chicken(); foreach (AAnimal animal in animals) { Console.WriteLine(animal.MakeSound()); if (animal is Chicken) { IEdible edibler = (Chicken)animal; Console.WriteLine($"\t {edibler.AHowToEat()}"); } } AFruit[] fruits = new AFruit[2]; fruits[0] = new Orange(); fruits[1] = new Apple(); foreach (AFruit fruit in fruits) { Console.WriteLine(fruit.AHowToEat()); } }
public void CheckCollision(Collider2D collision) { if (hunger.IsHungry) { IEdible food = collision.GetComponentInParent <IEdible>(); if (food != null) { if (objectPooler.EdibleFoodPoolDictonary[food.Name].Contains(collision.transform.parent.gameObject)) { foreach (GameObject foodObject in this.food) { if (food.Name == foodObject.name) { Eat(food); return; } } } } } }
/// <summary> /// Check to see whether Pacman can currently eat the entity he has collided with, and eat it if he can /// </summary> public void TryToEat(IEdible theEntity) { if (theEntity is Ghost aGhost) { if (itsPowerUpCounter > 0) { Eat(aGhost); if (aGhost.itsStandingOn is IEdible anEntity) { Eat(anEntity); } } else { Alive = false; } } else { Eat(theEntity); } }
public void Feed(Animal animal, IEdible edibleProduct, int productQuantity) { throw new NotImplementedException(); }
public override void Eat(IEdible edible) { Weight += 0.8 * edible.Weight; }
public override void Eat(IEdible food, int quantity) { this.Health += food.HealthEffect * 2 * quantity; }
public virtual void Eat(IEdible food, int quantity) { food.Quantity -= quantity; }
public override string GetInteractionName(Sim a, IEdible target, InteractionObjectPair interaction) { return "Drinking coffee"; }
public override void Eat(IEdible food) { Weight += food.Weight * 0.8; }
public override bool Test(Sim a, IEdible target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { return true; }
public virtual void Eat(IEdible edible) // virtual--- can be overwritable. { Weight += 0.5 * edible.Weight; }
public void Eat(IEdible food, int quantity) { throw new NotImplementedException(); }
public virtual void Eat(IEdible food, int quantity) { }
public abstract void Eat(IEdible food, int quantity);
public void Feed(Animal animal, IEdible edibleProduct, int productQuantity) { if (animal == null) { throw new ArgumentNullException("animal"); } if (edibleProduct == null) { throw new ArgumentNullException("edibleProduct"); } if (edibleProduct.Quantity < 0) { throw new ArgumentException("edibleProduct"); } animal.Eat(edibleProduct, productQuantity); }
public virtual void Eat(IEdible animalToEat) { Weight += animalToEat.Weight; }
public void Feed(Animal animal, IEdible edibleProduct, int productQuantity) { animal.Eat(edibleProduct, productQuantity); edibleProduct.Quantity -= productQuantity; }
public override void Eat(IEdible animalToEat) { this.Weight += animalToEat.Weight * 0.8; }
private void EatFood(BlobController blob, IEdible food) { blob.Energy += food.GetEnergyValue(); food.SetEaten(); }
public void Feed(Animal animal, IEdible product, int quantity) { product.Quantity -= quantity; animal.Eat(product, quantity); }
public override void Eat(IEdible food, int quantity) { this.Health += 2 * quantity * food.HealthEffect; food.Quantity -= quantity; }
public override void Eat(IEdible edible) { Weight += edible.Weight * 0.8; edible.Weight = 0; }
public virtual void Eat(IEdible food) { this.Weight += food.Weight; }
private void Eat(IEdible food) { Console.WriteLine("Eating {0}", food.GetType().Name); hunger -= food.NutritionValue; }