Beispiel #1
0
    private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        if (scene.name == sceneName)
        {
            for (int i = 0; i < transform.childCount; i++)
            {
                // print("on load: " + i);

                GameObject child     = transform.GetChild(i).gameObject;
                FoodData   childData = child.GetComponent <FoodData>();

                child.SetActive(true);

                if (childData.addedToListAlready)
                {
                    if (sceneName == "S7_Kitchen")
                    {
                        if (Global.inBlenderFoods.Count > 0)
                        {
                            int index = Global.inBlenderFoods.FindIndex(food => food.foodId == childData.id);

                            if (index > -1)
                            {
                                Global.inBlenderFoods[index].minusOneFromQuanity();

                                if (Global.inBlenderFoods[index].quantity == 0)
                                {
                                    Global.inBlenderFoods.Remove(Global.inBlenderFoods[index]);
                                }
                            }
                        }
                    }

                    if (sceneName == "S5_Supermarket" || sceneName == "S6_Garden")
                    {
                        if (Global.selectedFoods.Count > 0)
                        {
                            int index = Global.selectedFoods.FindIndex(bf => bf.foodId == childData.id);

                            if (index > -1)
                            {
                                Global.selectedFoods[index].minusOneFromQuanity();
                                if (Global.selectedFoods[index].quantity == 0)
                                {
                                    Global.selectedFoods.Remove(Global.selectedFoods[index]);
                                }
                            }
                        }
                    }
                }
            }
        }
        else
        {
            for (int i = 0; i < transform.childCount; i++)
            {
                transform.GetChild(i).gameObject.SetActive(false);
            }
        }
    }
Beispiel #2
0
        private bool ValidateFoodData(FoodData foodData, long foodIdl)
        {
            int foodId   = (int)foodIdl;
            var detail   = _foodDetailRepository.GetIQueryable().Where(f => f.FoodId == foodId).OrderByDescending(f => f.CreateDate).Take(1).SingleOrDefault();
            var function = "";

            if (detail.TypeId == 1)
            {
                function = "addNewData";
            }
            else
            {
                function = "saveData";
            }
            var setting = new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            };
            var FoodDataJson        = JsonConvert.SerializeObject(foodData, setting);
            var transactionFoodData = _service.DecodeData(_service.GetTransactionInputByHashAsync(detail.TransactionHash).Result, function);
            var isMatch             = FoodDataJson.CompareTo(transactionFoodData) == 0 ? true : false;

            if (!isMatch)
            {
                //_service.SetInvalidData(foodIdl);
            }
            return(true);
        }
Beispiel #3
0
        public override void Solve()
        {
            FoodData data = GetFoodData(ParseInput());

            PruneAllergens(data.PossibleCauses);

            var sb = new StringBuilder();

            // list dangerous ingredients in alphabetical order of allergen
            foreach (string allergen in data.Allergens.ToImmutableSortedSet())
            {
                var causes = data.PossibleCauses[allergen];
                if (causes.Count != 1)
                {
                    throw new Exception($"'{allergen}' isn't uniquely identifiable ({causes.Count})");
                }
                sb.Append(causes.First());
                sb.Append(',');
            }

            // remove last ','
            sb.Remove(sb.Length - 1, 1);
            Console.WriteLine("Canonical list of dangerous ingredients:");
            Console.WriteLine(sb.ToString());
        }
Beispiel #4
0
    public void UpdateFoods(List <FoodData> listFood)
    {
        for (int idx = 0; idx < listFood.Count; idx++)
        {
            FoodData data = listFood[idx];
            int      fIdx = registeredFood.FindIndex(x => x.foodId.Equals(data.foodID));
            //Find the given data in the list. If it's not in the list, create new food for the data
            if (fIdx < 0)
            {
                GameObject     go      = foodPool.GetGameObject(data.foodKeyword);
                FoodController control = go.GetComponent <FoodController>();
                if (control == null)
                {
                    control = go.AddComponent <FoodController>();
                }
                LayerController.Instance.SetFoodLayer(go);
                go.gameObject.tag = "Food";
                control.SetData(data);
                registeredFood.Add(control);
            }
            //When it's already in the list, just reset the data
            else
            {
                //registeredFood[fIdx].SetData(data);
            }
        }

        ClearFood(listFood);
    }
Beispiel #5
0
 private void btn_print_Click(object sender, EventArgs e)
 {
     try
     {
         FoodData obj = foodDataBindingSource.Current as FoodData;
         if (obj != null)
         {
             using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString))
             {
                 if (db.State == ConnectionState.Closed)
                 {
                     db.Open();
                     string sql = $"Select order_No,cus_No,Due_Date,Due_Time,foodName,item_price,quantity,totAmt From Food_Order_Header where Due_Time Like '%{txt_time.Text}%'";
                     List <ListFoodData> list = db.Query <ListFoodData>(sql, commandType: CommandType.Text).ToList();
                     using (PrintDailyFoodOrdRep print = new PrintDailyFoodOrdRep(list))
                     {
                         print.ShowDialog();
                     }
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
    public void Feeder(GameObject obj)
    {
        FoodData foodData = obj.GetComponent <FoodData>();

        if (foodData.count <= 0)
        {
            return;
        }

        obj.GetComponentInChildren <Text>().text = (foodData.count - 1).ToString();
        foodData.count--;
        float addFood = (10 * ((foodData.id * 0.1f) + 1)) * (foodData.id + 1);

        petAI.Hunger += addFood;
        int realIdFood = SaveSystem.A_GetRealIdFood(foodData.id);

        if (foodDic.Keys.Contains(realIdFood))
        {
            foodDic[realIdFood] = foodData.count;
        }
        else
        {
            foodDic.Add(realIdFood, foodData.count);
        }

        StartCoroutine(AnimateSliderOverTime(hunger, addFood * 0.01f, 0.2f));

        petAI.PetAct = PetActivity.Happy;

        if (foodData.count <= 0)
        {
            obj.SetActive(false);
        }
    }
Beispiel #7
0
        public async Task AddOrUpdateFoodDataAsync(IDbConnection connection, FoodData foodData)
        {
            await connection.QueryFirstOrDefaultAsync(
                $@"INSERT INTO food (shopTypeId, externalId, category, name, url, weight, volume, price, energy, proteins, fats, carbohydrates, created, updated)
  VALUES(@{nameof(FoodData.ShopType)},
@{nameof(FoodData.ExternalId)},
@{nameof(FoodData.Category)},
@{nameof(FoodData.Name)},
@{nameof(FoodData.Url)},
@{nameof(FoodData.Weight)},
@{nameof(FoodData.Volume)},
@{nameof(FoodData.Price)},
@{nameof(FoodData.Energy)},
@{nameof(FoodData.Proteins)},
@{nameof(FoodData.Fats)},
@{nameof(FoodData.Carbohydrates)},
@{nameof(FoodData.Created)},
@{nameof(FoodData.Updated)}
) 
  ON CONFLICT(shopTypeId, externalId) 
  DO UPDATE SET 
category = @{nameof(FoodData.Category)},
name = @{nameof(FoodData.Name)},
url = @{nameof(FoodData.Url)},
weight = @{nameof(FoodData.Weight)},
volume = @{nameof(FoodData.Volume)},
price = @{nameof(FoodData.Price)},
energy = @{nameof(FoodData.Energy)},
proteins = @{nameof(FoodData.Proteins)},
fats = @{nameof(FoodData.Fats)},
carbohydrates = @{nameof(FoodData.Carbohydrates)},
updated = @{nameof(FoodData.Updated)}", foodData);
        }
Beispiel #8
0
        public override async Task <FoodResponse> CreateFood(FoodRequest request, ServerCallContext context)
        {
            List <string> items = new List <string>();

            _logger.LogInformation("Begin grpc call from method {Method} for Foody Restaurant {RestaurantName}", context.Method, request.Foods.RestaurantName);

            request.Foods.FoodItems.ToList().ForEach(a => items.Add(a.Name));

            var foodData = new FoodData(items, request.Foods.RestaurantName, request.Foods.Description);

            if (foodData != null)
            {
                await _repository.AddAsync(foodData);

                context.Status = new Status(StatusCode.OK, "Food created successfulyl.");

                _logger.LogInformation("Grpc call created successfully for Restaurant {RestaurantName}", request.Foods.RestaurantName);

                return(new FoodResponse {
                    Message = "Food Created"
                });
            }
            else
            {
                context.Status = new Status(StatusCode.NotFound, "Error creating food.");
            }

            return(new FoodResponse {
                Message = "Food Error."
            });
        }
Beispiel #9
0
        public static Object GetFoodData(string ClientID)
        {
            DataTable dtFoodList = new DataTable();

            //BusinessHelper<IFoodMaster>.Use(FoodMasterManager =>
            //{
            //    dtFoodList = FoodMasterManager.GetFoodList();
            //});

            dtFoodList = new FoodMasterManager().GetFoodList();

            DataTable dtFoodUnitList = new DataTable();

            //BusinessHelper<IFoodMaster>.Use(FoodMasterManager =>
            //{
            //    dtFoodUnitList = FoodMasterManager.GetFoodUnitList();
            //});
            dtFoodUnitList = new FoodMasterManager().GetFoodUnitList();

            string[] foods       = dtFoodList.Rows[0][0].ToString().Split('~');
            string[] units       = dtFoodUnitList.Rows[0][0].ToString().Split(',');
            FoodData objFoodData = new FoodData();

            objFoodData.foodNames = foods;
            objFoodData.foodUnits = units;
            return(objFoodData);
            //return new Object();
        }
Beispiel #10
0
        public async Task <FoodData> GetFoodDataByIDAndProviderID(long foodId, int providerId)
        {
            FoodData food = await _service.GetFoodDataByID(foodId);

            food.Providers = food.Providers.Where(x => x.ProviderId == providerId).ToList();
            return(food);
        }
    // Use this for initialization
    void Start()
    {
        animator   = GetComponent <Animator>();
        objectData = GetComponentInParent <FoodData>();

        currState       = ObjectState.Idle;
        initialPosition = transform.position;
    }
Beispiel #12
0
 public void SetData(FoodData data)
 {
     SetFoodId(data.foodID);
     SetPosition(data.xPosition, data.yPosition);
     SetSize(data.width, data.height);
     SetColor();
     keyword = data.foodKeyword;
 }
Beispiel #13
0
        public override void Solve()
        {
            FoodData data = GetFoodData(ParseInput());
            var      possibleAllergens = data.PossibleCauses.Values.SelectMany(x => x);
            var      safeFoods         = data.Ingredients.Where(x => !possibleAllergens.Contains(x));

            Console.WriteLine($"Safe food count is {safeFoods.Sum(f => data.IngredientCounts[f])}");
        }
Beispiel #14
0
        /// <summary>
        /// Creates the food data with defined numbers of food and initializes each.
        /// </summary>
        /// <param name="data">A structure defining the numbers of food to create.</param>
        public void initialize(FoodData data)
        {
            setFood(data);

            foreach (FoodType item in food)
            {
                item.initialize();
            }
        }
Beispiel #15
0
 public void SetData(FoodData data)
 {
     if (data == null)
     {
         return;
     }
     FoodData_     = data;
     _Sprite.color = FoodData_._Color;
 }
Beispiel #16
0
    static void Main(string[] args)
    {
        XDocument doc      = XDocument.Load(@"Your path to xml");               //<= Load xml
        FoodData  foodData = GetUserData(doc, "David");                         //<= Pass "David" to function

        foodData.FoodNames.ForEach(x => Console.WriteLine("Food: " + x));       //<= Print food name list
        Console.WriteLine();
        foodData.DrinkNames.ForEach(x => Console.WriteLine("Drink: " + x));     //<= Print drink name list
        Console.ReadLine();
    }
Beispiel #17
0
 private void ChooseFood()
 {
     foodNumber                = Random.Range(0, foodOptions.Count);
     foodImage.tag             = foodOptions[foodNumber].foodTag;
     foodImage.name            = foodOptions[foodNumber].foodName;
     foodSpriteRenderer        = foodImage.GetComponent <SpriteRenderer>();
     foodSpriteRenderer.sprite = foodOptions[foodNumber].foodSprite;
     foodSprite                = foodOptions[foodNumber].foodSprite;
     chosenFood                = foodOptions[foodNumber];
 }
Beispiel #18
0
 public Food(FoodData data, Behaviour behaviour)
 {
     Id          = data.Id;
     Name        = I18N.Instance.Get(data.NameKey);
     Description = I18N.Instance.Get(data.DescriptionKey);
     Type        = data.Type;
     Icon        = data.Icon;
     Price       = data.Price;
     Behaviour   = behaviour;
 }
Beispiel #19
0
    static void Main(string[] args)
    {
        XDocument doc      = XDocument.Load(@"Your path to xml");
        FoodData  foodData = GetUserData(doc, "David");

        foodData.FoodNames.ForEach(x => Console.WriteLine("Food: " + x));
        Console.WriteLine();
        foodData.DrinkNames.ForEach(x => Console.WriteLine("Drink: " + x));
        Console.ReadLine();
    }
Beispiel #20
0
    public static FoodData GetUserData(XDocument doc, string userName)
    {
        FoodData foodData = new FoodData
        {
            FoodNames  = doc.Root.Elements(userName).Elements().Where(x => x.Name == "FAVE_FOOD").Descendants().Select(x => x.Attribute("value").Value).ToList(),
            DrinkNames = doc.Root.Elements(userName).Elements().Where(x => x.Name == "FAVE_Drinks").Descendants().Select(x => x.Attribute("value").Value).ToList()
        };

        return(foodData);
    }
Beispiel #21
0
    public void AddFood(Entity food)
    {
        ICollectable newFood = (ICollectable)food;

        FoodData newFoodData = new FoodData();

        newFoodData.entityCell = food.currentGridCell;
        newFoodData.prefab     = food.Prefab;
        newFoodData.parent     = food.transform.parent;
    }
Beispiel #22
0
        private void setFood(FoodData data)
        {
            food.Clear();

            int start = 0;

            for (int i = 0; i < data.numberOfMice; i++)
            {
                if (start > 8)
                {
                    start = 0;
                }

                food.Add(new MouseType());

                start++;
            }

            for (int i = 0; i < data.numberOfHogs; i++)
            {
                if (start > 8)
                {
                    start = 0;
                }

                food.Add(new GroundHogType());

                start++;
            }

            for (int i = 0; i < data.numberOfRabbits; i++)
            {
                if (start > 8)
                {
                    start = 0;
                }

                food.Add(new RabbitType());

                start++;
            }

            for (int i = 0; i < data.numberOfScorpions; i++)
            {
                if (start > 8)
                {
                    start = 0;
                }

                food.Add(new ScorpionType());

                start++;
            }
        }
Beispiel #23
0
        public async Task <ImageAnalysis> Classify(string fileName, string writePath = null)
        {
            Console.WriteLine("----------------------------------------------------------");
            Console.WriteLine("ANALYZE IMAGE - URL");
            Console.WriteLine();
            try
            {
                List <VisualFeatureTypes> features = new List <VisualFeatureTypes>()
                {
                    VisualFeatureTypes.Categories, VisualFeatureTypes.Description,
                    VisualFeatureTypes.Faces, VisualFeatureTypes.ImageType,
                    VisualFeatureTypes.Tags, VisualFeatureTypes.Adult,
                    VisualFeatureTypes.Color, VisualFeatureTypes.Brands,
                    VisualFeatureTypes.Objects
                };
                Console.WriteLine($"Analyzing the image {Path.GetFileName(fileName)}...");
                Console.WriteLine();
                // Analyze the URL image
                using (Stream analyzeImageStream = File.OpenRead(fileName))
                {
                    // Analyze the local image.
                    ImageAnalysis results = await client.AnalyzeImageInStreamAsync(analyzeImageStream, features);

                    var foodResult = results.Tags.Where(t => t.Hint == "food").FirstOrDefault() ?? results.Tags.FirstOrDefault();
                    if (!string.IsNullOrWhiteSpace(writePath))
                    {
                        Directory.CreateDirectory(writePath);
                        var jsonFilePath =
                            Path.Combine(writePath, $"{Path.GetFileNameWithoutExtension(fileName)}.json");
                        var foodData = new FoodData
                        {
                            Classification = new Classification
                            {
                                Succeeded   = true,
                                Category    = foodResult.Name,
                                Probability = foodResult.Confidence
                            },
                            CreationDate   = DateTime.UtcNow,
                            ExpirationDate = null
                        };

                        File.WriteAllText(jsonFilePath, JsonConvert.SerializeObject(foodData));
                    }

                    return(results);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                throw e;
            }
        }
Beispiel #24
0
 private async Task DisplayResultsAsync(FoodData data)
 {
     if (Dispatcher.HasThreadAccess)
     {
         _repository.Clear();
         _repository.ExtractDataToRepository(data);
     }
     else
     {
         await Dispatcher.RunAsync(CoreDispatcherPriority.Low, async() => await DisplayResultsAsync(data));
     }
 }
Beispiel #25
0
        public async Task <string> AddNewFoodData(FoodData FoodData, string sender)
        {
            var service = GetService();
            var setting = new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            };
            string Data   = JsonConvert.SerializeObject(FoodData, setting);
            var    result = await service.AddNewDataRequestAndWaitForReceiptAsync(
                new AddNewDataFunction { Data = Data, Id = FoodData.FoodId, Sender = sender, Gas = 1000000 });

            return(result.TransactionHash);
        }
Beispiel #26
0
        private async Task ImportData(IDbConnection connection, FoodData food, ProductId productId)
        {
            if (food != null)
            {
                await _dal.AddOrUpdateFoodDataAsync(connection, food);

                _logger.LogDebug($"Добавлен {food.Name}");
            }

            productId.Status  = food == null ? ProductIdStatus.Skipped : ProductIdStatus.Imported;
            productId.Updated = DateTime.UtcNow;
            await _dal.AddOrUpdateProductIdAsync(connection, productId);
        }
    private void Start()
    {
        //inital
        foodData = FoodData.Instance;
        trie     = new TRIE();
        root     = trie.Root;

        selectedMenus = new List <string>();

        //setting
        trie.insert(foodData.words);
        tv_search.onValueChanged.AddListener(TextUpdated);

        Active(false);
    }
Beispiel #28
0
    public void Preview(GameObject obj)
    {
        SoundManager.Ins.PlaySound(SoundManager.Ins._Select);
        furnitureData = obj.transform.parent.GetComponent <FurnitureData>();
        clothesData   = obj.transform.parent.GetComponent <ClothesData>();
        foodData      = obj.transform.parent.GetComponent <FoodData>();

        price = furnitureData != null ? furnitureData.price : price;
        price = clothesData != null ? clothesData.price : price;
        price = foodData != null ? foodData.price : price;
        coin  = SaveSystem.A_Coin();
        previewImage.sprite = obj.GetComponent <Image>().sprite;
        cost.text           = obj.transform.parent.GetChild(1).GetChild(0).GetComponent <Text>().text;
        previewObj.SetActive(true);
    }
Beispiel #29
0
    public FoodData GetFoodData(int foodId)
    {
        var      fs       = _GameData._Foods;
        FoodData foodData = null;

        for (int i = 0, length = fs.Length; i < length; i++)
        {
            if (fs[i]._ID == foodId)
            {
                foodData = fs[i];
                break;
            }
        }
        return(foodData);
    }
Beispiel #30
0
        public async Task <string> CreateFood(Entities.Food newFood, int farmId, int createById)
        {
            var Premises = _premesisRepository.GetById(farmId);
            var Cat      = _categoryRepository.GetById(newFood.CategoryId);
            var FoodData = new FoodData()
            {
                FoodId      = newFood.FoodId,
                Breed       = newFood.Breed,
                Category    = Cat.Name,
                Farm        = _mapper.Map <Farm>(Premises),
                StartedDate = DateTime.Now
            };

            return(await _service.AddNewFoodData(FoodData, _userRepository.GetById(createById).Username));
        }