Exemplo n.º 1
0
 void GestionEscape()
 {
     if (Input.GetKeyDown(KeyCode.Escape)) // retire le batiment du curseur du joueur
     {
         if (GOAmenagement != null && modelActuel != null)
         {
             DestroyImmediate(GOAmenagement);
             GOAmenagement = null;
             modelActuel   = null;
             amenagement   = null;
         }
         else if (isInDestroyMode)
         {
             isInDestroyMode = false;
         }
         else
         {
             // toggle para menu
             if (boxPause.gameObject.activeInHierarchy)
             {
                 boxPause.GetComponent <PauseBox>().Close();
                 boxPause.SetActive(false);
             }
             else
             {
                 boxPause.SetActive(true);
             }
         }
     }
 }
 void Start()
 {
     if (amenagement == null)
     {
         amenagement = CreationAmenagement();
     }
 }
Exemplo n.º 3
0
        public static string ExporterAmenagement(Amenagement A, int i)
        {
            string variables = "";

            variables += "\newcommand{\\graphoAmenagementType" + i + "}{" + A.AmenagementType + "}\n";

            return(variables);
        }
Exemplo n.º 4
0
 public void SetAmenagement(GameObject a)
 {
     isInDestroyMode = false;
     Destroy(GOAmenagement);
     amenagement   = null;
     modelActuel   = a;
     GOAmenagement = Instantiate(modelActuel, new Vector3(posX, 0.1f, posZ), Quaternion.identity);
     amenagement   = GOAmenagement.GetComponent <AmenagementPrefab>().Amenagement;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Ajoute un nouvel aménagement à un patient
        /// </summary>
        /// <param name="p"></param>
        public static void nouvelAmenagement(int idPatient, Amenagement amenagement)
        {
            using (IDbConnection connection = new SQLiteConnection(DBAccess.connectionString()))
            {
                string amenagementType = amenagement.AmenagementType;

                connection.Execute("INSERT INTO AMENAGEMENT (AmenagementType, PatientId) VALUES (@amenagementType, @idPatient)", new { amenagementType, idPatient });
            }
        }
    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.º 7
0
    public Amenagement Cloner()
    {
        Amenagement clone = CreateInstance <Amenagement>();

        clone.terrainsAmenageables = terrainsAmenageables;
        clone.Slots              = Slots;
        clone.palier             = palier;
        clone.spritesEte         = new List <Sprite>(spritesEte);
        clone.spritesHiver       = new List <Sprite>(spritesHiver);
        clone.gainAmenagementEte = gainAmenagementEte;
        clone.Effets             = Effets;

        return(clone);
    }
Exemplo n.º 8
0
    public void AmenagerTuile(Amenagement nvlAmenagement)
    {
        if (!amenagement)
        {
            amenagement = nvlAmenagement;
            ValiderPalier();
        }
        else if (nvlAmenagement == amenagement)
        {
            ValiderPalier();
        }

        Amenagement.eventAmenagement.Invoke();
    }
Exemplo n.º 9
0
    /// <summary>
    /// Place un carré jaune sous le batiment sélectionné
    /// </summary>
    void DisplayOutlineSelectedBuilding()
    {
        outlineGroup = new List <GameObject>();
        Amenagement amenTemp = targetBuilding.gameObject.GetComponent <AmenagementPrefab>().Amenagement;

        for (int i = amenTemp.PosX; i < amenTemp.PosX + amenTemp.Taille; i++)
        {
            for (int j = amenTemp.PosY; j < amenTemp.PosY + amenTemp.Taille; j++)
            {
                GameObject temp = Instantiate(unitOutline);
                temp.transform.position = new Vector3(ConvertToMapScale(i), 0.1f, ConvertToMapScale(j));
                outlineGroup.Add(temp);
            }
        }
    }
Exemplo n.º 10
0
    void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
    {
        infoBox.SetActive(true);

        infoBox.GetComponent <Image>().sprite = gameObject.GetComponent <Image>().sprite;
        Transform   ctn = infoBox.transform.Find("filtre").Find("Container");
        Amenagement a   = GetComponent <SelectionneAmenagementBouton>().amenagement.GetComponent <AmenagementPrefab>().Amenagement;

        ctn.Find("Nom").GetComponent <Text>().text    = a.Nom;
        ctn.Find("Prix").GetComponent <Text>().text   = "Prix : " + a.Prix.ToString() + "€";
        ctn.Find("Taille").GetComponent <Text>().text = "Taille : " + a.Taille.ToString() + "*" + a.Taille.ToString();
        ctn.Find("Info").GetComponent <Text>().text   = a.AffichageAchat();

        (infoBox.transform as RectTransform).position = new Vector2((transform as RectTransform).position.x, (infoBox.transform as RectTransform).position.y);
    }
Exemplo n.º 11
0
    void StartParticleEmition()
    {
        listParticleSystem = new List <GameObject>();
        Amenagement amenTemp = amenagement.gameObject.GetComponent <AmenagementPrefab>().Amenagement;

        for (int i = amenTemp.PosX; i < amenTemp.PosX + amenTemp.Taille; i++)
        {
            for (int j = amenTemp.PosY; j < amenTemp.PosY + amenTemp.Taille; j++)
            {
                GameObject temp = Instantiate(particleSystemUnit);
                temp.SetActive(true);
                temp.transform.position = new Vector3(ConvertToMapScale(i), 0.1f, ConvertToMapScale(j));
                listParticleSystem.Add(temp);
            }
        }
    }
Exemplo n.º 12
0
 void GestionClickDroit()
 {
     if (Input.GetMouseButtonDown(1))
     {
         if (GOAmenagement != null && modelActuel != null)
         {
             DestroyImmediate(GOAmenagement);
             GOAmenagement = null;
             modelActuel   = null;
             amenagement   = null;
         }
         if (isInDestroyMode)
         {
             isInDestroyMode = false;
         }
     }
 }
Exemplo n.º 13
0
    void DeplaceAmenagement()
    {
        if (GOAmenagement != null)   // placement d'un amenagement sur la carte
        {
            if (amenagement != null) // vérifie que l'amenagement à bien été instantié dans le GameObject
            {
                amenagement.PosX = gridX;
                amenagement.PosY = gridZ;
                dispo            = ville.Map.VerifierPlace(amenagement);

                // Modifie le material du batiment pour afficher si la place est disponible
                if (dispo)
                {
                    ChangeGameObjectTexture(GOAmenagement, disponibleMat);
                }
                else
                {
                    ChangeGameObjectTexture(GOAmenagement, indisponibleMat);
                }

                // positionnement du prefab par rapport au curseur de la souris
                if (amenagement.Taille % 2 == 0)
                {
                    GOAmenagement.transform.position = new Vector3(x + (amenagement.Taille - 1) * 5f, 0.1f, z + (amenagement.Taille - 1) * 5f);
                }
                else
                {
                    GOAmenagement.transform.position = new Vector3(x + Mathf.Max(0, amenagement.Taille - 2) * 10f, 0.1f, z + Mathf.Max(0, amenagement.Taille - 2) * 10f);
                }

                GOAmenagement.transform.rotation = Quaternion.Euler(rotation);
            }
            else
            {
                amenagement = GOAmenagement.GetComponent <AmenagementPrefab>().Amenagement;
            }
        }
        else
        {
            Cursor.visible = true;
        }
    }
Exemplo n.º 14
0
    public override void OnInspectorGUI()
    {
        amenagement = (Amenagement)target;
        GUILayout.Space(30);
        amenagement.gainAmenagementEte   = (Production)EditorGUILayout.ObjectField("Gain Amenagement Eté", amenagement.gainAmenagementEte, typeof(Production), true);
        amenagement.gainAmenagementHiver = (Production)EditorGUILayout.ObjectField("Gain Amenagement Hiver", amenagement.gainAmenagementHiver, typeof(Production), true);
        amenagement.Slots = EditorGUILayout.IntField("nombre de slots", amenagement.Slots);
        GUILayout.Space(20);
        amenagement.palier = EditorGUILayout.IntField("Nombre de palier", amenagement.palier);

        GUILayout.Space(10);
        GUILayout.Label("Sprite d'Eté");
        for (int i = 0; i < amenagement.palier; i++)
        {
            if (amenagement.spritesEte.Count == i)
            {
                amenagement.spritesEte.Add(null);
            }
            amenagement.spritesEte[i] = (Sprite)EditorGUILayout.ObjectField("Sprite Palier " + (i + 1), amenagement.spritesEte[i], typeof(Sprite), true);
        }
        GUILayout.Space(10);
        GUILayout.Label("Sprites d'Hiver");
        for (int i = 0; i < amenagement.palier; i++)
        {
            if (amenagement.spritesHiver.Count == i)
            {
                amenagement.spritesHiver.Add(null);
            }
            amenagement.spritesHiver[i] = (Sprite)EditorGUILayout.ObjectField("Sprite Palier " + (i + 1), amenagement.spritesHiver[i], typeof(Sprite), true);
        }

        if (amenagement.spritesEte.Count > amenagement.palier)
        {
            for (int i = 0; i < amenagement.spritesEte.Count - amenagement.palier; i++)
            {
                amenagement.spritesEte.RemoveAt(amenagement.palier);
            }
        }
        if (amenagement.spritesHiver.Count > amenagement.palier)
        {
            for (int i = 0; i < amenagement.spritesHiver.Count - amenagement.palier; i++)
            {
                amenagement.spritesHiver.RemoveAt(amenagement.palier);
            }
        }
        GUILayout.Space(15);


        base.OnInspectorGUI();
        DessinerSelecteurTerrainsAmenagables();

        GUILayout.Space(25);
        GUILayout.Label("Effets");
        amenagement.Effets = EditorGUILayout.TextArea(amenagement.Effets);

        GUILayout.Space(30);
        if (GUILayout.Button("SAUVEGARDER"))
        {
            Sauvegarder();
        }
    }
Exemplo n.º 15
0
    void GestionClickGauche()
    {
        if (Input.GetMouseButton(0) && hitTerrain)                                                              // click gauche souris
        {
            if (GOAmenagement != null && amenagement != null && !EventSystem.current.IsPointerOverGameObject()) // place le batiment attaché au curseur du joueur
            {
                if (amenagement is Route)
                {
                    if (firstBoule == null)
                    {
                        firstBoule = Instantiate(boule, new Vector3(x, 5f, z), Quaternion.identity);
                        GOAmenagement.SetActive(false);
                        secondBoule = Instantiate(boule, new Vector3(x, 5f, z), Quaternion.identity);
                    }
                    secondBoule.transform.position = new Vector3(x, 5f, z);
                }
                else
                {
                    if (dispo && ville.PlacerUnAmenagement(amenagement)) // placement du batiment sur la carte
                    {
                        ChangeGameObjectTextureToOriginal(GOAmenagement, modelActuel);
                        amenagementSpawner.GetComponent <AmenagementSpawner>().Spawn(GOAmenagement.transform);

                        // on place le model attaché à la souris en remplacant le model attaché a la souris par un nouveau, l'autre est donc laissé sur place
                        GOAmenagement        = Instantiate(modelActuel, new Vector3(posX, 0, posZ), Quaternion.identity);
                        amenagement          = GOAmenagement.GetComponent <AmenagementPrefab>().Amenagement;
                        amenagement.Rotation = rotation;
                    }
                }
            }
        }

        // Placement des route en gardant le clique enfoncé
        if (Input.GetMouseButtonUp(0) && hitTerrain)
        {
            bool ligneDispo = true;
            GOAmenagement.SetActive(true);

            if (firstBoule != null && firstBoule.transform.position.x == x)
            {
                for (int i = Mathf.Min(Mathf.FloorToInt(firstBoule.transform.position.z) / 10, gridZ); i <= Mathf.Max(gridZ, Mathf.FloorToInt(firstBoule.transform.position.z) / 10); i++)
                {
                    if (!ville.Map.VerifierPlace(new Route("", 0, 1, Mathf.FloorToInt(x) / 10, i, false)) && !(ville.Map.Carte[i, Mathf.FloorToInt(x) / 10] is Route))
                    {
                        ligneDispo = false;
                    }
                }
                if (ligneDispo)
                {
                    Destroy(GOAmenagement);
                    for (int i = Mathf.Min(Mathf.FloorToInt(firstBoule.transform.position.z) / 10, gridZ); i <= Mathf.Max(gridZ, Mathf.FloorToInt(firstBoule.transform.position.z) / 10); i++)
                    {
                        if (ville.PlacerUnAmenagement(new Route("", 0, 1, Mathf.FloorToInt(x) / 10, i, false)))
                        {
                            GOAmenagement = Instantiate(modelActuel, new Vector3(ConvertToMapScale(gridX), 0.1f, ConvertToMapScale(i)), Quaternion.identity);

                            amenagement      = GOAmenagement.GetComponent <AmenagementPrefab>().Amenagement;
                            amenagement.PosX = gridX;
                            amenagement.PosY = i;
                        }
                    }
                }
                GOAmenagement = Instantiate(modelActuel, new Vector3(0, 0.1f, 0), Quaternion.identity);
                amenagement   = GOAmenagement.GetComponent <AmenagementPrefab>().Amenagement;
            }
            else if (firstBoule != null && firstBoule.transform.position.z == z)
            {
                for (int i = Mathf.Min(Mathf.FloorToInt(firstBoule.transform.position.x) / 10, gridX); i <= Mathf.Max(gridX, Mathf.FloorToInt(firstBoule.transform.position.x) / 10); i++)
                {
                    if (!ville.Map.VerifierPlace(new Route("", 0, 1, i, Mathf.FloorToInt(z) / 10, false)) && !(ville.Map.Carte[Mathf.FloorToInt(z) / 10, i] is Route))
                    {
                        ligneDispo = false;
                    }
                }
                if (ligneDispo)
                {
                    Destroy(GOAmenagement);
                    for (int i = Mathf.Min(Mathf.FloorToInt(firstBoule.transform.position.x) / 10, gridX); i <= Mathf.Max(gridX, Mathf.FloorToInt(firstBoule.transform.position.x) / 10); i++)
                    {
                        if (ville.PlacerUnAmenagement(new Route("", 0, 1, i, Mathf.FloorToInt(z) / 10, false)))
                        {
                            GOAmenagement    = Instantiate(modelActuel, new Vector3(ConvertToMapScale(i), 0.1f, ConvertToMapScale(gridZ)), Quaternion.identity);
                            amenagement      = GOAmenagement.GetComponent <AmenagementPrefab>().Amenagement;
                            amenagement.PosX = i;
                            amenagement.PosY = gridZ;
                        }
                    }
                    GOAmenagement = Instantiate(modelActuel, new Vector3(0, 0.1f, 0), Quaternion.identity);
                    amenagement   = GOAmenagement.GetComponent <AmenagementPrefab>().Amenagement;
                }
            }
            Destroy(firstBoule);
            Destroy(secondBoule);
            GOAmenagement.SetActive(true);
            secondBoule = null;
            firstBoule  = null;
        }

        //Selection ou desruction d'un batiment
        if (Input.GetMouseButtonDown(0) && GOAmenagement == null)
        {
            int  mask  = LayerMask.GetMask("Batiment");
            Ray  ray   = Camera.main.ScreenPointToRay(Input.mousePosition);
            bool touch = Physics.Raycast(ray, out hit, 5000f, mask);

            if (touch && !EventSystem.current.IsPointerOverGameObject())
            {
                targetBuilding = hit.transform;
                if (!targetBuilding.GetComponent <AmenagementPrefab>())
                {
                    targetBuilding = targetBuilding.parent;
                }


                if (isInDestroyMode)
                {
                    if (targetBuldingDestroy != null)
                    {
                        Amenagement temp = targetBuilding.GetComponent <AmenagementPrefab>().Amenagement;
                        ville.SupprimerAmenagement(temp);
                        Destroy(targetBuilding.gameObject);
                        targetBuilding = null;
                        Destroy(buildingTextureHolder.gameObject);
                    }
                }
                else // Le joueur a cliqué sur un batilent
                {
                    // On affiche les informations du batiments
                    menu.AfficheInfoAmenagement(targetBuilding);
                    //Affiche l'outline du batiment
                    DisplayOutlineSelectedBuilding();
                }
            }
            else if (!EventSystem.current.IsPointerOverGameObject()) // CLique sur un point de la map qui ne contient pas de batiment
            {
                // on cache les infos du batiment
                // on cache l'outline du batiment
                targetBuilding = null;
                RemoveOutlineSelectedTransform();
                menu.CacherInfoAmenagement();
            }
        }
    }
Exemplo n.º 16
0
    /// <summary>
    /// Active la popup qui donne les informations sur l'amenagement choisi
    /// </summary>
    /// <param name="t"></param>
    public void AfficheInfoAmenagement(Transform t)
    {
        Text          infoText;
        RectTransform rectTransform;
        Amenagement   a = t.GetComponent <AmenagementPrefab>().Amenagement;

        CacherInfoAmenagement();
        //SignalBatimentDeconnecte

        if (a is Commercant || a is CompagnieEau || a is CompagnieElectricite || a is Primaire)
        {
            infoText      = infoBoxAmenagement1Para.Find("Container").Find("InfoText").GetComponent <Text>();
            rectTransform = (RectTransform)infoBoxAmenagement1Para.transform;

            infoBoxAmenagement1Para.Find("SignalBatimentDeconnecte").gameObject.SetActive(!(a as Batiment).EstConnecte);

            // Modification des informations de la pop up en fonction du batiment choisi
            #region Creation pop up gestion batiment

            if (a is Commercant)
            {
                infoBoxAmenagement1Para.Find("Container").Find("TextPara").GetComponent <Text>().text = "Prix de vente : " + (a as Commercant).Prix;
                infoBoxAmenagement1Para.Find("Container").Find("Container").Find("ValMin").GetComponent <Text>().text = "0";
                infoBoxAmenagement1Para.Find("Container").Find("Container").Find("ValMax").GetComponent <Text>().text = "100";

                Slider slider = infoBoxAmenagement1Para.Find("Container").Find("Container").Find("Slider").GetComponent <Slider>();
                slider.onValueChanged.RemoveAllListeners();
                slider.minValue     = 0;
                slider.maxValue     = 100;
                slider.wholeNumbers = true;

                Ville  v   = GameObject.FindObjectOfType <GameManager>().ville;
                Button btn = infoBoxAmenagement1Para.Find("Container").Find("Button").GetComponent <Button>();
                btn.onClick.RemoveAllListeners();
                btn.GetComponent <Button>().onClick.AddListener(() =>
                {
                    foreach (Amenagement amen in v.Amenagements)
                    {
                        if (amen is Commercant && amen.Niveau == a.Niveau)
                        {
                            (amen as Commercant).PrixVente = slider.value;
                        }
                    }
                });

                UnityAction <float> callback = new UnityAction <float>((float value) =>
                {
                    (a as Commercant).PrixVente = slider.value;
                });

                slider.onValueChanged.AddListener(callback);
                slider.value = (a as Commercant).PrixVente;
            }
            if (a is CompagnieEau)
            {
                infoBoxAmenagement1Para.Find("Container").Find("TextPara").GetComponent <Text>().text = "Production d'eau : " + (a as CompagnieEau).EauProduite;
                infoBoxAmenagement1Para.Find("Container").Find("Container").Find("ValMin").GetComponent <Text>().text = (a as CompagnieEau).ProductionMin.ToString();
                infoBoxAmenagement1Para.Find("Container").Find("Container").Find("ValMax").GetComponent <Text>().text = (a as CompagnieEau).ProductionMax.ToString();

                Slider slider = infoBoxAmenagement1Para.Find("Container").Find("Container").Find("Slider").GetComponent <Slider>();
                slider.onValueChanged.RemoveAllListeners();
                slider.minValue     = (a as CompagnieEau).ProductionMin;
                slider.maxValue     = (a as CompagnieEau).ProductionMax;
                slider.wholeNumbers = true;

                Ville  v   = GameObject.FindObjectOfType <GameManager>().ville;
                Button btn = infoBoxAmenagement1Para.Find("Container").Find("Button").GetComponent <Button>();
                btn.onClick.RemoveAllListeners();
                btn.GetComponent <Button>().onClick.AddListener(() =>
                {
                    foreach (Amenagement amen in v.Amenagements)
                    {
                        if (amen is CompagnieEau && amen.Niveau == a.Niveau)
                        {
                            (amen as CompagnieEau).EauProduite = (int)slider.value;
                        }
                    }
                });

                UnityAction <float> callback = new UnityAction <float>((float value) =>
                {
                    (a as CompagnieEau).EauProduite = (int)value;
                });

                slider.onValueChanged.AddListener(callback);
                slider.value = (a as CompagnieEau).EauProduite;
            }
            if (a is CompagnieElectricite)
            {
                infoBoxAmenagement1Para.Find("Container").Find("TextPara").GetComponent <Text>().text = "Energie produite : " + (a as CompagnieElectricite).EnergieProduite;
                infoBoxAmenagement1Para.Find("Container").Find("Container").Find("ValMin").GetComponent <Text>().text = (a as CompagnieElectricite).ProductionMax.ToString();
                infoBoxAmenagement1Para.Find("Container").Find("Container").Find("ValMax").GetComponent <Text>().text = (a as CompagnieElectricite).ProductionMax.ToString();

                Slider slider = infoBoxAmenagement1Para.Find("Container").Find("Container").Find("Slider").GetComponent <Slider>();
                slider.onValueChanged.RemoveAllListeners();
                slider.minValue     = (a as CompagnieElectricite).ProductionMax;
                slider.maxValue     = (a as CompagnieElectricite).ProductionMax;
                slider.wholeNumbers = true;

                Ville  v   = GameObject.FindObjectOfType <GameManager>().ville;
                Button btn = infoBoxAmenagement1Para.Find("Container").Find("Button").GetComponent <Button>();
                btn.onClick.RemoveAllListeners();
                btn.GetComponent <Button>().onClick.AddListener(() =>
                {
                    foreach (Amenagement amen in v.Amenagements)
                    {
                        if (amen is CompagnieElectricite && amen.Niveau == a.Niveau)
                        {
                            (amen as CompagnieElectricite).EnergieProduite = (int)slider.value;
                        }
                    }
                });

                UnityAction <float> callback = new UnityAction <float>((float value) =>
                {
                    (a as CompagnieElectricite).EnergieProduite = (int)value;
                });

                slider.onValueChanged.AddListener(callback);
                slider.value = (a as CompagnieElectricite).EnergieProduite;
            }
            if (a is Primaire)
            {
                infoBoxAmenagement1Para.Find("Container").Find("TextPara").GetComponent <Text>().text = "Produvtion nourriture : " + (a as Primaire).NourritureProduite;
                infoBoxAmenagement1Para.Find("Container").Find("Container").Find("ValMin").GetComponent <Text>().text = (a as Primaire).ProductionMin.ToString();
                infoBoxAmenagement1Para.Find("Container").Find("Container").Find("ValMax").GetComponent <Text>().text = (a as Primaire).ProductionMax.ToString();

                Slider slider = infoBoxAmenagement1Para.Find("Container").Find("Container").Find("Slider").GetComponent <Slider>();
                slider.onValueChanged.RemoveAllListeners();
                slider.minValue     = (a as Primaire).ProductionMin;
                slider.maxValue     = (a as Primaire).ProductionMax;
                slider.wholeNumbers = true;

                Ville  v   = GameObject.FindObjectOfType <GameManager>().ville;
                Button btn = infoBoxAmenagement1Para.Find("Container").Find("Button").GetComponent <Button>();
                btn.onClick.RemoveAllListeners();
                btn.GetComponent <Button>().onClick.AddListener(() =>
                {
                    foreach (Amenagement amen in v.Amenagements)
                    {
                        if (amen is Primaire && amen.Niveau == a.Niveau)
                        {
                            (amen as Primaire).NourritureProduite = (int)slider.value;
                        }
                    }
                });

                UnityAction <float> callback = new UnityAction <float>((float value) =>
                {
                    (a as Primaire).NourritureProduite = (int)value;
                });

                slider.onValueChanged.AddListener(callback);
                slider.value = (a as Primaire).NourritureProduite;
            }
            #endregion

            infoBoxAmenagement1Para.gameObject.SetActive(true);
        }
        else if (a is CompagnieTransport)
        {
            infoText      = infoBoxAmenagementMultiPara.Find("InfoText").GetComponent <Text>();
            rectTransform = (RectTransform)infoBoxAmenagement1Para.transform;

            //para 1
            infoBoxAmenagementMultiPara.Find("Container").Find("TextPara").GetComponent <Text>().text = "Nombre de Transport : " + (a as CompagnieTransport).NombreTransport;
            infoBoxAmenagementMultiPara.Find("Container").Find("Container").Find("ValMin").GetComponent <Text>().text = "0";
            infoBoxAmenagementMultiPara.Find("Container").Find("Container").Find("ValMax").GetComponent <Text>().text = "100";

            Slider slider = infoBoxAmenagementMultiPara.Find("Container").Find("Container").Find("Slider").GetComponent <Slider>();
            slider.onValueChanged.RemoveAllListeners();
            slider.minValue     = 0;
            slider.maxValue     = 100;
            slider.wholeNumbers = true;

            Ville v = GameObject.FindObjectOfType <GameManager>().ville;


            UnityAction <float> callback = new UnityAction <float>((float value) =>
            {
                (a as CompagnieTransport).NombreTransport = (int)value;
            });

            slider.onValueChanged.AddListener(callback);
            slider.value = (a as CompagnieTransport).NombreTransport;

            //para 2
            infoBoxAmenagementMultiPara.Find("Container").Find("TextPara2").GetComponent <Text>().text = "Prix Tiquet : " + (a as CompagnieTransport).PrixTransport;
            infoBoxAmenagementMultiPara.Find("Container").Find("Container2").Find("ValMin").GetComponent <Text>().text = "0";
            infoBoxAmenagementMultiPara.Find("Container").Find("Container2").Find("ValMax").GetComponent <Text>().text = "10";

            Slider slider2 = infoBoxAmenagementMultiPara.Find("Container").Find("Container2").Find("Slider").GetComponent <Slider>();
            slider2.onValueChanged.RemoveAllListeners();
            slider2.minValue     = 0;
            slider2.maxValue     = 10;
            slider2.wholeNumbers = false;


            UnityAction <float> callback2 = new UnityAction <float>((float value) =>
            {
                (a as CompagnieTransport).PrixTransport = value;
            });

            slider2.onValueChanged.AddListener(callback2);
            slider2.value = (a as CompagnieTransport).PrixTransport;

            //para 3
            infoBoxAmenagementMultiPara.Find("TextPara3").Find("Container").GetComponent <Text>().text = "Capacite Transport : " + (a as CompagnieTransport).CapaciteTransport;
            infoBoxAmenagementMultiPara.Find("Container3").Find("Container").Find("ValMin").GetComponent <Text>().text = "0";
            infoBoxAmenagementMultiPara.Find("Container3").Find("Container").Find("ValMax").GetComponent <Text>().text = "40";

            Slider slider3 = infoBoxAmenagementMultiPara.Find("Container").Find("Container3").Find("Slider").GetComponent <Slider>();
            slider3.onValueChanged.RemoveAllListeners();
            slider3.minValue     = 0;
            slider3.maxValue     = 40;
            slider3.wholeNumbers = true;



            UnityAction <float> callback3 = new UnityAction <float>((float value) =>
            {
                (a as CompagnieTransport).CapaciteTransport = (int)value;
            });

            slider3.onValueChanged.AddListener(callback3);
            slider3.value = (a as CompagnieTransport).CapaciteTransport;


            Button btn = infoBoxAmenagement1Para.Find("Container").Find("Button").GetComponent <Button>();
            btn.onClick.RemoveAllListeners();
            btn.GetComponent <Button>().onClick.AddListener(() =>
            {
                foreach (Amenagement amen in v.Amenagements)
                {
                    if (amen is CompagnieTransport && amen.Niveau == a.Niveau)
                    {
                        (amen as CompagnieTransport).NombreTransport   = (int)slider.value;
                        (amen as CompagnieTransport).PrixTransport     = slider2.value;
                        (amen as CompagnieTransport).CapaciteTransport = (int)slider3.value;
                    }
                }
            });
            infoBoxAmenagementMultiPara.gameObject.SetActive(true);
        }
        else
        {
            infoText      = infoBoxAmenagement.Find("InfoText").GetComponent <Text>();
            rectTransform = (RectTransform)infoBoxAmenagement.transform;
            infoBoxAmenagement.gameObject.SetActive(true);
            if (a is Batiment)
            {
                infoBoxAmenagement.Find("SignalBatimentDeconnecte").gameObject.SetActive(!(a as Batiment).EstConnecte);
            }
        }

        infoText.text = a.ToString();
        Vector2 viewportPoint = Camera.main.WorldToScreenPoint(t.position);
        rectTransform.position = viewportPoint;
    }
Exemplo n.º 17
0
 // Use this for initialization
 void Start()
 {
     ville = FindObjectOfType <GameManager>().ville;
     a     = GetComponent <AmenagementPrefab>().Amenagement;
 }