示例#1
0
 public void AddFood_NoException()
 {
     Assert.DoesNotThrow(() => foodManager.AddFood(new Food("")
     {
         FId      = "1",
         FoodName = "food",
         FoodDesc = "desc",
         donor    = new User()
     }));
 }
示例#2
0
    public void FoodNearBy()
    {
        //call this when a food is placed or finished eating food
        if (nearestFood != null)
        {
            foods.AddFood(nearestFood.gameObject);
        }
        //CHECK ALL FOODS
        float dist = 999999;

        for (int i = 0; i < foods.food.Count; i++)
        {
            if (foods.food[i] != null)
            {
                float newDist = Vector3.Distance(transform.position, foods.food[i].transform.position);
                if (newDist < dist)
                {
                    dist        = newDist;
                    nearestFood = foods.food[i].transform;
                }
            }
        }
        if (nearestFood != null)
        {
            foods.RemoveFood(nearestFood.gameObject);
        }
    }
示例#3
0
        private void RegisterFood(PoolObject poolObject)
        {
            var food = poolObject.Resolve <Food>();

            _foodManager.AddFood(food);
            poolObject.OnDestroyed += () => _foodManager.RemoveFood(food);
        }
示例#4
0
 public static void PromptAddFood()
 {
     try
     {
         Food f = new Food();
         Console.Write(@"-----------> Food name: ");
         f.Name = Console.ReadLine();
         Console.Write(@"-----------> Food gram: ");
         f.Gram = Int32.Parse(Console.ReadLine());
         Console.Write(@"-----------> Food price: ");
         f.Price = Decimal.Parse(Console.ReadLine());
         Console.Write(@"-----------> Food composition: ");
         f.Composition = Console.ReadLine();
         Console.Write(@"Category to append to: ");
         f.CategoryId = Int32.Parse(Console.ReadLine());
         Console.Write(@"-----------> Would you like to add nutritional values?[y/n]: ");
         string decision = Console.ReadLine();
         if (decision.Equals("y", StringComparison.OrdinalIgnoreCase) || decision.Equals("yes", StringComparison.OrdinalIgnoreCase))
         {
             Console.Write(@"-----------> Food energy (Kj): ");
             f.EnergyKj = Int32.Parse(Console.ReadLine());
             Console.Write(@"-----------> Food energy (Kcal): ");
             f.EnergyKcal = Int32.Parse(Console.ReadLine());
             Console.Write(@"-----------> Food protein: ");
             f.Protein = Decimal.Parse(Console.ReadLine());
             Console.Write(@"-----------> Food carbohydrates: ");
             f.Carbohydrates = Decimal.Parse(Console.ReadLine());
             Console.Write(@"-----------> Food sugar: ");
             f.Sugar = Decimal.Parse(Console.ReadLine());
             Console.Write(@"-----------> Food total fat: ");
             f.TotalFat = Decimal.Parse(Console.ReadLine());
             Console.Write(@"-----------> Food saturated fat: ");
             f.SaturatedFat = Decimal.Parse(Console.ReadLine());
             Console.Write(@"-----------> Food fiber: ");
             f.Fiber = Decimal.Parse(Console.ReadLine());
             Console.Write(@"-----------> Food salt: ");
             f.Salt = Decimal.Parse(Console.ReadLine());
             Console.Write(@"-----------> Food allergenes (numbers separated by commas ','): ");
             f.Allergenes = Console.ReadLine().Split(',').Select(s => Int32.Parse(s)).ToList();
             FoodManager.AddFood(f);
             Console.WriteLine("Food succesfully added");
         }
         else
         {
             FoodManager.AddFood(f);
             Console.WriteLine("Food succesfully added");
         }
     }
     catch (Exception)
     {
         Console.WriteLine("Invalid input! Aborting...");
         return;
     }
 }
示例#5
0
 // Update is called once per frame
 void Update()
 {
     if (timer >= timeTillNextDrop)
     {
         Vector3 randomPosition = new Vector3(Random.Range(1, 3), 0, Random.Range(1, 3));
         int     randomNum      = Random.Range(0, 2);
         if (randomNum == 1)
         {
             randomPosition *= -1;
         }
         var newFood = Instantiate(fruits[Random.Range(0, fruits.Length)], transform.position + randomPosition, Quaternion.identity, fruitParent);
         foods.AddFood(newFood);
         foreach (HumanCurrentStats h in population.humans)
         {
             h.GetComponent <HumanEat>().FoodNearBy();
         }
         timer = 0;
     }
     timer += Time.deltaTime;
 }
示例#6
0
 public Food AddFood(string jsonObject)
 {
     StatusCode = 201;
     return(FoodManager.AddFood(jsonObject));
 }