예제 #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
파일: Router.cs 프로젝트: LukMRVC/WebServer
 public Food AddFood(string jsonObject)
 {
     StatusCode = 201;
     return(FoodManager.AddFood(jsonObject));
 }