Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Menu              myMenu            = new Menu();
            RoomForSmokers    roomForSmokers    = new RoomForSmokers();
            RoomForNonSmokers roomForNonSmokers = new RoomForNonSmokers();
            List <Waiter>     listOfWaiters     = new List <Waiter>();
            Waiter            Ivan = new Waiter();
            Waiter            Petr = new Waiter();

            listOfWaiters.Add(Ivan);
            listOfWaiters.Add(Petr);
            List <Cooker> listOfCookers = new List <Cooker>();
            Cooker        Alesya        = new Cooker();

            listOfCookers.Add(Alesya);
            List <Guest> listOfGuests = new List <Guest>();
            Guest        Aleksandr    = new Guest();

            listOfGuests.Add(Aleksandr);
            roomForNonSmokers.Tables[1].GuestAtTable = Aleksandr;
            Ivan.TablesOfWaiter.Add(roomForNonSmokers.Tables[1]);
            Order AleksandrOrder = new Order();

            AleksandrOrder.ListOfDishesInOrder.Add(myMenu.ListOfDishesInMenu[1]);
            Ivan.ServeOrder(AleksandrOrder, Alesya);

            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            ILogger logger = new ConsoleLogger();
            Cooker  cooker = new Cooker();

            logger.Log("Приготорление салата...");
            List <IVegetable> ingredients = new List <IVegetable>();

            ingredients.Add(new Carrot());
            ingredients.Add(new Potato());
            ingredients.Add(new Pepper());
            ingredients.Add(new Tomato());
            ingredients.Add(new Cucumber());
            ingredients.Add(new Pepper());
            cooker.CreateSalad(ingredients, "Мимоза");
            logger.Log("Салат мимоза создан. Калорийность равна:");
            Salad currentSalad = cooker.GetSaladList().FirstOrDefault(saladItem => saladItem.Name == "Мимоза");

            logger.Log(currentSalad.Calories.ToString());
            logger.Log("Продукты отсортированы по калорийности:");
            LogCollection(currentSalad.GetSortIngredByCalories());
            logger.Log("Продукты отсортированы по кол-ву белков:");
            LogCollection(currentSalad.GetSortIngredByProtein());
            logger.Log("Продукты отсортированы по кол-ву жиров:");
            LogCollection(currentSalad.GetSortIngredByFats());
            logger.Log("Продукты отсортированы по кол-ву углеводов:");
            LogCollection(currentSalad.GetSortIngredByCarbohydrates());
            logger.Log("Овощи по в калорийном диапазоне от 100ед. до 190ед.");
            LogCollection(currentSalad.GetVegetablesInCaloriesRange(100, 190));
        }
Ejemplo n.º 3
0
 public void Initialize(Cooker cooker)
 {
     Cooker              = cooker;
     Cooker.FryingEvent += OnCook;
     _isFrying           = true;
     _isLanded           = false;
 }
Ejemplo n.º 4
0
        // GET: Home/Delete/5/tv
        public ActionResult Delete(int?id, string device)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            switch (device)
            {
            case "Tv":
                Tv tv = db.Tvs.Find(id);
                if (tv != null)
                {
                    db.Tvs.Remove(tv);
                    db.SaveChanges();
                }
                break;

            case "Fridge":
                Fridge fridge = db.Fridges.Find(id);
                if (fridge != null)
                {
                    db.Fridges.Remove(fridge);
                    db.SaveChanges();
                }
                break;

            case "Lamp":
                Lamp lamp = db.Lamps.Find(id);
                if (lamp != null)
                {
                    db.Lamps.Remove(lamp);
                    db.SaveChanges();
                }
                break;

            case "Cooker":
                Cooker cooker = db.Cookers.Find(id);
                if (cooker != null)
                {
                    db.Cookers.Remove(cooker);
                    db.SaveChanges();
                }
                break;

            case "Microwave":
                Microwave microwave = db.Microwaves.Find(id);
                if (microwave != null)
                {
                    db.Microwaves.Remove(microwave);
                    db.SaveChanges();
                }
                break;

            default:
                break;
            }
            Session["SelectedDevice"] = null;
            Session["DeviceConsole"]  = null;
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public TimeSpan MakeOrder(DishDTO dishDTO, ICookerService cookerSv, ICookService cookSv, IDishService dishSv)
        {
            if (dishDTO == null)
            {
                throw new NullReferenceException();
            }

            DateTime orderTime = DateTime.Now;

            Dish dish = dishSv.Find(dishDTO.Id);

            Cooker cooker = cookerSv.FindCooker(dish);
            Cook   cook   = cookSv.FindCook();

            TimeSpan cookerTimeToCook = cookerSv.TimeToCook(dish, cooker, orderTime);
            TimeSpan cookTimeToCook   = cookSv.TimeToCook(dish, cook, orderTime);
            TimeSpan maxCookingTime   = cookerTimeToCook >= cookTimeToCook ? cookerTimeToCook : cookTimeToCook;

            DateTime finishTime = orderTime.Add(maxCookingTime);

            cookerSv.Update(cooker, finishTime);
            cookSv.Update(cook, finishTime);

            AddOrder(orderTime, finishTime, dish, cook, cooker);
            _db.Save();

            return(maxCookingTime);
        }
Ejemplo n.º 6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Cooker cooker = CookersRepo.Find(id);

            CookersRepo.Remove(cooker);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 7
0
        public TimeSpan TimeToCook(Dish dish, Cooker cooker, DateTime orderTime)
        {
            if (dish == null)
            {
                throw new NullReferenceException();
            }

            if (dish.CookerType == null)
            {
                return(TimeSpan.Zero);
            }

            if (cooker == null)
            {
                throw new NullReferenceException();
            }

            if (cooker.CookerType != dish.CookerType)
            {
                throw new Exception("This applianceType can`t cook this dish!");
            }

            TimeSpan cookingTime =
                orderTime < cooker.FinishTime
                ? (cooker.FinishTime - orderTime) + dish.CookingTime
                : orderTime < (cooker.FinishTime + cooker.CoolingTime)
                ? dish.CookingTime
                : cooker.WarmUpTime + dish.CookingTime;

            return(cookingTime);
        }
Ejemplo n.º 8
0
        public void Delete(int id)
        {
            Cooker item = _db.Cookers.Find(id);

            if (item != null)
            {
                _db.Cookers.Remove(item);
            }
        }
Ejemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "Id,Name,Email,Password")] Cooker cooker)
 {
     if (ModelState.IsValid)
     {
         CookersRepo.Edit(cooker);
         return(RedirectToAction("Index"));
     }
     return(View(cooker));
 }
Ejemplo n.º 10
0
        public void Update(Cooker cooker, DateTime finishTime)
        {
            if (cooker == null)
            {
                return;
            }

            cooker.FinishTime = finishTime;

            _db.CookerRepository.Update(cooker); //!
        }
Ejemplo n.º 11
0
        static void Main()
        {
            var cooker = new Cooker();
            var potato = new Potato();

            cooker.CheckIfPotatoIsReadyForCooking(potato);

            var cellValidator = new CellValidator();

            cellValidator.VisitedCell();
        }
Ejemplo n.º 12
0
        // GET: Home/Create/tv
        public ActionResult Create(string device)
        {
            switch (device)
            {
            case "Tv":
                Tv tv = new Tv();
                db.Tvs.Add(tv);
                db.SaveChanges();
                Session["SelectedDevice"] = tv;
                Session["DeviceConsole"]  = new DeviceConsole(tv);
                break;

            case "Fridge":
                Fridge fridge = new Fridge();
                db.Fridges.Add(fridge);
                db.SaveChanges();
                Session["SelectedDevice"] = fridge;
                Session["DeviceConsole"]  = new DeviceConsole(fridge);
                break;

            case "Lamp":
                Lamp lamp = new Lamp();
                db.Lamps.Add(lamp);
                db.SaveChanges();
                Session["SelectedDevice"] = lamp;
                Session["DeviceConsole"]  = new DeviceConsole(lamp);

                break;

            case "Cooker":
                Cooker cooker = new Cooker();
                db.Cookers.Add(cooker);
                db.SaveChanges();
                Session["SelectedDevice"] = cooker;
                Session["DeviceConsole"]  = new DeviceConsole(cooker);

                break;

            case "Microwave":
                Microwave microwave = new Microwave();
                db.Microwaves.Add(microwave);
                db.SaveChanges();
                Session["SelectedDevice"] = microwave;
                Session["DeviceConsole"]  = new DeviceConsole(microwave);
                break;

            default:
                break;
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 13
0
        // Create
        public void Create(string device)
        {
            switch (device)
            {
            case "Tv":
                Tv tv = new Tv();
                db.Tvs.Add(tv);
                db.SaveChanges();
                Session["SelectedDevice"] = tv;
                Session["DeviceConsole"]  = new DeviceConsole(tv);
                break;

            case "Fridge":
                Fridge fridge = new Fridge();
                db.Fridges.Add(fridge);
                db.SaveChanges();
                Session["SelectedDevice"] = fridge;
                Session["DeviceConsole"]  = new DeviceConsole(fridge);
                break;

            case "Lamp":
                Lamp lamp = new Lamp();
                db.Lamps.Add(lamp);
                db.SaveChanges();
                Session["SelectedDevice"] = lamp;
                Session["DeviceConsole"]  = new DeviceConsole(lamp);
                break;

            case "Cooker":
                Cooker cooker = new Cooker();
                db.Cookers.Add(cooker);
                db.SaveChanges();
                Session["SelectedDevice"] = cooker;
                Session["DeviceConsole"]  = new DeviceConsole(cooker);
                break;

            case "Microwave":
                Microwave microwave = new Microwave();
                db.Microwaves.Add(microwave);
                db.SaveChanges();
                Session["SelectedDevice"] = microwave;
                Session["DeviceConsole"]  = new DeviceConsole(microwave);
                break;

            default:
                break;
            }
            selectedDevice = (Session["SelectedDevice"] as Device);
            deviceConsole  = (Session["DeviceConsole"] as DeviceConsole);
            RefreshPage();
        }
Ejemplo n.º 14
0
 public ActionResult Create(Cooker cooker)
 {
     ViewBag.danhSachDauBep = new VendorDao().ListAll();
     try
     {
         var result = new CookerDao().Insert(cooker);
         return(RedirectToAction("Index", "Cooker", new { vendorId = cooker.VendorId }));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         return(View(cooker));
     }
 }
Ejemplo n.º 15
0
        // GET: Cookers/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cooker cooker = CookersRepo.Find(id);

            if (cooker == null)
            {
                return(HttpNotFound());
            }
            return(View(cooker));
        }
Ejemplo n.º 16
0
 public ActionResult Edit(Cooker cooker)
 {
     try
     {
         var result   = new CookerDao().Update(cooker);
         var VendorId = new CookerDao().GetCookerById(cooker.ID).VendorId;
         return(RedirectToAction("Index", "Cooker", new { vendorId = VendorId }));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("", ex.Message);
         ViewBag.danhSachGianHang = new VendorDao().ListAll();
         ViewBag.gian_hang        = new VendorDao().GetVendorById(cooker.VendorId);
         return(View(cooker));
     }
 }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            Conteiner conteiner = new Conteiner();
            Cooker    cooker    = new Cooker();
            HotAction hotAction = new HotAction();

            //Make multicooker as facade class on actions above!
            MultiCooker multiCooker = new MultiCooker(conteiner, hotAction, cooker);

            //Make a boiling water
            multiCooker.MakeBoilingWater();

            //Make a meat dish
            multiCooker.MakeDishWithMeat();

            Console.ReadLine();
        }
Ejemplo n.º 18
0
        public long Update(Cooker entity)
        {
            var cooker = db.Cooker.Find(entity.ID);

            if (!string.IsNullOrEmpty(entity.Name))
            {
                cooker.Name = entity.Name;
            }
            if (!string.IsNullOrEmpty(entity.Email))
            {
                cooker.Email = entity.Email;
            }
            if (!string.IsNullOrEmpty(entity.Phone))
            {
                cooker.Phone = entity.Phone;
            }
            cooker.Status = entity.Status;
            db.SaveChanges();
            return(entity.ID);
        }
Ejemplo n.º 19
0
        public Cooker FindCooker(Dish dish)
        {
            if (dish == null)
            {
                throw new NullReferenceException();
            }

            if (dish.CookerType == null)
            {
                return(null);
            }

            Cooker cooker =
                _db.CookerRepository
                .GetAll()
                .Where(x => (x.CookerType.Id == dish.CookerType.Id))
                .OrderBy(x => x.FinishTime)
                .FirstOrDefault()
                ?? throw new Exception("There is no appliance to prepare this");

            return(cooker);
        }
Ejemplo n.º 20
0
 public long Insert(Cooker cooker)
 {
     db.Cooker.Add(cooker);
     db.SaveChanges();
     return(cooker.ID);
 }
Ejemplo n.º 21
0
        protected override void Seed(OrderContext db)
        {
            CookerType ct1 = new CookerType
            {
                Name = "Oven"
            };

            CookerType ct2 = new CookerType
            {
                Name = "Microwave"
            };

            Dish d1 = new Dish
            {
                Name        = "Salad",
                CookingTime = TimeSpan.FromSeconds(45),
                Weight      = 500
            };

            Dish d2 = new Dish
            {
                Name        = "Soup",
                CookingTime = TimeSpan.FromMinutes(5),
                CookerType  = ct1,
                Weight      = 450
            };

            Dish d3 = new Dish
            {
                Name        = "Pizza",
                CookingTime = TimeSpan.FromMinutes(3),
                CookerType  = ct2,
                Weight      = 600
            };

            Dish d4 = new Dish
            {
                Name        = "Pasta",
                CookingTime = TimeSpan.FromMinutes(10),
                CookerType  = ct1,
                Weight      = 250
            };

            Cook c1 = new Cook
            {
                SkillCoefficient = 1.2f,
                FinishTime       = DateTime.Now.AddHours(1)
            };

            Cook c2 = new Cook
            {
                SkillCoefficient = 1.5f,
                FinishTime       = DateTime.Now.AddHours(1)
            };

            Cooker cr1 = new Cooker
            {
                CookerType  = ct1,
                CoolingTime = TimeSpan.FromHours(1),
                WarmUpTime  = TimeSpan.FromHours(2),
                FinishTime  = DateTime.Now.AddHours(-2)
            };

            Cooker cr2 = new Cooker
            {
                CookerType  = ct2,
                CoolingTime = TimeSpan.FromSeconds(30),
                WarmUpTime  = TimeSpan.FromSeconds(30),
                FinishTime  = DateTime.Now
            };

            db.CookerTypes.Add(ct1);
            db.CookerTypes.Add(ct2);

            db.Dishes.Add(d1);
            db.Dishes.Add(d2);
            db.Dishes.Add(d3);
            db.Dishes.Add(d4);

            db.Cooks.Add(c1);
            db.Cooks.Add(c2);

            db.Cookers.Add(cr1);
            db.Cookers.Add(cr2);

            db.SaveChanges();
        }
Ejemplo n.º 22
0
        private void AddOrder(DateTime orderTime, DateTime finishTime, Dish dish, Cook cook, Cooker cooker)
        {
            Order order = new Order()
            {
                OrderTime  = orderTime,
                FinishTime = finishTime,
                DishId     = dish.Id,
                CookId     = cook.Id
            };

            if (cooker != null)
            {
                order.CookerId = cooker.Id;
            }

            _db.OrderRepository.Add(order);
        }
Ejemplo n.º 23
0
        public KitchenModel()
        {
            personnel = new List <Sprite>();
            objects   = new List <Sprite>();

            Desk                 kitchenDesk            = new Desk();
            Sink                 kitchenSink            = new Sink();
            HeatingPlate         plaque1                = new HeatingPlate();
            HeatingPlate         plaque2                = new HeatingPlate();
            HeatingPlate         plaque3                = new HeatingPlate();
            Dishwasher           laveVaisselle          = new Dishwasher();
            LaundryMachine       laveLinge              = new LaundryMachine();
            DishesStock          stockVaisselle         = new DishesStock();
            DirtyDishesStock     stockVaiselleSale      = new DirtyDishesStock();
            Fridge               kitchenFridge          = new Fridge();
            KitchenMaterialStock kitchenMaterialStock   = new KitchenMaterialStock();
            IngredientStock      kitchenIngredientStock = new IngredientStock();

            objects.Add(kitchenDesk.Sprite);
            objects.Add(kitchenSink.Sprite);
            objects.Add(plaque1.Sprite);
            objects.Add(plaque2.Sprite);
            objects.Add(plaque3.Sprite);
            objects.Add(laveVaisselle.Sprite);
            objects.Add(laveLinge.Sprite);
            objects.Add(stockVaisselle.Sprite);
            objects.Add(stockVaiselleSale.Sprite);
            objects.Add(kitchenFridge.Sprite);
            objects.Add(kitchenMaterialStock.Sprite);
            objects.Add(kitchenIngredientStock.Sprite);


            Plunger plongeur   = new Plunger(kitchenDesk, stockVaiselleSale, stockVaisselle, laveVaisselle, laveLinge, kitchenSink);
            Clerk   commis1    = new Clerk(kitchenMaterialStock, kitchenIngredientStock, kitchenFridge, kitchenSink, "GabinCuisto");
            Clerk   commis2    = new Clerk(kitchenMaterialStock, kitchenIngredientStock, kitchenFridge, kitchenSink, "MaxCuisto");
            Cooker  cuisinier1 = new Cooker(commis1, commis2, kitchenMaterialStock, kitchenIngredientStock, kitchenFridge, "BenjaminCuisto");
            Cooker  cuisinier2 = new Cooker(commis1, commis2, kitchenMaterialStock, kitchenIngredientStock, kitchenFridge, "PirminCuisto");
            Chef    chef       = new Chef(cuisinier1, cuisinier2, kitchenDesk);


            personnel.Add(chef.Sprite);
            personnel.Add(cuisinier1.Sprite);
            personnel.Add(cuisinier2.Sprite);
            personnel.Add(commis1.Sprite);
            personnel.Add(commis2.Sprite);
            personnel.Add(plongeur.Sprite);


            socket = new SocketApp();

            SocketListener.kitchenDesk = kitchenDesk;

            // Ajouter des abonnés observer à l'observable Comptoir
            kitchenDesk.AttachChef(chef);
            kitchenDesk.AttachPlunger(plongeur);
            kitchenDesk.AttachSocket(socket);



            //// Créations des Ingrédients
            //Ingredient steak = new Ingredient("Steak", "Viande");
            //Ingredient poulet = new Ingredient("Poulet", "Viande");
            //Ingredient poisson = new Ingredient("Poisson", "Poisson");
            //Ingredient pain = new Ingredient("Pain", "Pain");
            //Ingredient salade = new Ingredient("Salade", "Vegetables");
            //Ingredient tomate = new Ingredient("Tomate", "Vegetables");
            //Ingredient oignon = new Ingredient("Oignon", "Vegetables");
            //Ingredient cheddar = new Ingredient("Cheddar", "Frommage");
            //Ingredient raclette = new Ingredient("Raclette", "Fromage");
            //Ingredient sauce = new Ingredient("Sauce", "Sauce");

            //// Instanciation Object Cuisine Material
            //KitchenKnife kitchenKnife = new KitchenKnife();
            //Pans kitchenCasserolle = new Pans();
            //Stove kitchenPoêle = new Stove();
            //WoodenSpoon kitchenCuillière = new WoodenSpoon();
            //SaladBowl kitchenBolSalade = new SaladBowl();


            //// Creation des etapes des recettes
            //RecipeStep prepareSteak = new RecipeStep("Cuire le Steak", 10);
            //prepareSteak.IngredientQuantities.Add(new IngredientQuantity(1, steak));
            //prepareSteak.ListUstencils.Add(kitchenPoêle);

            //RecipeStep preparePoulet = new RecipeStep("Cuire le Poulet", 10);
            //preparePoulet.IngredientQuantities.Add(new IngredientQuantity(1, poulet));
            //preparePoulet.ListUstencils.Add(kitchenPoêle);

            //RecipeStep preparePoisson = new RecipeStep("Cuire le Poisson", 10);
            //preparePoisson.IngredientQuantities.Add(new IngredientQuantity(1, poisson));
            //preparePoisson.ListUstencils.Add(kitchenPoêle);

            //RecipeStep prepareVegetables = new RecipeStep("Preparer les légumes", 5);
            //prepareVegetables.IngredientQuantities.Add(new IngredientQuantity(1, salade));
            //prepareVegetables.IngredientQuantities.Add(new IngredientQuantity(2, tomate));
            //prepareVegetables.IngredientQuantities.Add(new IngredientQuantity(1, oignon));
            //prepareVegetables.ListUstencils.Add(kitchenBolSalade);
            //prepareVegetables.ListUstencils.Add(kitchenCuillière);
            //prepareVegetables.ListUstencils.Add(kitchenKnife);

            //RecipeStep prepareRaclette = new RecipeStep("Préparer le frommage à Raclette", 5);
            //prepareRaclette.IngredientQuantities.Add(new IngredientQuantity(2, raclette));
            //prepareRaclette.ListUstencils.Add(kitchenKnife);

            //RecipeStep prepareCheddar = new RecipeStep("Préparer le Cheddar", 5);
            //prepareCheddar.IngredientQuantities.Add(new IngredientQuantity(2, cheddar));
            //prepareCheddar.ListUstencils.Add(kitchenKnife);

            //RecipeStep assemblerBurger = new RecipeStep("Assembler le Burger", 5);
            //assemblerBurger.IngredientQuantities.Add(new IngredientQuantity(1, pain));
            //assemblerBurger.IngredientQuantities.Add(new IngredientQuantity(1, sauce));


            //// Creations des plats
            //Dish burgerClassic = new Dish(1, "Burger Classique");
            //burgerClassic.Recipe.Add(prepareSteak);
            //burgerClassic.Recipe.Add(prepareVegetables);
            //burgerClassic.Recipe.Add(prepareCheddar);
            //burgerClassic.Recipe.Add(assemblerBurger);

            //Dish burgerChicken = new Dish(2, "Burger Poulet");
            //burgerChicken.Recipe.Add(preparePoulet);
            //burgerChicken.Recipe.Add(prepareVegetables);
            //burgerChicken.Recipe.Add(prepareCheddar);
            //burgerChicken.Recipe.Add(assemblerBurger);

            //Dish burgerMountain = new Dish(3, "Burger Montagnard");
            //burgerMountain.Recipe.Add(prepareSteak);
            //burgerMountain.Recipe.Add(prepareVegetables);
            //burgerMountain.Recipe.Add(prepareCheddar);
            //burgerMountain.Recipe.Add(assemblerBurger);

            //Dish burgerVegan = new Dish(4, "Burger Vegan");
            //burgerVegan.Recipe.Add(preparePoisson);
            //burgerVegan.Recipe.Add(prepareVegetables);
            //burgerVegan.Recipe.Add(prepareCheddar);
            //burgerVegan.Recipe.Add(prepareRaclette);
            //burgerVegan.Recipe.Add(assemblerBurger);

            DomainApp domainApp = new DomainApp();

            Console.WriteLine("Instanciation du Controller sans problèmes");
        }
Ejemplo n.º 24
0
 public void Update(Cooker item)
 {
     _db.Entry(item).State = EntityState.Modified;
 }
Ejemplo n.º 25
0
 public void Add(Cooker item)
 {
     _db.Cookers.Add(item);
 }
Ejemplo n.º 26
0
    protected void GenerateCooker()
    {
        Cooker c = Instantiate(cookerPrefab, exitPosition, Quaternion.LookRotation(queueDirection), cookerContainer.transform);

        c.gameObject.SetActive(true);
    }
Ejemplo n.º 27
0
        // Delete
        protected void LinkButtonDelete_Click(object sender, EventArgs e)
        {
            if (selectedDevice != null)
            {
                string device = (selectedDevice as Device).TypeDevice();
                int    id     = (selectedDevice as Device).Id;

                switch (device)
                {
                case "Tv":
                    Tv tv = db.Tvs.Find(id);
                    if (tv != null)
                    {
                        db.Tvs.Remove(tv);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(tv.Id, tv.TypeDevice());
                    }
                    break;

                case "Fridge":
                    Fridge fridge = db.Fridges.Find(id);
                    if (fridge != null)
                    {
                        db.Fridges.Remove(fridge);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(fridge.Id, fridge.TypeDevice());
                    }
                    break;

                case "Lamp":
                    Lamp lamp = db.Lamps.Find(id);
                    if (lamp != null)
                    {
                        db.Lamps.Remove(lamp);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(lamp.Id, lamp.TypeDevice());
                    }
                    break;

                case "Cooker":
                    Cooker cooker = db.Cookers.Find(id);
                    if (cooker != null)
                    {
                        db.Cookers.Remove(cooker);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(cooker.Id, cooker.TypeDevice());
                    }
                    break;

                case "Microwave":
                    Microwave microwave = db.Microwaves.Find(id);
                    if (microwave != null)
                    {
                        db.Microwaves.Remove(microwave);
                        db.SaveChanges();
                        PanelDevicesDeleteControl(microwave.Id, microwave.TypeDevice());
                    }
                    break;

                default:
                    break;
                }
                Session["SelectedDevice"] = null;
                Session["DeviceConsole"]  = null;
                selectedDevice            = null;
                deviceConsole             = null;
                RefreshPage();
            }
        }
Ejemplo n.º 28
0
        public static Control Drawe(Cooker cooker)
        {
            LinkButton linkButtonCooker = new LinkButton()
            {
                CssClass = "device-cooker"
            };
            Panel panelContent = new Panel()
            {
                CssClass = "content"
            };
            Panel panelProperty = new Panel()
            {
                CssClass = "property"
            };
            Panel panelStove1 = new Panel()
            {
                CssClass = "stove1"
            };
            Panel panelStove2 = new Panel()
            {
                CssClass = "stove2"
            };
            Panel panelStove3 = new Panel()
            {
                CssClass = "stove3"
            };
            Panel panelStove4 = new Panel()
            {
                CssClass = "stove4"
            };
            Panel panelTemp1 = new Panel()
            {
                CssClass = "temp1"
            };
            Panel panelTemp2 = new Panel()
            {
                CssClass = "temp2"
            };
            Panel panelTemp3 = new Panel()
            {
                CssClass = "temp3"
            };
            Panel panelTemp4 = new Panel()
            {
                CssClass = "temp4"
            };
            Label labelText1 = new Label()
            {
                CssClass = "text"
            };
            Label labelTextValue1 = new Label()
            {
                CssClass = "text-value"
            };
            Label labelText2 = new Label()
            {
                CssClass = "text"
            };
            Label labelTextValue2 = new Label()
            {
                CssClass = "text-value"
            };
            Label labelText3 = new Label()
            {
                CssClass = "text"
            };
            Label labelTextValue3 = new Label()
            {
                CssClass = "text-value"
            };
            Label labelText4 = new Label()
            {
                CssClass = "text"
            };
            Label labelTextValue4 = new Label()
            {
                CssClass = "text-value"
            };

            panelStove1.Attributes.CssStyle.Add("opacity", cooker.TempPercent(cooker.Temp1, cooker.MaxTemp1));
            panelStove2.Attributes.CssStyle.Add("opacity", cooker.TempPercent(cooker.Temp2, cooker.MaxTemp2));
            panelStove3.Attributes.CssStyle.Add("opacity", cooker.TempPercent(cooker.Temp3, cooker.MaxTemp3));
            panelStove4.Attributes.CssStyle.Add("opacity", cooker.TempPercent(cooker.Temp4, cooker.MaxTemp4));
            labelText1.Attributes.CssStyle.Add("display", "block");
            labelTextValue1.Attributes.CssStyle.Add("display", "block");
            labelText2.Attributes.CssStyle.Add("display", "block");
            labelTextValue2.Attributes.CssStyle.Add("display", "block");
            labelText3.Attributes.CssStyle.Add("display", "block");
            labelTextValue3.Attributes.CssStyle.Add("display", "block");
            labelText4.Attributes.CssStyle.Add("display", "block");
            labelTextValue4.Attributes.CssStyle.Add("display", "block");

            labelText1.Text      = "TEMP1:";
            labelTextValue1.Text = cooker.Temp1.ToString();
            labelText2.Text      = "TEMP2:";
            labelTextValue2.Text = cooker.Temp2.ToString();
            labelText3.Text      = "TEMP3:";
            labelTextValue3.Text = cooker.Temp3.ToString();
            labelText4.Text      = "TEMP4:";
            labelTextValue4.Text = cooker.Temp4.ToString();

            panelTemp1.Controls.Add(labelText1);
            panelTemp1.Controls.Add(labelTextValue1);
            panelTemp2.Controls.Add(labelText2);
            panelTemp2.Controls.Add(labelTextValue2);
            panelTemp3.Controls.Add(labelText3);
            panelTemp3.Controls.Add(labelTextValue3);
            panelTemp4.Controls.Add(labelText4);
            panelTemp4.Controls.Add(labelTextValue4);

            panelProperty.Controls.Add(panelStove1);
            panelProperty.Controls.Add(panelStove2);
            panelProperty.Controls.Add(panelStove3);
            panelProperty.Controls.Add(panelStove4);
            panelProperty.Controls.Add(panelTemp1);
            panelProperty.Controls.Add(panelTemp2);
            panelProperty.Controls.Add(panelTemp3);
            panelProperty.Controls.Add(panelTemp4);

            panelContent.Controls.Add(panelProperty);
            linkButtonCooker.Controls.Add(panelContent);
            linkButtonCooker.Controls.Add(DeviceBgAsp.Drawe());

            linkButtonCooker.Attributes.Add("data-device", (cooker as Device).TypeDevice());
            linkButtonCooker.Attributes.Add("data-id", cooker.Id.ToString());

            return(linkButtonCooker);
        }
Ejemplo n.º 29
0
    void Update()
    {
        float horizontalMovement = Input.GetAxis("Horizontal");
        float verticalMovement   = Input.GetAxis("Vertical");

        moveTo = new Vector3(horizontalMovement, 0, verticalMovement);

        if (moveTo != Vector3.zero)
        {
            animator.SetBool("Walking", true);
            animator.SetBool("IDLE", false);
            animator.SetBool("Pulling", false);
            animator.SetBool("Cutting", false);
        }
        else
        {
            if (isChopping)
            {
                animator.SetBool("IDLE", false);
                animator.SetBool("Walking", false);
                animator.SetBool("Pulling", false);
                animator.SetBool("Cutting", true);
            }
            else
            {
                animator.SetBool("IDLE", true);
                animator.SetBool("Walking", false);
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            Furniture currentFurniture = furnitureDetection.GetSelected();
            if (currentFurniture != null)
            {
                Holder currentFurnitureHolder = currentFurniture.GetComponent <Holder>();
                //Give
                if (currentFurnitureHolder != null)
                {
                    //Si el jugador tiene un objeto
                    if (PlayerHolder.HasMovable())
                    {
                        //Si ambos tienen objeto no lo cambia, se queda igual
                        if (PlayerHolder.HasMovable() && currentFurnitureHolder.HasMovable())
                        {
                            MovableObject furnitureMovable = currentFurnitureHolder.GetMovable();
                            MovableObject playerMovable    = PlayerHolder.GetMovable();

                            PlayerHolder.SetMovable(playerMovable);
                            currentFurnitureHolder.SetMovable(furnitureMovable);
                        }
                        //Si solo uno tiene objeto
                        else
                        {
                            MovableObject movable = PlayerHolder.GetMovable();
                            Trash         trash   = currentFurniture.GetComponent <Trash>();
                            Cooker        cooker  = currentFurniture.GetComponent <Cooker>();
                            Chopper       chopper = currentFurniture.GetComponent <Chopper>();
                            //Si el mueble es el basurero
                            if (trash != null && movable.GetComponent <Food>())
                            {
                                PlayerHolder.RemoveMovable();
                                Destroy(movable.gameObject);

                                /*Food food = movable.GetComponent<Food>();
                                 * if (food!= null)
                                 * {
                                 *  food.Delete();
                                 * }*/
                            }
                            //Solo acepta basura en el basurero
                            if (trash != null && movable.GetComponent <Food>() == false)
                            {
                                MovableObject furnitureMovable = currentFurnitureHolder.GetMovable();
                                MovableObject playerMovable    = PlayerHolder.GetMovable();

                                PlayerHolder.SetMovable(playerMovable);
                                currentFurnitureHolder.SetMovable(furnitureMovable);
                            }
                            //Solo acepta la olla en los hornos
                            if (cooker != null && movable.GetComponent <Container>() == false)
                            {
                                MovableObject furnitureMovable = currentFurnitureHolder.GetMovable();
                                MovableObject playerMovable    = PlayerHolder.GetMovable();

                                PlayerHolder.SetMovable(playerMovable);
                                currentFurnitureHolder.SetMovable(furnitureMovable);
                            }
                            if (chopper != null && movable.GetComponent <Food>() == false)
                            {
                                MovableObject furnitureMovable = currentFurnitureHolder.GetMovable();
                                MovableObject playerMovable    = PlayerHolder.GetMovable();

                                PlayerHolder.SetMovable(playerMovable);
                                currentFurnitureHolder.SetMovable(furnitureMovable);
                            }
                            //Si tiene el objeto y lo que tiene en frente tiene la olla
                            else
                            {
                                MovableObject furnitureMovable = currentFurnitureHolder.GetMovable();
                                if (furnitureMovable != null)
                                {
                                    Container furnitureContainer = furnitureMovable.GetComponent <Container>();
                                    if (furnitureContainer != null)
                                    {
                                        Food food = movable.GetComponent <Food>();
                                        if (food != null)
                                        {
                                            if (furnitureContainer.CanAccept(food))
                                            {
                                                PlayerHolder.RemoveMovable();
                                            }
                                        }
                                    }
                                }
                                currentFurnitureHolder.SetMovable(movable);
                                PlayerHolder.RemoveMovable();
                            }
                        }
                    }
                    //Pick
                    else
                    {
                        if (currentFurnitureHolder.HasMovable())
                        {
                            MovableObject movable = currentFurnitureHolder.GetMovable();
                            PlayerHolder.SetMovable(movable);
                            currentFurnitureHolder.RemoveMovable();
                        }
                        else
                        {
                            IngredientSpawner ingred = currentFurniture.GetComponent <IngredientSpawner>();
                            if (ingred != null)
                            {
                                MovableObject movable = ingred.GetIngredient();
                                PlayerHolder.SetMovable(movable);
                            }
                        }
                    }
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            Furniture currentFurniture = furnitureDetection.GetSelected();
            if (currentFurniture != null)
            {
                Chopper currentChopper = currentFurniture.GetComponent <Chopper>();
                //Comienza a cortar
                if (currentChopper != null)
                {
                    isChopping = currentChopper.StartChopping(this);
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            tempForce = force;
            Debug.Log("La fuerza temporal es");
            Debug.Log(tempForce);
            timer += Time.deltaTime;
            while (timer < 10.0f)
            {
                timer += Time.deltaTime;
                force  = forceBoost;
                Debug.Log("La fuerza es");
                Debug.Log(force);
            }
            force = tempForce;
            Debug.Log("La fuerza es");
            Debug.Log(force);
        }
    }