Пример #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nom,Longitude,Latitude,Adresse1,Adresse2,Ville,CP,Architecte,ImageURL,Periode_construction_debut,Periode_construction_fin,Style,Siteweb")] Batiment batiment)
        {
            if (id != batiment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(batiment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BatimentExists(batiment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(batiment));
        }
        public async Task <IActionResult> Edit(int id, [Bind("BatimentId,NomBatiment,URLPhoto,TypeBatiment,DescriptionBatiment,Longitude,Latitude,MonumentHistorique,DateConstruction,VilleId")] Batiment batiment)
        {
            if (id != batiment.BatimentId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(batiment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BatimentExists(batiment.BatimentId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VilleId"] = new SelectList(_context.Villes, "VilleId", "NomVille", batiment.VilleId);
            return(View(batiment));
        }
        public async Task <IActionResult> PutBatiment(int id, Batiment batiment)
        {
            if (id != batiment.Id)
            {
                return(BadRequest());
            }

            _context.Entry(batiment).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BatimentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <Batiment> > PostBatiment(Batiment batiment)
        {
            _context.Batiments.Add(batiment);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBatiment", new { id = batiment.Id }, batiment));
        }
Пример #5
0
        public BatimentViewModel(Batiment model, BatimentCulturel modelBatCulturel)
        {
            this.model            = model;
            this.modelBatCulturel = modelBatCulturel;

            ListDeStyle       = new List <SelectListItem>();
            ListeTypeBatiment = new List <SelectListItem>();
            ListeTypeCulture  = new List <SelectListItem>();

            foreach (var v in Enum.GetValues(typeof(Models.StyleBatiment)))
            {
                var itm = new SelectListItem(v.ToString(), ((int)v).ToString());
                ListDeStyle.Add(itm);
            }
            //IEnumerable<Models.StyleBatiment> values = (IEnumerable <Models.StyleBatiment>) Enum.GetValues(typeof(Models.StyleBatiment));
            //ListDeStyle = values.Select(v => new SelectListItem(v.ToString(),((int)v).ToString()));

            foreach (var v in Enum.GetValues(typeof(Models.TypeBatiment)))
            {
                var itm = new SelectListItem(v.ToString(), ((int)v).ToString());
                ListeTypeBatiment.Add(itm);
            }

            foreach (var v in Enum.GetValues(typeof(Models.TypeCulturel)))
            {
                var itm = new SelectListItem(v.ToString(), ((int)v).ToString());
                ListeTypeCulture.Add(itm);
            }
        }
Пример #6
0
        // GET: /Batiment/Delete/

        public ActionResult DeleteBatiment(int id = 0)
        {
            Batiment batiment = batimentRepository.Get(id);

            if (batiment == null)
            {
                return(HttpNotFound());
            }
            else
            {
                this.batimentRepository.Delete(id);
                this.batimentRepository.Save();

                return(RedirectToAction("IndexBatiment"));
            }

            /* if (!Request.IsAjaxRequest())
             * {
             *   return View(batiment);
             * }
             * else
             * {
             *
             *   return PartialView("_DeleteBatiment", batiment);
             * }*/
        }
Пример #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Batiment batiment = db.Batiments.Find(id);

            db.Batiments.Remove(batiment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #8
0
 public ActionResult EditBatiment(Batiment batiment)
 {
     if (ModelState.IsValid)
     {
         batimentRepository.Entry(batiment);
         batimentRepository.Save();
         return(RedirectToAction("IndexBatiment"));
     }
     return(View(batiment));
 }
Пример #9
0
 public ActionResult Edit([Bind(Include = "Id,NomBatiment,Niveau")] Batiment batiment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(batiment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(batiment));
 }
Пример #10
0
        public ActionResult Create([Bind(Include = "Id,NomBatiment,Niveau")] Batiment batiment)
        {
            if (ModelState.IsValid)
            {
                db.Batiments.Add(batiment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(batiment));
        }
Пример #11
0
        public ActionResult CreateBatiment(Batiment batiment)
        {
            if (ModelState.IsValid)
            {
                this.batimentRepository.Insert(batiment);
                this.batimentRepository.Save();
                return(RedirectToAction("IndexBatiment"));
            }

            return(View(batiment));
        }
Пример #12
0
    public void openBuildingManagement(Batiment bat)
    {
        if (this.isOpen())
        {
            return;
        }

        GameVariables.batimentSelectionne = bat;
        isMenuOpen = true;
        initUI();
        this.gameObject.SetActive(true);
    }
Пример #13
0
        static void Main(string[] args)
        {
            Batiment batiment1 = new Batiment("96 Jacques-Cartier", 3500, 3);

            Console.WriteLine(batiment1);
            Maison maison1 = new Maison("14 Adams", 850, 2, 4, "brique");

            Console.WriteLine(maison1);
            Entrepot entrepot1 = new Entrepot("123 boul. Industriel", 15000, 1, 8);

            Console.WriteLine(entrepot1);
        }
    private void buildMine()
    {
        if (minePrefab == null)
        {
            return;
        }

        Batiment bat = Instantiate(minePrefab);

        bat.name = "Batiment " + GameVariables.listBatiment.Count;
        GameVariables.listBatiment.Add(bat);
    }
        public async Task <IActionResult> Create([Bind("BatimentId,NomBatiment,URLPhoto,TypeBatiment,DescriptionBatiment,Longitude,Latitude,MonumentHistorique,DateConstruction,VilleId")] Batiment batiment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(batiment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["VilleId"] = new SelectList(_context.Villes, "VilleId", "NomVille", batiment.VilleId);
            return(View(batiment));
        }
Пример #16
0
        public async Task <IActionResult> Create([Bind("Id,Nom,Longitude,Latitude,Adresse1,Adresse2,Ville,CP,Architecte,ImageURL,Periode_construction_debut,Periode_construction_fin,Style,Siteweb,TypeCulturel")] Batiment batiment)
        //public async Task<IActionResult> Create(BatimentViewModel vm)
        {
            if (ModelState.IsValid)
            {
                _context.Add(batiment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(batiment));
            //return RedirectToAction("Index");
        }
Пример #17
0
        // GET: Batiments/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Batiment batiment = db.Batiments.Find(id);

            if (batiment == null)
            {
                return(HttpNotFound());
            }
            return(View(batiment));
        }
Пример #18
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Batiment = await _context.Batiment.FirstOrDefaultAsync(m => m.ID == id);

            if (Batiment == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Пример #19
0
        public ActionResult CreateBatiment(Batiment reg)
        {
            try
            {
                batiment.CreateBatiment(reg);
                batiment.SaveBatiment();

                return(RedirectToAction("GetBatiment"));
            }
            catch (Exception ex)
            {
                LogThread.WriteLine(ex.Message);
                return(RedirectToAction("Index", "Error"));
            }
        }
Пример #20
0
        /// <summary>
        /// Fonction qui retourne une carte.
        /// </summary>
        /// <param name="query">Requête à effectuer sur la BD</param>
        /// <returns>Une carte avec son effet.</returns>
        private static Carte Retrieve(string query)
        {
            Carte     resultat;
            DataSet   dsResultat;
            DataTable dtResultat;
            DataRow   drResultat;

            ConnectionBD = new MySqlConnexion();

            dsResultat = ConnectionBD.Query(query);
            dtResultat = dsResultat.Tables[0];
            drResultat = dtResultat.Rows[0];
            Effet effetCarte = null;

            if (drResultat["idEffet"] != DBNull.Value)
            {
                effetCarte = MySqlEffetService.RetrieveById((int)drResultat["idEffet"]);
            }
            if (drResultat["typeUnite"] != DBNull.Value) // TODO: vérifié si le if fonctionne sinon changé pour "null"
            {
                resultat = new Unite((int)drResultat["idCarte"]
                                     , (string)drResultat["nom"]
                                     , effetCarte
                                     , new Ressource((int)drResultat["coutCharronite"], (int)drResultat["coutBarilNucleaire"], (int)drResultat["coutAlainDollars"])
                                     , (int)drResultat["pointsAttaque"]
                                     , (int)drResultat["pointsDefense"]
                                     );
            }
            else if (drResultat["pointsDefense"] != DBNull.Value) // TODO: vérifié si le if fonctionne sinon changé pour "null"
            {
                resultat = new Batiment((int)drResultat["idCarte"]
                                        , (string)drResultat["nom"]
                                        , effetCarte
                                        , new Ressource((int)drResultat["coutCharronite"], (int)drResultat["coutBarilNucleaire"], (int)drResultat["coutAlainDollars"])
                                        , (int)drResultat["pointsDefense"]
                                        );
            }
            else
            {
                resultat = new Gadget((int)drResultat["idCarte"]
                                      , (string)drResultat["nom"]
                                      , effetCarte
                                      , new Ressource((int)drResultat["coutCharronite"], (int)drResultat["coutBarilNucleaire"], (int)drResultat["coutAlainDollars"])
                                      );
            }

            return(resultat);
        }
Пример #21
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Batiment = await _context.Batiments.FindAsync(id);

            if (Batiment != null)
            {
                _context.Batiments.Remove(Batiment);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Пример #22
0
        //Get
        public ActionResult EditBatiment(int id = 0)
        {
            Batiment batiment = batimentRepository.Get(id);

            if (batiment == null)
            {
                return(HttpNotFound());
            }
            if (!Request.IsAjaxRequest())
            {
                return(View(batiment));
            }
            else
            {
                return(PartialView("_EditBatiment", batiment));
            }
        }
Пример #23
0
        public ActionResult EditBatiment(Batiment reg)
        {
            try
            {
                var bat = batiment.FindBatimentByID(reg.idBatiment);
                //var bat2 = BissInventaireEntities.Instance.Batiment.Find(reg.idBatiment);
                batiment.UpdateBatimentDetached(reg);
                batiment.SaveBatiment();

                return(RedirectToAction("GetBatiment"));
            }
            catch (Exception ex)
            {
                LogThread.WriteLine(ex.Message);
                return(RedirectToAction("Index", "Error"));
            }
        }
    public void buildButtonPointerEnter(Batiment batiment)
    {
        costPopUp.gameObject.SetActive(true);

        if (batiment is Entrepot)
        {
            costPopUp.transform.SetParent(buidHouseButton.transform);
        }
        else if (batiment is Caserne)
        {
            costPopUp.transform.SetParent(buidMiliciaButton.transform);
        }
        else
        {
            if (batiment.typeHabitant == Batiment.role.Bucheron)
            {
                costPopUp.transform.SetParent(buidWoodLodgeButton.transform);
            }
            else if (batiment.typeHabitant == Batiment.role.Fermier)
            {
                costPopUp.transform.SetParent(buidFarmButton.transform);
            }
            else if (batiment.typeHabitant == Batiment.role.Marchand)
            {
                costPopUp.transform.SetParent(buidTraderButton.transform);
            }
            else if (batiment.typeHabitant == Batiment.role.Mineur)
            {
                costPopUp.transform.SetParent(buidMineButton.transform);
            }
            else if (batiment.typeHabitant == Batiment.role.Pretre)
            {
                costPopUp.transform.SetParent(buidMageButton.transform);
            }
        }

        costPopUp.updateFoodCost(batiment.priceMeat);
        costPopUp.updateWoodCost(batiment.priceWood);
        costPopUp.updateIronCost(batiment.priceGold);
        costPopUp.updateGoldCost(batiment.priceGold);
        costPopUp.updateManaCost(batiment.priceMana);

        costPopUp.GetComponent <RectTransform>().anchoredPosition = new Vector3(0, 0, 45);
    }
    //Milicia
    void addFirstFoundHabitantForType(Batiment.role type)
    {
        if (GameVariables.listHabitant.Count == 0 && GameVariables.batimentSelectionne.ListHabitants.Count < GameVariables.batimentSelectionne.nbrMaxHab)
        {
            return;
        }


        Batiment batiment = null;

        foreach (Batiment bat in GameVariables.listBatiment)
        {
            if (!bat.isEnDeplacement() && bat.typeHabitant == type && bat.ListHabitants.Count < bat.nbrMaxHab)
            {
                batiment = bat;
                break;
            }
        }

        if (batiment == null || batiment.ListHabitants.Count >= batiment.nbrMaxHab)
        {
            return;
        }

        List <Habitant> listMetierBat = GameVariables.getListMetier(batiment.typeHabitant);

        if (listMetierBat == null)
        {
            return;
        }

        Habitant villager = GameVariables.listHabitant[0];

        GameVariables.listHabitant.Remove(villager);

        villager.Spawn = batiment;
        GameObject o = villager.GetComponent <Role>().changementRole(batiment.typeHabitant.ToString());

        GameVariables.listHabitantAffecte.Add(villager);
        listMetierBat.Add(villager);
        batiment.ListHabitants.Add(o);
    }
    void removeFirstFoundHabitantForType(Batiment.role type)
    {
        Batiment batiment = null;

        foreach (Batiment bat in GameVariables.listBatiment)
        {
            if (!bat.isEnDeplacement() && bat.typeHabitant == type && bat.ListHabitants.Count > 0)
            {
                Debug.Log(batiment);
                batiment = bat; break;
            }
        }

        if (batiment == null || batiment.ListHabitants.Count <= 0)
        {
            return;
        }

        GameObject o = batiment.ListHabitants[0];

        if (o.GetComponent <Habitant>() == null)
        {
            return;
        }

        List <Habitant> listMetierBat = GameVariables.getListMetier(batiment.typeHabitant);

        if (listMetierBat == null)
        {
            return;
        }

        Habitant villager = o.GetComponent <Habitant>();

        batiment.ListHabitants.Remove(o);
        listMetierBat.Remove(villager);
        GameVariables.listHabitantAffecte.Remove(villager);

        villager.GetComponent <Role>().changementRole(Batiment.role.Habitant.ToString());
        GameVariables.listHabitant.Add(villager);
    }
Пример #27
0
 public void UpdateBatimentDetached(Batiment e)
 {
     utOfWork.BatimentRepository.UpdateBatimentDetached(e);
 }
Пример #28
0
 public void CreateBatiment(Batiment Batiment)
 {
     utOfWork.BatimentRepository.Add(Batiment);
 }
 public void construire(Case kase)
 {
     kase.construire (batimentEnCoursDeConstruction);
     batimentEnCoursDeConstruction = null;
 }
 public void validerProposition()
 {
     if (propositionActuelle.getBatiments().Count > 0) {
         Batiment bat = propositionActuelle.getBatiments()[0];
         batimentEnCoursDeConstruction = bat;
         Colonie.instance.batimentsDisponibles.Add(bat);
         propositionEnCours = false;
         panelPropositions.SetActive(false);
         panelInfoPropositions.SetActive(false);
         //panelInfoBatiment.SetActive(true);
         //panelSelectionBatiment.SetActive(true);
     }
 }
 public void mettreAJour(Batiment bat)
 {
     titre.text = bat.getNom ();
     texte.text = bat.getDescription ();
 }
    private void AddBatimentComponent(Batiment batiment)
    {
        var batimentComponent = SpawnedObject.AddComponent <BatimentDataHolder>();

        batimentComponent.batiment = batiment;
    }
Пример #33
0
 protected virtual void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag ("Mur") || other.gameObject.CompareTag ("Arbre")) {
         if (!champVision.Contains (other.transform)) {
             champVision.Add (other.transform);
         }
     } else if (other.gameObject.CompareTag ("Personnage")) {
         if (!other.isTrigger) {
             if (!champVision.Contains (other.transform)) {
                 champVision.Add (other.transform);
             }
         }
     } else if (other.gameObject.CompareTag ("Hotel")) {
         if(!other.GetComponent<Batiment>().enChantier)
         {
             hotelFavori=other.GetComponent<Batiment>();
         }
     }
 }
Пример #34
0
 public BatimentViewModel()
 {
     model            = new Batiment();
     modelBatCulturel = new BatimentCulturel();
 }
Пример #35
0
        public void Run()
        {
            foreach (string batCamelId in batiments)
            {
                // Création du batiment
                Batiment batiment = new Batiment();
                batiment.CamelId = batCamelId;
                batiment.Save();

                Log("création batiment A");

                foreach (string camelIdApart in batimentA)
                {
                    // Création de l'appartement
                    Appartement apart = new Appartement();
                    apart.Nom = camelIdApart;
                    apart.CamelId = camelIdApart;
                    apart.Batiment = batiment;
                    apart.Save();

                    Log("création apart " + camelIdApart);

                    foreach (string voie in voies)
                    {
                        // Récupération des mesures semaine par semaine
                        for (DateTime begin = new DateTime(2013, 6, 1); begin <= end; begin = begin.AddMonths(1))
                        {
                            CamelResponseResource l_res = CamelGet(batCamelId, camelIdApart, voie, begin, begin.AddMonths(1));

                            // Sauvegarde des mesures en base de données
                            if (l_res != null && l_res.error == null && l_res.result != null &&
                                l_res.result[0].chs != null && l_res.result[0].chs[0] != null &&
                                l_res.result[0].chs[0].vals != null && l_res.result[0].chs[0].vals.Length > 1)
                            {
                                foreach (vals values in l_res.result[0].chs[0].vals)
                                {
                                    DateTime date = DateTimeHelper.ConvertTimeStampToDateTime(values.date);
                                    Mesure mes = new Mesure();
                                    mes.Date = date;
                                    mes.Appartement = apart;
                                    mes.Type = voie;
                                    mes.Valeur = values.val;

                                    mes.Save();
                                }
                            }
                        }
                    }
                }
            }
        }