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.º 2
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);
        }