Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Factory factory = new AllianceFactory();

            Console.WriteLine(factory.CreateCaserne());
            Usine usine = factory.CreateUsine();

            Console.WriteLine(usine);

            Console.WriteLine(usine.CreateJeep());
            Console.WriteLine(usine.CreateMoto());

            DbProviderFactory dbFactory    = DbProviderFactories.GetFactory("System.Data.SqlClient");
            DbConnection      dbConnection = dbFactory.CreateConnection();

            dbConnection.ConnectionString = @"Data Source=AW-BRIAREOS\SQL2016DEV;Initial Catalog=DemoModel;Integrated Security=True";

            DbCommand dbCommand = dbConnection.CreateCommand();

            dbCommand.CommandText = "Select * from Contact";

            dbConnection.Open();

            DbDataReader reader = dbCommand.ExecuteReader();

            while (reader.Read())
            {
                Console.WriteLine($"{reader["Nom"]} {reader["Prenom"]}");
            }

            dbConnection.Dispose();


            Console.ReadLine();
        }
Exemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Usine usine = db.Usines.Find(id);

            db.Usines.Remove(usine);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "IdUsine,UsineName")] Usine usine)
 {
     if (ModelState.IsValid)
     {
         db.Entry(usine).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(usine));
 }
    Amenagement CreationAmenagement()
    {
        Amenagement temp = null;

        if (type == Type.BatimentAdministartif)
        {
            temp = new BatimentAdministratif(nombreHabitantNecessaire, coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.Bureau)
        {
            temp = new Bureau(placesDisponible, prixLocation, coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.Commercant)
        {
            temp = new Commercant(nbrEmployeMaxAise, nbrEmployeMaxMoyenne, nbrEmployeMaxOuvriere, coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.CompagnieEau)
        {
            temp = new CompagnieEau(productionMax, nbrEmployeMaxAise, nbrEmployeMaxMoyenne, nbrEmployeMaxOuvriere, coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.CompagnieElectricite)
        {
            temp = new CompagnieElectricite(productionMax, nbrEmployeMaxAise, nbrEmployeMaxMoyenne, nbrEmployeMaxOuvriere, coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.CompagnieTransport)
        {
            temp = new CompagnieTransport(coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.Culture)
        {
            temp = new Culture(niveauCulture, coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.Tourisme)
        {
            temp = new Tourisme(impactTourisme, coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.Logement)
        {
            temp = new Logement(capaciteMax, classe, nivBonheur, coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.Route)
        {
            temp = new Route(nom, prix, taille, estSortie);
        }
        else if (type == Type.Usine)
        {
            temp = new Usine(nbrEmployeMaxAise, nbrEmployeMaxMoyenne, nbrEmployeMaxOuvriere, coutMensuel, nom, prix, taille, niveau);
        }
        else if (type == Type.Primaire)
        {
            temp = new Primaire(nbrEmployeMaxAise, nbrEmployeMaxMoyenne, nbrEmployeMaxOuvriere, productionMax, coutMensuel, nom, prix, taille, niveau);
        }

        return(temp);
    }
Exemplo n.º 5
0
        private static void DrawBoxes(Usine usine)
        {
            string strview = "";

            foreach (int nbr in usine.Stacks)
            {
                strview += String.Format(STACK, nbr);
            }

            Console.SetCursorPosition(0, 1);
            Console.Write(strview);
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "IdUsine,UsineName")] Usine usine)
        {
            if (ModelState.IsValid)
            {
                db.Usines.Add(usine);
                db.SaveChanges();

                TempData["mssg"] = "Thank you";
                return(RedirectToAction("Index"));
            }

            return(View(usine));
        }
Exemplo n.º 7
0
        // GET: Usines/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Usine usine = db.Usines.Find(id);

            if (usine == null)
            {
                return(HttpNotFound());
            }
            return(View(usine));
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Grue  grue  = new Grue();
            Usine usine = new Usine(grue, new[] { 2, 1, 0, 3, 1, 8, 1 });

            Vue.Draw(grue, usine);

            do
            {
                if (usine.ExecuterAction(Solve(grue.Position, usine.Stacks, grue.IsGrabbing)))
                {
                    break;
                }
                Vue.Draw(grue, usine);
            }while (Console.ReadKey().KeyChar != 'q');
        }
Exemplo n.º 9
0
        private static void DrawGrue(Grue grue, Usine usine)
        {
            string espacementsInitiaux = "";

            for (int i = 0; i < grue.Position; i++)
            {
                espacementsInitiaux += ESPACEMENT;
            }

            espacementsInitiaux += (grue.IsGrabbing ? GRUE_GRAB : GRUE_VIDE);

            for (int i = grue.Position; i < usine.Stacks.Length; i++)
            {
                espacementsInitiaux += ESPACEMENT;
            }

            Console.SetCursorPosition(0, 0);
            Console.Write(espacementsInitiaux);
        }
Exemplo n.º 10
0
 public static void Draw(Grue grue, Usine usine)
 {
     DrawGrue(grue, usine);
     DrawBoxes(usine);
 }
Exemplo n.º 11
0
        public static void LoadGame(string saveKey)
        {
            Ville   v;
            JObject vJObject;

            try
            {
                StreamReader stm        = new StreamReader(folder + saveKey + ".txt");
                string       jsonString = stm.ReadToEnd();
                vJObject = JObject.Parse(jsonString);

                v = JsonConvert.DeserializeObject <Ville>(jsonString);
            }
            catch (Exception e)
            {
                UnityEngine.Object.FindObjectOfType <LogBox>().WriteLog(e.Message);
                return;
            }


            v.LoadData();
            List <Amenagement> newAmenagements = new List <Amenagement>();
            JArray             amenagements    = (JArray)vJObject["Amenagements"];

            for (int i = 0; i < amenagements.Count; i++)
            {
                JToken a    = amenagements[i];
                string type = a["Type"].ToString();
                if (type == "Route")
                {
                    Route r = new Route(a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["PosX"].ToString()), Int32.Parse(a["PosY"].ToString()), bool.Parse(a["EstSortie"].ToString()));
                    r.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    newAmenagements.Add(r);
                }

                /* if (type == "Batiment")
                 * {
                 *   Batiment b = new Batiment(a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["PosX"].ToString()), Int32.Parse(a["PosY"].ToString()), bool.Parse(a["EstSortie"].ToString()));
                 *   b.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                 *   newAmenagements.Add(b);
                 * } */
                if (type == "BatimentAdministratif")
                {
                    BatimentAdministratif t = new BatimentAdministratif(Int32.Parse(a["NombreHabitantNecessaire"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }
                if (type == "Bureau")
                {
                    Bureau t = new Bureau(Int32.Parse(a["MaxPlaceDispo"].ToString()), float.Parse(a["PrixLocation"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }
                if (type == "Commercant")
                {
                    Commercant t = new Commercant(Int32.Parse(a["NbrEmployeMaxAise"].ToString()), Int32.Parse(a["NbrEmployeMaxMoyenne"].ToString()), Int32.Parse(a["NbrEmployeMaxOuvriere"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }
                if (type == "CompagnieEau")
                {
                    CompagnieEau t = new CompagnieEau(Int32.Parse(a["ProductionMax"].ToString()), Int32.Parse(a["NbrEmployeMaxAise"].ToString()), Int32.Parse(a["NbrEmployeMaxMoyenne"].ToString()), Int32.Parse(a["NbrEmployeMaxOuvriere"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }
                if (type == "CompagnieElectricite")
                {
                    CompagnieElectricite t = new CompagnieElectricite(Int32.Parse(a["ProductionMax"].ToString()), Int32.Parse(a["NbrEmployeMaxAise"].ToString()), Int32.Parse(a["NbrEmployeMaxMoyenne"].ToString()), Int32.Parse(a["NbrEmployeMaxOuvriere"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }
                if (type == "CompagnieTransport")
                {
                    CompagnieTransport t = new CompagnieTransport(Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }
                if (type == "Culture")
                {
                    Culture t = new Culture(Int32.Parse(a["NiveauCulture"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }

                /*if (type == "Entreprise")
                 * {
                 *  Entreprise t = new Entreprise(Int32.Parse(a["NiveauCulture"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                 *  t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                 *  t.PosX = Int32.Parse(a["PosX"].ToString());
                 *  t.PosY = Int32.Parse(a["PosY"].ToString());
                 *  newAmenagements.Add(t);
                 * }*/
                if (type == "Logement")
                {
                    Logement t = new Logement(Int32.Parse(a["CapaciteMax"].ToString()), (ClasseSocial)Enum.Parse(typeof(ClasseSocial), a["Classe"].ToString()), float.Parse(a["NivBonheur"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }
                if (type == "Tourisme")
                {
                    Tourisme t = new Tourisme(Int32.Parse(a["ImpactTourisme"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }
                if (type == "Usine")
                {
                    Usine t = new Usine(Int32.Parse(a["NbrEmployeMaxAise"].ToString()), Int32.Parse(a["NbrEmployeMaxMoyenne"].ToString()), Int32.Parse(a["NbrEmployeMaxOuvriere"].ToString()), Int32.Parse(a["CoutMensuel"].ToString()), a["Nom"].ToString(), Int32.Parse(a["Prix"].ToString()), Int32.Parse(a["Taille"].ToString()), Int32.Parse(a["Niveau"].ToString()));
                    t.Rotation = new Vector3(float.Parse(a["Rotation"]["x"].ToString()), float.Parse(a["Rotation"]["y"].ToString()), float.Parse(a["Rotation"]["z"].ToString()));
                    t.PosX     = Int32.Parse(a["PosX"].ToString());
                    t.PosY     = Int32.Parse(a["PosY"].ToString());
                    newAmenagements.Add(t);
                }
            }

            v.Amenagements = newAmenagements;
            PopulateMap(v);
            UnityEngine.Object.FindObjectOfType <Manager>().StartGame();
            UnityEngine.Object.FindObjectOfType <GameManager>().LoadGame(v);
        }