private void CreateFood() { Point location = new Point(random.Next(arenaSize.Width) / 10 * 10, random.Next(arenaSize.Height) / 10 * 10); Food newfood = new Food(location, this); Foods.Add(newfood); // 场上不止一种食物? if (Foods.Count > 1) { Foods.RemoveAt(0); } }
/// <summary> /// Добавление продукта. /// </summary> /// <param name="food">Продукт.</param> /// <param name="wieght">Количество.</param> public void AddFoodToEating(Food food, float wieght) { var product = Foods.Keys.FirstOrDefault(f => f.Name.Equals(food.Name)); if (product == null) { Foods.Add(food, wieght); } else { Foods[product] += wieght; } }
private void GenerateFood(int desiredFoodCount) { while (Foods.Count < desiredFoodCount) { Random random = new Random(); int x = random.Next(1, this.Wall.BottomX - 2); int y = random.Next(1, Wall.BottomY - 2); if (!Snake.ContainsPoint(x, y)) { Foods.Add(new Food(x, y)); } } }
/// <summary> /// Возможность добавлять продукт питания /// </summary> /// <param name="food">Наименование продукта</param> /// <param name="calorie">Калории</param> public void Add(Food food, double calorie) { var product = Foods.Keys.FirstOrDefault(f => f.Name.Equals(food.Name)); if (product == null) { Foods.Add(food, calorie); } else { Foods[product] += calorie; } }
/// <summary> /// 添加食物 /// </summary> public bool AddFood(Food food) { var existFood = Foods.Find(p => p.Id == food.Id); if (existFood != null) { return(false); } Foods.Add(food); OnAddFood?.Invoke(food); return(true); }
public void Add(Food food, double weight) { var product = Foods.Keys.FirstOrDefault(f => f.Name.Equals(food.Name)); if (product == null) { Foods.Add(food, weight); } else { Foods[product] += weight; } }
private void AddToList(IEnumerable <Food> foods) { Foods.Clear(); foreach (var item in foods) { var newEntry = new SelectableFoodViewModel(item) { Price = GetPrice(item.MealCost) }; Foods.Add(newEntry); } }
/// <summary> /// Добавление продукта. /// </summary> /// <param name="foodName">Наименование продукта.</param> /// <param name="wieght">Вес продукта.</param> public void AddFood(Food food, float weight) { var product = Foods.SingleOrDefault(f => f.Name == food.Name); if (product == null) { Foods.Add(food); Eating.AddFoodToEating(food, weight); } else { Eating.AddFoodToEating(product, weight); } SetAll(); }
/// <summary> /// Add to meal and to product and all new of what use eat then save. /// </summary> /// <param name="food"></param> /// <param name="weight"></param> public void Add(Food food, double weight) { var product = Foods.SingleOrDefault(f => f.Name == food.Name);//because we return default(T); if (product == null) {//new product Foods.Add(food); Eating.Add(food, weight); } else { Eating.Add(product, weight); } Save(); }
/// <summary> /// Добавление нового продукта/занесение в прием пищи /// </summary> /// <param name="food"></param> /// <param name="weight"></param> public void Add(Food food, double weight) { var product = Foods.SingleOrDefault(x => x.Name == food.Name); if (product == null) { Foods.Add(food); Eating.Add(food, weight); } else { Eating.Add(food, weight); } Save(); }
public void Add(Food food, double weight) { //Ищем такой продукт var product = Foods.Keys.FirstOrDefault(f => f.Name.Equals(food)); //Если его нет то добавляем if (product == null) { Foods.Add(food, weight); } else { Foods[product] += weight; } }
public void Add(Food food, double weight) { var product = Foods.SingleOrDefault(n => n.Name == food.ToString()); if (product == null) { Foods.Add(food); Eating.Add(food, weight); Save(); } else { Eating.Add(product, weight); Save(); } }
public void AddEating(Food food, double quantity) { var product = Foods.SingleOrDefault(f => f.Name == food.Name); if (product == null) { Foods.Add(food); UserEating.AddProduct(food, quantity); SaveFoodData(); } else { UserEating.AddProduct(product, quantity); SaveFoodData(); } }
public void Add(Food food, double wieght) { Food product = Foods.SingleOrDefault((f) => f.Name == food.Name); if (product == null) { Foods.Add(food); Eating.Add(food, wieght); Save(); } else { Eating.Add(product, wieght); Save(); } }
/// <summary> /// Добавить прием пищи. /// </summary> /// <param name="food"></param> /// <param name="weight"></param> public void Add(Food food, double weight) { //проверяем подходит ли ключ стловаря - тоесть название продукта к переданному значению var product = Foods.Keys.FirstOrDefault(f => f.Name.Equals(food.Name)); //если да,добавляем прием пищи if (product == null) { Foods.Add(food, weight); } ///если нет ,добавляем вес к уже существующему продукту else { Foods[product] += weight; } }
/// <summary> /// Метод добавления еды, если такого продукта нет было ранее, то добавляем новый. /// </summary> /// <param name="food"></param> /// <param name="calorie"></param> public void Add(Food food, double calorie) { var product = Foods.SingleOrDefault(f => f.Name == food.Name); if (product == null) { Foods.Add(food); Eating.Add(food, calorie); Save(); } else { Eating.Add(product, calorie); Save(); } }
public void Add(Food food, double weight) { var product = Foods.SingleOrDefault(f => f.Name == food.Name); if (product is null) { Foods.Add(food); Eating.AddFood(food, weight); SaveFood(); } else { Eating.AddFood(product, weight); SaveFood(); } }
public void Add(Food food, double weight) { var product = Foods.SingleOrDefault(f => f.FoodName == food.FoodName); if (product == null) { Foods.Add(food); Meal.Add(food, weight); Save(); } else { Meal.Add(product, weight); Save(); } }
/// <summary> /// Добавление продукта в справочник продуктов, добавление в базу съеденного. /// </summary> /// <param name="food">Параметр - продукт.</param> /// <param name="weight">Параметр - вес продукта.</param> public void Add(Food food, double weight) { var product = Foods.SingleOrDefault(f => f.Name == food.Name); if (product == null) // Новый продукт. { Foods.Add(food); // Пополняем справочник продуктов. Eating.Add(food, weight); // Пополняем базу съеденного. Save(); } else // Такой продукт уже когда-то ели. { Eating.Add(product, weight); Save(); } }
public void Add(Food food, decimal weight) { var product = Foods.SingleOrDefault(f => f.Name == food.Name); if (product == null) { Foods.Add(food); Eating.Add(food, (double)weight); Save(); } else { Eating.Add(product, (double)weight); Save(); } }
/// <summary> /// Метод добавляет в словарь саму еду и ее количество. /// </summary> /// <param name="food"></param> /// <param name="weight"></param> public void Add(Food food, double weight) { // Foods.TryGetValue(); /// Сравнение по сслыкам не работает. Если значимые типо работает хорошо // проверка. Есть ли такое значение в справочнике var product = Foods.Keys.FirstOrDefault(f => f.Name.Equals(food.Name)); if (product == null) // Если такого продукта нет. То мы его добавляем { Foods.Add(food, weight); } else { Foods[product] += weight; } }
/// <summary> /// Добавление еды. (приём пищи) /// </summary> public void Add(Food food, double weight) { //Получаем еду из списка существующих продуктов. var product = Foods.FirstOrDefault(f => f.Name == food.Name); if (product == null) { Foods.Add(food); Eatings.Add(food, weight); Save(); } else { Eatings.Add(product, weight); Save(); } }
public bool Add(Food food, double weight) { var product = Foods.SingleOrDefault(f => f.Name == food.Name); if (product == null) // request all food details { Foods.Add(food); Eating.Add(food, weight); Save(); } else { Eating.Add(product, weight); Save(); } return(false); }
public void Add(Food food, double weight) { var product = Foods.FirstOrDefault(e => e.Name == food.Name); if (product == null) { Foods.Add(food); Eating.Add(food, weight); Save <Food>(Foods); } else { Eating.Add(product, weight); } Save <Eating>(new List <Eating> { Eating }); }
public static Food CreateNewFood() { var score = Random.Next(1, 100); var pos = GetRandomPos(); if (GetFoodAtPos(pos) != null) { return(CreateNewFood()); } Food food = new Food(score) { Position = GetRandomPos() }; Foods.Add(food); food.Draw(); return(food); }
public async void GetFoods() { RestService restSevice = new RestService(); FoodManager myFoodManager = new FoodManager(restSevice); List <Food> listFoods = await myFoodManager.GetFoodsAsync(); var user = JsonConvert.DeserializeObject <ApplicationUser>(Preferences.Get("User", "default_value")); string connectionString = Constants.connectionString; BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString); string containerName = "foodpicsblobs"; BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName); foreach (var item in listFoods) { if (user.Id == item.UserID) { BlobClient blobClient = containerClient.GetBlobClient(item.ImageUrl); item.ImageSource = ImageSource.FromStream(() => { var stream = blobClient.OpenRead(); return(stream); }); Foods.Add(item); } } }
public async void GetFoods() { RestService restSevice = new RestService(); FoodManager myFoodManager = new FoodManager(restSevice); List <Food> listFoods = await myFoodManager.GetFoodsAsync(); string connectionString = Constants.connectionString; BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString); string containerName = "foodpicsblobs"; BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName); foreach (var item in listFoods) { if (profileUser.Id == item.UserID) { BlobClient blobClient = containerClient.GetBlobClient(item.ImageUrl); item.ImageSource = ImageSource.FromStream(() => { var stream = blobClient.OpenRead(); return(stream); }); item.SetUserLoc(new Location(profileUser.UserLocLatitude, profileUser.UserLocLongitude)); Foods.Add(item); } } }
private void RefreshItems() { this.Items = new List <Item>() { new Item() { Name = Config.Material, Count = Helper.Rand.Next(1, Config.WoodSellCount + 1) } }; this.Foods = new List <Item>(); int count = Helper.Rand.Next(1, Config.SellFoodCount + 1); for (int x = 0; x < count; x++) { PlantType plant = Helper.GetRandomPlantType(); while (plant.Food < 1) { plant = Helper.GetRandomPlantType(); } Foods.Add(new Item() { Name = plant.Name, Count = Helper.Rand.Next(1, Config.FoodSellCount + 1) }); } this.Seeds = new List <Item>(); count = Helper.Rand.Next(1, Config.SellSeedCount + 1); for (int x = 0; x < count; x++) { PlantType plant = Helper.GetRandomPlantType(); Seeds.Add(new Item() { Name = plant.Name, Count = Helper.Rand.Next(1, Config.SeedSellCount + 1) }); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { //fit to the bg graphics.PreferredBackBufferWidth = 1024; graphics.PreferredBackBufferHeight = 768; //graphics.IsFullScreen = true; graphics.ApplyChanges(); Content.RootDirectory = "Content"; new FpsCounter(this, new Vector2(graphics.GraphicsDevice.Viewport.Width - 25, 5)); //displays FPS ConstantsForm c = new ConstantsForm(); c.Show(); rd = new MouseEventsManager(this); Vector2 startingPoint = new Vector2(Random.Next(GraphicsDevice.Viewport.Width), Random.Next(GraphicsDevice.Viewport.Height)); antHill = new AntHill(this, startingPoint); this.reservoir = new Pools(this); this.Cemeteries = new List <Cemetery>(); //ajout des fourmis for (int i = 0; i < NUMBER_ANTS; i++) { reservoir.pickAnt(startingPoint, 0f, 0); } //ajout de la bouffe for (int i = 0; i < NUMBER_FOOD; i++) { Foods.Add(new Food(this, new Vector2(Random.Next(GraphicsDevice.Viewport.Width), Random.Next(GraphicsDevice.Viewport.Height)), 500)); } this.IsMouseVisible = true; base.Initialize(); }
private void AddMethod(object obj) { try { Caters.Model.Factory.FoodFactory food = null; if ((string)obj == "Mashroom") { MashroomsCustomNos = new ObservableCollection <int>(); food = new Model.Factory.PizzaFactory.MashroomFactory(); Foods.Add(food.GetFood()); MashroomCount++; AddDropDown(MashroomCount, obj as string); } else if ((string)obj == "Panner") { PannerCustomNos = new ObservableCollection <int>(); food = new Model.Factory.PizzaFactory.PannerFactory(); Foods.Add(food.GetFood()); PannerCount++; AddDropDown(PannerCount, obj as string); } else if ((string)obj == "SevenUp") { SevenUpCustomNos = new ObservableCollection <int>(); food = new Model.Factory.DrinkFactory.SevenUpFactory(); Foods.Add(food.GetFood()); SevenUpCount++; AddDropDown(SevenUpCount, obj as string); } addDummyData(food); } catch (Exception ex) { throw ex; } }