Пример #1
0
 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));
 }
Пример #2
0
    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));
        }
    }
Пример #3
0
        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());
            }
        }
Пример #4
0
        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");
            }
        }
Пример #5
0
 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;
 }
Пример #6
0
    private void OnTriggerEnter(Collider col)
    {
        IEdible edible = col.GetComponent <IEdible>();

        if (edible != null && !_edibles.Contains(col.transform))
        {
            _edibles.Add(col.transform);
        }
    }
Пример #7
0
    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);
        }
    }
Пример #8
0
    private void OnTriggerExit(Collider col)
    {
        IEdible edible = col.GetComponent <IEdible>();

        if (edible != null && _edibles.Contains(col.transform))
        {
            _edibles.Remove(col.transform);
        }
    }
Пример #9
0
    private void OnCollisionEnter2D(Collision2D col)
    {
        IEdible edible = col.transform.GetComponent <IEdible>();

        if (edible != null)
        {
            edible.OnEaten();
            Grow();
        }
    }
Пример #10
0
        /// <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;
            }
        }
Пример #11
0
 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;
     }
 }
Пример #13
0
 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!");
     }
 }
Пример #14
0
 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.");
     }
 }
Пример #16
0
 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;
     }
 }
Пример #17
0
 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);
         }
     }
 }
Пример #18
0
 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;
 }
Пример #19
0
        /// <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;
            }
        }
Пример #20
0
        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;
            }
        }
Пример #21
0
 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);
             }
     }
 }
Пример #22
0
        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;
            }
        }
Пример #23
0
 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!");
     }
 }
Пример #24
0
 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();
     }
 }
Пример #25
0
    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);
    }
Пример #26
0
        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!");
            }
        }
Пример #27
0
        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!");
            }
        }
Пример #28
0
        /// <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.");
            }
        }
Пример #29
0
 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());
     }
 }
Пример #30
0
    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;
                        }
                    }
                }
            }
        }
    }
Пример #31
0
 /// <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);
     }
 }
Пример #32
0
 public void Feed(Animal animal, IEdible edibleProduct, int productQuantity)
 {
     throw new NotImplementedException();
 }
Пример #33
0
 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;
 }
Пример #35
0
 public virtual void Eat(IEdible food, int quantity)
 {
     food.Quantity -= quantity;
 }
Пример #36
0
        public override string GetInteractionName(Sim a, IEdible target, InteractionObjectPair interaction)
        {

            return "Drinking coffee";
        }
Пример #37
0
 public override void Eat(IEdible food)
 {
     Weight += food.Weight * 0.8;
 }
Пример #38
0
 public override bool Test(Sim a, IEdible target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
 {
     return true;
 }
Пример #39
0
 public virtual void Eat(IEdible edible) // virtual--- can be overwritable.
 {
     Weight += 0.5 * edible.Weight;
 }
 public override void Eat(IEdible food, int quantity)
 {
     this.Health += food.HealthEffect * 2 * quantity;
 }
Пример #41
0
 public void Eat(IEdible food, int quantity)
 {
     throw new NotImplementedException();
 }
Пример #42
0
 public virtual void Eat(IEdible food, int quantity)
 {
 }
Пример #43
0
 public abstract void Eat(IEdible food, int quantity);
Пример #44
0
        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);
        }
Пример #45
0
 public virtual void Eat(IEdible animalToEat)
 {
     Weight += animalToEat.Weight;
 }
Пример #46
0
 public void Feed(Animal animal, IEdible edibleProduct, int productQuantity)
 {
     animal.Eat(edibleProduct, productQuantity);
     edibleProduct.Quantity -= productQuantity;
 }
Пример #47
0
 public override void Eat(IEdible animalToEat)
 {
     this.Weight += animalToEat.Weight * 0.8;
 }
Пример #48
0
 public abstract void Eat(IEdible food, int quantity);
Пример #49
0
        private void EatFood(BlobController blob, IEdible food)
        {
            blob.Energy += food.GetEnergyValue();

            food.SetEaten();
        }
Пример #50
0
 public void Feed(Animal animal, IEdible product, int quantity)
 {
     product.Quantity -= quantity;
     animal.Eat(product, quantity);
 }
Пример #51
0
 public override void Eat(IEdible food, int quantity)
 {
     this.Health += 2 * quantity * food.HealthEffect;
     food.Quantity -= quantity;
 }
Пример #52
0
 public override void Eat(IEdible edible)
 {
     Weight       += edible.Weight * 0.8;
     edible.Weight = 0;
 }
Пример #53
0
 public void Feed(Animal animal, IEdible edibleProduct, int productQuantity)
 {
     throw new NotImplementedException();
 }
Пример #54
0
 public virtual void Eat(IEdible food)
 {
     this.Weight += food.Weight;
 }
Пример #55
0
 private void Eat(IEdible food)
 {
     Console.WriteLine("Eating {0}", food.GetType().Name);
     hunger -= food.NutritionValue;
 }