diff --git a/Game/Buildings/Building.cs b/Game/Buildings/Building.cs index a697bf1..9b7e689 100644 --- a/Game/Buildings/Building.cs +++ b/Game/Buildings/Building.cs @@ -20,7 +20,7 @@ private Building(BuildingType type, Vector2 position, int theLvl) Activated = true; Characteristics.Lvl = theLvl; Characteristics.Lvl = theLvl; - + PlanInitial.MAX_CAR += Characteristics.NbCar; ListBuildings.Add(this); } @@ -29,7 +29,7 @@ private Building(BuildingType type, Vector2 position, int theLvl) /// La position du building sur la map /// public Vector2 Position { get; } - + /// /// Si le batiment est activé /// @@ -75,17 +75,18 @@ public static Building Create(BuildingType type, Vector2 position, int theLvl = public static void verify(BuildingType type) { - } + public void energyAndWater(Building type) { - (int energy, int water) = (Characteristics.energy[Characteristics.Lvl],Characteristics.water[Characteristics.Lvl]); - if (energy<0) + (int energy, int water) = (Characteristics.energy[Characteristics.Lvl], + Characteristics.water[Characteristics.Lvl]); + if (energy < 0) { Ref_donnees.energy -= energy; Interface.Water -= water; } - else if(water < 0) + else if (water < 0) { Ref_donnees.water -= water; Interface.Energy -= energy; @@ -148,7 +149,7 @@ private void Upgrade() Interface.Xp += Characteristics.GainXp[Characteristics.Lvl]; Characteristics.Lvl += 1; } - + public static Building GetFromTile(Vector2 tile) { var i = 0; @@ -160,6 +161,7 @@ public static Building GetFromTile(Vector2 tile) return batiment; i++; } + return null; } } diff --git a/Game/Buildings/BuildingCharacteristics.cs b/Game/Buildings/BuildingCharacteristics.cs index b1ce49c..36f2951 100644 --- a/Game/Buildings/BuildingCharacteristics.cs +++ b/Game/Buildings/BuildingCharacteristics.cs @@ -16,7 +16,7 @@ public interface IBuildingCharacteristics int Lvl { get; set; } int[] GainXp { get; } int[] energy { get; } - int[] water { get; } + int[] water { get; } string[] Image { get; } int NbrAmeliorations { get; } int NbCar { get; } diff --git a/Game/Buildings/Characteristics/Cafe.cs b/Game/Buildings/Characteristics/Cafe.cs index 8657a25..25edde7 100644 --- a/Game/Buildings/Characteristics/Cafe.cs +++ b/Game/Buildings/Characteristics/Cafe.cs @@ -17,7 +17,7 @@ public Cafe() Image = new[] {"res://assets/ImageSized/isometric magasin6.png"}; NbrAmeliorations = 0; NbCar = 0; - Population =new[] {0}; + Population = new[] {0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/CentraleElectrique.cs b/Game/Buildings/Characteristics/CentraleElectrique.cs index 44cb88f..a6592cb 100644 --- a/Game/Buildings/Characteristics/CentraleElectrique.cs +++ b/Game/Buildings/Characteristics/CentraleElectrique.cs @@ -14,10 +14,11 @@ public CentraleElectrique() GainXp = new[] {10, 15}; energy = new[] {-30, -70}; water = new[] {3, 6}; - Image = new[] {"res://assets/ImageSized/isometric centrale1.png", "res://assets/ImageSized/isometric centrale2.png"}; + Image = new[] + {"res://assets/ImageSized/isometric centrale1.png", "res://assets/ImageSized/isometric centrale2.png"}; NbrAmeliorations = 1; NbCar = 0; - Population = new [] {0, 0}; + Population = new[] {0, 0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Eglise.cs b/Game/Buildings/Characteristics/Eglise.cs index 1c8ae81..23800e3 100644 --- a/Game/Buildings/Characteristics/Eglise.cs +++ b/Game/Buildings/Characteristics/Eglise.cs @@ -14,10 +14,14 @@ public Eglise() GainXp = new[] {10, 15, 30}; energy = new[] {2, 4, 6}; water = new[] {1, 3, 9}; - Image = new[] {"res://assets/ImageSized/isometric eglise1.png", "res://assets/ImageSized/isometric eglise5.png", "res://assets/ImageSized/isometric eglise4.png"}; + Image = new[] + { + "res://assets/ImageSized/isometric eglise1.png", "res://assets/ImageSized/isometric eglise5.png", + "res://assets/ImageSized/isometric eglise4.png" + }; NbrAmeliorations = 2; NbCar = 0; - Population = new []{0, 0, 0}; + Population = new[] {0, 0, 0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Eolienne.cs b/Game/Buildings/Characteristics/Eolienne.cs index abe280c..12a5904 100644 --- a/Game/Buildings/Characteristics/Eolienne.cs +++ b/Game/Buildings/Characteristics/Eolienne.cs @@ -17,7 +17,7 @@ public Eolienne() Image = new[] {"res://assets/ImageSized/isometric par eoliennes.png"}; NbrAmeliorations = 0; NbCar = 0; - Population = new []{0}; + Population = new[] {0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Epuration.cs b/Game/Buildings/Characteristics/Epuration.cs index c6a2339..eb1d532 100644 --- a/Game/Buildings/Characteristics/Epuration.cs +++ b/Game/Buildings/Characteristics/Epuration.cs @@ -8,7 +8,7 @@ public Epuration() { Bloc = new[] {Ref_donnees.stationEpuration}; Cost = new[] {3000}; - Earn = new[] {2,5,8}; + Earn = new[] {2, 5, 8}; Titre = new[] {"Epuration"}; Lvl = 0; GainXp = new[] {10, 100, 500}; @@ -17,7 +17,7 @@ public Epuration() Image = new[] {"res://assets/ImageSized/station epuration2.png"}; NbrAmeliorations = 0; NbCar = 3; - Population = new []{0}; + Population = new[] {0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Essence.cs b/Game/Buildings/Characteristics/Essence.cs index 04caa0f..acfbf78 100644 --- a/Game/Buildings/Characteristics/Essence.cs +++ b/Game/Buildings/Characteristics/Essence.cs @@ -17,7 +17,7 @@ public Essence() Image = new[] {"res://assets/ImageSized/isometric station service1.png"}; NbrAmeliorations = 0; NbCar = 2; - Population = new []{0}; + Population = new[] {0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Ferme.cs b/Game/Buildings/Characteristics/Ferme.cs index 54de3f7..0e360da 100644 --- a/Game/Buildings/Characteristics/Ferme.cs +++ b/Game/Buildings/Characteristics/Ferme.cs @@ -8,16 +8,17 @@ public Ferme() { Bloc = new[] {Ref_donnees.ferme, Ref_donnees.ferme_ecolo}; Cost = new[] {3000, 4000}; - Earn = new[] {2,5}; + Earn = new[] {2, 5}; Titre = new[] {"Ferme", "Ferme Ecolo"}; Lvl = 0; GainXp = new[] {10, 15}; energy = new[] {1, 0}; water = new[] {3, 0}; - Image = new[] {"res://assets/ImageSized/isometric ferme2.png", "res://assets/ImageSized/I ferme ecolobis.png"}; + Image = new[] + {"res://assets/ImageSized/isometric ferme2.png", "res://assets/ImageSized/I ferme ecolobis.png"}; NbrAmeliorations = 1; NbCar = 3; - Population = new []{0, 0}; + Population = new[] {0, 0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/FermeGrande.cs b/Game/Buildings/Characteristics/FermeGrande.cs index f8ce2de..be46879 100644 --- a/Game/Buildings/Characteristics/FermeGrande.cs +++ b/Game/Buildings/Characteristics/FermeGrande.cs @@ -14,10 +14,11 @@ public FermeGrande() GainXp = new[] {10, 15}; energy = new[] {10, 20}; water = new[] {11, 22}; - Image = new[] {"res://assets/ImageSized/isometric ferme3.png", "res://assets/ImageSized/isometric ferme4.png"}; + Image = new[] + {"res://assets/ImageSized/isometric ferme3.png", "res://assets/ImageSized/isometric ferme4.png"}; NbrAmeliorations = 1; NbCar = 2; - Population = new []{0, 0}; + Population = new[] {0, 0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/FeteForraine.cs b/Game/Buildings/Characteristics/FeteForraine.cs index 0b7f1d8..fa3bc04 100644 --- a/Game/Buildings/Characteristics/FeteForraine.cs +++ b/Game/Buildings/Characteristics/FeteForraine.cs @@ -17,7 +17,7 @@ public FeteForraine() Image = new[] {"res://assets/ImageSized/isometric fete foraine1.png"}; NbrAmeliorations = 0; NbCar = 2; - Population = new []{0}; + Population = new[] {0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Foot.cs b/Game/Buildings/Characteristics/Foot.cs index 838fd55..8586536 100644 --- a/Game/Buildings/Characteristics/Foot.cs +++ b/Game/Buildings/Characteristics/Foot.cs @@ -8,16 +8,21 @@ public Foot() { Bloc = new[] {Ref_donnees.foot, Ref_donnees.footlv2, Ref_donnees.footlv3}; Cost = new[] {3000, 10000, 20000}; - Earn = new[] {2,50, 100}; + Earn = new[] {2, 50, 100}; Titre = new[] {"Terrain Foot", "Stadium", "Stade"}; Lvl = 0; GainXp = new[] {10, 15, 30}; energy = new[] {1, 5, 10}; water = new[] {1, 5, 10}; - Image = new[] {"res://assets/ImageSized/isometric terrain foot1.png", "res://assets/ImageSized/isometric terrain foot2.png", "res://assets/ImageSized/isometric terrain foot3.png"}; + Image = new[] + { + "res://assets/ImageSized/isometric terrain foot1.png", + "res://assets/ImageSized/isometric terrain foot2.png", + "res://assets/ImageSized/isometric terrain foot3.png" + }; NbrAmeliorations = 2; NbCar = 1; - Population = new []{0, 0, 0}; + Population = new[] {0, 0, 0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Hospital.cs b/Game/Buildings/Characteristics/Hospital.cs index 85e7b60..106dad9 100644 --- a/Game/Buildings/Characteristics/Hospital.cs +++ b/Game/Buildings/Characteristics/Hospital.cs @@ -14,10 +14,14 @@ public Hospital() GainXp = new[] {10, 15, 30}; energy = new[] {2, 5, 10}; water = new[] {2, 5, 10}; - Image = new[] {"res://assets/ImageSized/hopital.png", "res://assets/ImageSized/hopital3.png", "res://assets/ImageSized/hopital4.png"}; + Image = new[] + { + "res://assets/ImageSized/hopital.png", "res://assets/ImageSized/hopital3.png", + "res://assets/ImageSized/hopital4.png" + }; NbrAmeliorations = 2; NbCar = 5; - Population = new []{0, 0, 0}; + Population = new[] {0, 0, 0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Hotel.cs b/Game/Buildings/Characteristics/Hotel.cs index 7d223fd..05ef005 100644 --- a/Game/Buildings/Characteristics/Hotel.cs +++ b/Game/Buildings/Characteristics/Hotel.cs @@ -1,4 +1,3 @@ -using System; using SshCity.Game.Plan; namespace SshCity.Game.Buildings.Characteristics @@ -9,13 +8,17 @@ public Hotel() { Bloc = new[] {Ref_donnees.hotel1, Ref_donnees.hotel, Ref_donnees.hotel2}; Cost = new[] {2000, 10000, 15000}; - Earn = new[] {2,15,50}; + Earn = new[] {2, 15, 50}; Titre = new[] {"Môtel", "Hotel", "Palace"}; Lvl = 0; GainXp = new[] {10, 15, 30}; energy = new[] {2, 10, 25}; water = new[] {2, 10, 25}; - Image = new[] {"res://assets/ImageSized/I hotel.png", "res://assets/ImageSized/hotel.png", "res://assets/ImageSized/isometric hotel1.png"}; + Image = new[] + { + "res://assets/ImageSized/I hotel.png", "res://assets/ImageSized/hotel.png", + "res://assets/ImageSized/isometric hotel1.png" + }; NbrAmeliorations = 2; NbCar = 3; Population = new[] {5, 20, 30}; diff --git a/Game/Buildings/Characteristics/Maison.cs b/Game/Buildings/Characteristics/Maison.cs index 3a12446..334ea23 100644 --- a/Game/Buildings/Characteristics/Maison.cs +++ b/Game/Buildings/Characteristics/Maison.cs @@ -8,13 +8,17 @@ public Maison() { Bloc = new[] {Ref_donnees.maison1, Ref_donnees.immeuble_vert, Ref_donnees.immeubleVert}; Cost = new[] {1000, 3000, 10000}; - Earn = new[] {1,2,5}; + Earn = new[] {1, 2, 5}; Titre = new[] {"Maison", "Immeuble", "Tour"}; Lvl = 0; GainXp = new[] {10, 15, 30}; - energy = new[] {1,3,6}; - water = new[] {1,3,3}; - Image = new[] {"res://assets/ImageSized/maison1.png", "res://assets/ImageSized/immeuble.png", "res://assets/ImageSized/isometric hotel.png"}; + energy = new[] {1, 3, 6}; + water = new[] {1, 3, 3}; + Image = new[] + { + "res://assets/ImageSized/maison1.png", "res://assets/ImageSized/immeuble.png", + "res://assets/ImageSized/isometric hotel.png" + }; NbrAmeliorations = 2; NbCar = 2; Population = new[] {5, 15, 30}; diff --git a/Game/Buildings/Characteristics/Maison3.cs b/Game/Buildings/Characteristics/Maison3.cs index 218ab61..5b924d5 100644 --- a/Game/Buildings/Characteristics/Maison3.cs +++ b/Game/Buildings/Characteristics/Maison3.cs @@ -12,8 +12,8 @@ public Maison3() Titre = new[] {"Maison", "Tour"}; Lvl = 0; GainXp = new[] {10, 15}; - energy = new[] {1,3}; - water = new[] {1,3}; + energy = new[] {1, 3}; + water = new[] {1, 3}; Image = new[] {"res://assets/ImageSized/maison3.png", "res://assets/ImageSized/maison2.png"}; NbrAmeliorations = 1; NbCar = 2; diff --git a/Game/Buildings/Characteristics/Maison4.cs b/Game/Buildings/Characteristics/Maison4.cs index 127dbb6..22d86d6 100644 --- a/Game/Buildings/Characteristics/Maison4.cs +++ b/Game/Buildings/Characteristics/Maison4.cs @@ -12,8 +12,8 @@ public Maison4() Titre = new[] {"Maison", "Tour"}; Lvl = 0; GainXp = new[] {10, 15}; - energy = new[] {1,3}; - water = new[] {1,3}; + energy = new[] {1, 3}; + water = new[] {1, 3}; Image = new[] {"res://assets/ImageSized/maison4.png", "res://assets/ImageSized/isometric immeuble.png"}; NbrAmeliorations = 1; NbCar = 2; diff --git a/Game/Buildings/Characteristics/Maison5.cs b/Game/Buildings/Characteristics/Maison5.cs index a6f2194..085e5dc 100644 --- a/Game/Buildings/Characteristics/Maison5.cs +++ b/Game/Buildings/Characteristics/Maison5.cs @@ -12,7 +12,7 @@ public Maison5() Titre = new[] {"Maison", "Maison Ecolo"}; Lvl = 0; GainXp = new[] {10, 15}; - energy = new[] {2,0}; + energy = new[] {2, 0}; water = new[] {2, 0}; Image = new[] {"res://assets/ImageSized/maison5.png", "res://assets/ImageSized/isometric maison ecolo.png"}; NbrAmeliorations = 1; diff --git a/Game/Buildings/Characteristics/Mosque.cs b/Game/Buildings/Characteristics/Mosque.cs index de6df3a..bc360ce 100644 --- a/Game/Buildings/Characteristics/Mosque.cs +++ b/Game/Buildings/Characteristics/Mosque.cs @@ -14,10 +14,14 @@ public Mosque() GainXp = new[] {10, 15, 30}; energy = new[] {1, 3, 6}; water = new[] {2, 3, 5}; - Image = new[] {"res://assets/ImageSized/isometric mosquee2.png", "res://assets/ImageSized/isometric mosquee1.png", "res://assets/ImageSized/isometric mosquee3.png"}; + Image = new[] + { + "res://assets/ImageSized/isometric mosquee2.png", "res://assets/ImageSized/isometric mosquee1.png", + "res://assets/ImageSized/isometric mosquee3.png" + }; NbrAmeliorations = 2; NbCar = 0; - Population =new[] {0, 0, 0}; + Population = new[] {0, 0, 0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Parc.cs b/Game/Buildings/Characteristics/Parc.cs index b77b775..adba1ad 100644 --- a/Game/Buildings/Characteristics/Parc.cs +++ b/Game/Buildings/Characteristics/Parc.cs @@ -8,13 +8,17 @@ public Parc() { Bloc = new[] {Ref_donnees.parc_enfant, Ref_donnees.parc2, Ref_donnees.parc3}; Cost = new[] {100, 1000, 5000}; - Earn = new[] {1, 3,6}; + Earn = new[] {1, 3, 6}; Titre = new[] {"Parc", "Parc", "Parc"}; Lvl = 0; GainXp = new[] {10, 15, 30}; energy = new[] {0, 0, 0}; water = new[] {0, 0, 0}; - Image = new[] {"res://assets/ImageSized/iso parc enfant4.png", "res://assets/ImageSized/I parc enfant.png", "res://assets/ImageSized/I parc enfant2.png"}; + Image = new[] + { + "res://assets/ImageSized/iso parc enfant4.png", "res://assets/ImageSized/I parc enfant.png", + "res://assets/ImageSized/I parc enfant2.png" + }; NbrAmeliorations = 2; NbCar = 0; Population = new[] {0, 0, 0}; diff --git a/Game/Buildings/Characteristics/Piscine.cs b/Game/Buildings/Characteristics/Piscine.cs index cee0a24..15dc54c 100644 --- a/Game/Buildings/Characteristics/Piscine.cs +++ b/Game/Buildings/Characteristics/Piscine.cs @@ -8,7 +8,7 @@ public Piscine() { Bloc = new[] {Ref_donnees.piscine}; Cost = new[] {10000}; - Earn = new[] {20,30,50}; + Earn = new[] {20, 30, 50}; Titre = new[] {"Piscine"}; Lvl = 0; GainXp = new[] {10, 100, 500}; diff --git a/Game/Buildings/Characteristics/Restaurant.cs b/Game/Buildings/Characteristics/Restaurant.cs index 8b20c7b..30f16e7 100644 --- a/Game/Buildings/Characteristics/Restaurant.cs +++ b/Game/Buildings/Characteristics/Restaurant.cs @@ -14,7 +14,8 @@ public Restaurant() GainXp = new[] {10, 15}; energy = new[] {1, 3}; water = new[] {2, 3}; - Image = new[] {"res://assets/ImageSized/isometric boutique5.png", "res://assets/ImageSized/isometric boutique9.png"}; + Image = new[] + {"res://assets/ImageSized/isometric boutique5.png", "res://assets/ImageSized/isometric boutique9.png"}; NbrAmeliorations = 1; NbCar = 0; Population = new[] {0, 0}; diff --git a/Game/Buildings/Characteristics/Solaire.cs b/Game/Buildings/Characteristics/Solaire.cs index 7d1ce89..d510c4f 100644 --- a/Game/Buildings/Characteristics/Solaire.cs +++ b/Game/Buildings/Characteristics/Solaire.cs @@ -17,7 +17,7 @@ public Solaire() Image = new[] {"res://assets/ImageSized/isometric parc panneaux solaires.png"}; NbrAmeliorations = 0; NbCar = 0; - Population =new[] {0}; + Population = new[] {0}; } public int[] Bloc { get; } diff --git a/Game/Buildings/Characteristics/Usine.cs b/Game/Buildings/Characteristics/Usine.cs index fe5a83e..be41616 100644 --- a/Game/Buildings/Characteristics/Usine.cs +++ b/Game/Buildings/Characteristics/Usine.cs @@ -12,9 +12,13 @@ public Usine() Titre = new[] {"Usine", "Usine", "Usine", "Usine"}; Lvl = 0; GainXp = new[] {10, 15, 30, 60}; - energy = new[] {5,10, 20, 30}; - water = new[] {2,4, 9, 15}; - Image = new[] {"res://assets/ImageSized/isometric usine1.png", "res://assets/ImageSized/isometric usine2.png", "res://assets/ImageSized/isometric usine3.png", "res://assets/ImageSized/isometric usine4.png"}; + energy = new[] {5, 10, 20, 30}; + water = new[] {2, 4, 9, 15}; + Image = new[] + { + "res://assets/ImageSized/isometric usine1.png", "res://assets/ImageSized/isometric usine2.png", + "res://assets/ImageSized/isometric usine3.png", "res://assets/ImageSized/isometric usine4.png" + }; NbrAmeliorations = 3; NbCar = 2; Population = new[] {0, 0, 0, 0}; diff --git a/Game/Incident/incidents.cs b/Game/Incident/incidents.cs index b545e7d..71731f3 100644 --- a/Game/Incident/incidents.cs +++ b/Game/Incident/incidents.cs @@ -1,215 +1,239 @@ using System; using System.Collections.Generic; -using System.Configuration; using System.Threading.Tasks; using Godot; using SshCity.Game.Plan; public class incidents : CanvasLayer { - /* Maximum des incidents potentiels */ - public const int MAX_INCENDIES = 1; - public const int MAX_ACCIDENT = 1; - public const int MAX_NOYADES = 1; - public const int MAX_BRACAGES = 1; - /* Nombre actuel des incidents */ - public static int Nbincendies = 0; - public static int Nbaccident = 0; - public static int Nbnoyades = 0; - public static int Nbbracages = 0; - /* definit si on peut resoudre un incident */ - public static bool ResoIncident = false; - public static bool ResoAccident = false; - public static bool ResoBracage = false; - public static bool ResoNoyade = false; - /* batiment a changer par son batiment accidente */ - private static int x, y; - private static int xincendie; - private static int yincendie; - private static int indexAvincendie; - private static int indexApincendie; - private static int xaccident; - private static int yaccident; - private static int indexAvaccident; - private static int indexApaccident; - private static int xnoyade; - private static int ynoyade; - private static int indexAvnoyade; - private static int indexApnoyade; - private static int xbracage; - private static int ybracage; - private static int indexAvbracage; - private static int indexApbracage; - /* niveau d apparition des differents incidents */ - private static int levelIncendie = 2; - public static int levelAccident = 0; - private static int levelNoyade = 8; - private static int levelBracage = 10; - /* Indique ou sont les incidents */ - public static List ListNoyade = new List(); - /* correction bug xp */ - public static bool XpIncident = false; - public static bool XpAccident = false; - public static bool XpBracage = false; - public static bool XpNoyade = false; - - - private const string _str_feu = "Feu"; - static AudioStreamPlayer _feu; - - public override void _Ready() - { - _feu = (AudioStreamPlayer) GetNode(_str_feu); - } - - public override void _Process(float delta) - { - base._Process(delta); - /* INCENDIES */ - if(Interface._level >= levelIncendie) - GenerateIncendies(MainPlan._planInitial); - if (menu_incident.TimerIncendie.IsStopped() && ResoIncident) // definit le temps entre l apparition de deux incendies - ResoIncident = false; - /* BRACAGES */ - if(Interface._level >= levelBracage) - GenerateBracage(MainPlan._planInitial); - if (menu_incident.TimerBracage.IsStopped() && ResoBracage) // definit le temps entre l apparition de deux bracage - ResoBracage = false; - /* NOYADES */ - if(Interface._level >= levelNoyade) - GenerateNoyade(MainPlan._planInitial); - if (menu_incident.TimerNoyade.IsStopped() && ResoNoyade) // definit le temps entre l apparition de deux noyades - ResoNoyade = false; - if (menu_incident.TimerAccident.IsStopped() && ResoAccident) - ResoAccident = false; - } - - public static (int x, int y, int indexAv, int indexAp) GenereCoords((int, int)[] listBat) - { /* Genere aleatoirement les coordonnees d un batiement a accidente */ - - var rand = new Random(); - var coordinates = new List(); // Liste de stockage des coordonnees de l incident - var nbBat = listBat.Length - 1; - int nbBloc; - int indexAv, indexAp; - - /* Ajoute a la liste toutes les positions du batiment a incendier */ - do { - (indexAv, indexAp) = listBat[rand.Next(0, nbBat)]; // choix aleatoire du batiment parmit les possibilites - - foreach (var building in MainPlan.ListeBatiment) - { - (Vector2 coords, int bat) = building; - if (bat == indexAv) - coordinates.Add(coords); - } - nbBloc = coordinates.Count - 1; - } while (nbBloc < 0); // verifie que le batiment existe et recommence s'il n'existe pas - - var pos = coordinates[rand.Next(0, nbBloc)]; // choisit aleatoirement un batiment parmit tous les batiments de meme type - x = (int) pos.x; - y = (int) pos.y; - return (x, y, indexAv, indexAp); - } - - /** INCENDIES **/ - public static void GenerateIncendies(PlanInitial planInitial) - { - if (ResoIncident && Nbincendies > 0) - { - if(XpIncident) - Interface.Xp += 30; - XpIncident = false; - Nbincendies--; - StopIncendie(planInitial); - } - else if (!ResoIncident && Nbincendies < MAX_INCENDIES) - { - (xincendie, yincendie, indexAvincendie, indexApincendie) = GenereCoords(Ref_donnees.BatimentFeu); - StartIncendie(planInitial); - XpIncident = true; - Nbincendies++; - } - } - public static async void StartIncendie(PlanInitial planInitial) - { /* change le batiment normal avec celui accidente */ - await Task.Delay(5000); - BuildingSwitch(planInitial, indexAvincendie, indexApincendie, xincendie, yincendie); - menu_incident.Flamme.Show(); - _feu.Play(); - } - public static async void StopIncendie(PlanInitial planInitial) - { /* revient au batiment normal */ - menu_incident.Flamme.Hide(); - await Task.Delay(3000); - BuildingSwitch(planInitial, indexApincendie, indexAvincendie, xincendie, yincendie); - menu_incident.TimerIncendie.Start(); - } - - /** BRACAGES **/ - public static void GenerateBracage(PlanInitial planInitial) - { - if (ResoBracage && Nbbracages > 0) - { - if(XpBracage) - Interface.Xp += 30; - XpBracage = false; - Nbbracages--; - StopBracage(planInitial); - } - else if (Nbbracages < MAX_BRACAGES && !ResoBracage) - { - (xbracage, ybracage, indexAvbracage, indexApbracage) = GenereCoords(Ref_donnees.BatimentVol); - StartBracage(planInitial); - XpBracage = true; - Nbbracages++; - } - } - public static async void StartBracage(PlanInitial planInitial) - { /*fait apparaitre une image de braqueur devant la maison */ - await Task.Delay(5000); - BuildingSwitch(planInitial, indexAvbracage, indexApbracage, xbracage, ybracage); - menu_incident.Bracage.Show(); - } - public static async void StopBracage(PlanInitial planInitial) - { /* supprime le bracage */ - menu_incident.Bracage.Hide(); - await Task.Delay(3000); - BuildingSwitch(planInitial, indexApbracage, indexAvbracage, xbracage, ybracage); - menu_incident.TimerBracage.Start(); - } - - /** NOYADES **/ - public static async void GenerateNoyade(PlanInitial planInitial) - { - if (ResoNoyade && Nbnoyades > 0) - { - if(XpNoyade) - Interface.Xp += 30; - XpNoyade = false; - Nbnoyades--; - menu_incident.Noyade.Hide(); - await Task.Delay(3000); - Lacs.GenerateLacNoyade(planInitial, Ref_donnees.lac1, xnoyade, ynoyade); - menu_incident.TimerNoyade.Start(); - } - else if (!ResoNoyade && Nbnoyades < MAX_NOYADES) - { - Random rand = new Random(); - (xnoyade, ynoyade) = Lacs.CoordsLac1[rand.Next(0, Lacs.CoordsLac1.Count - 1)]; - ListNoyade.Add(new Vector2(xnoyade, ynoyade)); - Nbnoyades++; - await Task.Delay(5000); - Lacs.GenerateLacNoyade(planInitial, Ref_donnees.lac1_noyade, xnoyade, ynoyade); - menu_incident.Noyade.Show(); - XpNoyade = true; - } - } - - public static void BuildingSwitch(PlanInitial planInitial, int indexAv, int indexAp, int x, int y) - { /* Change l'image d'un batiment */ - /* Initialise le bloc en x,y, comme batiment accidente */ - if (planInitial.GetBlock(planInitial.TileMap2, x, y) == indexAv) - planInitial.SetBlock(planInitial.TileMap2, x, y, indexAp); - } -} + /* Maximum des incidents potentiels */ + public const int MAX_INCENDIES = 1; + public const int MAX_ACCIDENT = 1; + public const int MAX_NOYADES = 1; + public const int MAX_BRACAGES = 1; + + + private const string _str_feu = "Feu"; + + /* Nombre actuel des incidents */ + public static int Nbincendies = 0; + public static int Nbaccident = 0; + public static int Nbnoyades = 0; + + public static int Nbbracages = 0; + + /* definit si on peut resoudre un incident */ + public static bool ResoIncident = false; + public static bool ResoAccident = false; + public static bool ResoBracage = false; + + public static bool ResoNoyade = false; + + /* batiment a changer par son batiment accidente */ + private static int x, y; + private static int xincendie; + private static int yincendie; + private static int indexAvincendie; + private static int indexApincendie; + private static int xaccident; + private static int yaccident; + private static int indexAvaccident; + private static int indexApaccident; + private static int xnoyade; + private static int ynoyade; + private static int indexAvnoyade; + private static int indexApnoyade; + private static int xbracage; + private static int ybracage; + private static int indexAvbracage; + + private static int indexApbracage; + + /* niveau d apparition des differents incidents */ + private static int levelIncendie = 2; + public static int levelAccident = 0; + private static int levelNoyade = 8; + + private static int levelBracage = 10; + + /* Indique ou sont les incidents */ + public static List ListNoyade = new List(); + + /* correction bug xp */ + public static bool XpIncident = false; + public static bool XpAccident = false; + public static bool XpBracage = false; + public static bool XpNoyade = false; + static AudioStreamPlayer _feu; + + public override void _Ready() + { + _feu = (AudioStreamPlayer) GetNode(_str_feu); + } + + public override void _Process(float delta) + { + base._Process(delta); + /* INCENDIES */ + if (Interface._level >= levelIncendie) + GenerateIncendies(MainPlan._planInitial); + if (menu_incident.TimerIncendie.IsStopped() && ResoIncident + ) // definit le temps entre l apparition de deux incendies + ResoIncident = false; + /* BRACAGES */ + if (Interface._level >= levelBracage) + GenerateBracage(MainPlan._planInitial); + if (menu_incident.TimerBracage.IsStopped() && ResoBracage + ) // definit le temps entre l apparition de deux bracage + ResoBracage = false; + /* NOYADES */ + if (Interface._level >= levelNoyade) + GenerateNoyade(MainPlan._planInitial); + if (menu_incident.TimerNoyade.IsStopped() && ResoNoyade) // definit le temps entre l apparition de deux noyades + ResoNoyade = false; + if (menu_incident.TimerAccident.IsStopped() && ResoAccident) + ResoAccident = false; + } + + public static (int x, int y, int indexAv, int indexAp) GenereCoords((int, int)[] listBat) + { + /* Genere aleatoirement les coordonnees d un batiement a accidente */ + + var rand = new Random(); + var coordinates = new List(); // Liste de stockage des coordonnees de l incident + var nbBat = listBat.Length - 1; + int nbBloc; + int indexAv, indexAp; + + /* Ajoute a la liste toutes les positions du batiment a incendier */ + do + { + (indexAv, indexAp) = listBat[rand.Next(0, nbBat)]; // choix aleatoire du batiment parmit les possibilites + + foreach (var building in MainPlan.ListeBatiment) + { + (Vector2 coords, int bat) = building; + if (bat == indexAv) + coordinates.Add(coords); + } + + nbBloc = coordinates.Count - 1; + } while (nbBloc < 0); // verifie que le batiment existe et recommence s'il n'existe pas + + var pos = coordinates[ + rand.Next(0, nbBloc)]; // choisit aleatoirement un batiment parmit tous les batiments de meme type + x = (int) pos.x; + y = (int) pos.y; + return (x, y, indexAv, indexAp); + } + + /** INCENDIES **/ + public static void GenerateIncendies(PlanInitial planInitial) + { + if (ResoIncident && Nbincendies > 0) + { + if (XpIncident) + Interface.Xp += 30; + XpIncident = false; + Nbincendies--; + StopIncendie(planInitial); + } + else if (!ResoIncident && Nbincendies < MAX_INCENDIES) + { + (xincendie, yincendie, indexAvincendie, indexApincendie) = GenereCoords(Ref_donnees.BatimentFeu); + StartIncendie(planInitial); + XpIncident = true; + Nbincendies++; + } + } + + public static async void StartIncendie(PlanInitial planInitial) + { + /* change le batiment normal avec celui accidente */ + await Task.Delay(5000); + BuildingSwitch(planInitial, indexAvincendie, indexApincendie, xincendie, yincendie); + menu_incident.Flamme.Show(); + _feu.Play(); + } + + public static async void StopIncendie(PlanInitial planInitial) + { + /* revient au batiment normal */ + menu_incident.Flamme.Hide(); + await Task.Delay(3000); + BuildingSwitch(planInitial, indexApincendie, indexAvincendie, xincendie, yincendie); + menu_incident.TimerIncendie.Start(); + } + + /** BRACAGES **/ + public static void GenerateBracage(PlanInitial planInitial) + { + if (ResoBracage && Nbbracages > 0) + { + if (XpBracage) + Interface.Xp += 30; + XpBracage = false; + Nbbracages--; + StopBracage(planInitial); + } + else if (Nbbracages < MAX_BRACAGES && !ResoBracage) + { + (xbracage, ybracage, indexAvbracage, indexApbracage) = GenereCoords(Ref_donnees.BatimentVol); + StartBracage(planInitial); + XpBracage = true; + Nbbracages++; + } + } + + public static async void StartBracage(PlanInitial planInitial) + { + /*fait apparaitre une image de braqueur devant la maison */ + await Task.Delay(5000); + BuildingSwitch(planInitial, indexAvbracage, indexApbracage, xbracage, ybracage); + menu_incident.Bracage.Show(); + } + + public static async void StopBracage(PlanInitial planInitial) + { + /* supprime le bracage */ + menu_incident.Bracage.Hide(); + await Task.Delay(3000); + BuildingSwitch(planInitial, indexApbracage, indexAvbracage, xbracage, ybracage); + menu_incident.TimerBracage.Start(); + } + + /** NOYADES **/ + public static async void GenerateNoyade(PlanInitial planInitial) + { + if (ResoNoyade && Nbnoyades > 0) + { + if (XpNoyade) + Interface.Xp += 30; + XpNoyade = false; + Nbnoyades--; + menu_incident.Noyade.Hide(); + await Task.Delay(3000); + Lacs.GenerateLacNoyade(planInitial, Ref_donnees.lac1, xnoyade, ynoyade); + menu_incident.TimerNoyade.Start(); + } + else if (!ResoNoyade && Nbnoyades < MAX_NOYADES) + { + Random rand = new Random(); + (xnoyade, ynoyade) = Lacs.CoordsLac1[rand.Next(0, Lacs.CoordsLac1.Count - 1)]; + ListNoyade.Add(new Vector2(xnoyade, ynoyade)); + Nbnoyades++; + await Task.Delay(5000); + Lacs.GenerateLacNoyade(planInitial, Ref_donnees.lac1_noyade, xnoyade, ynoyade); + menu_incident.Noyade.Show(); + XpNoyade = true; + } + } + + public static void BuildingSwitch(PlanInitial planInitial, int indexAv, int indexAp, int x, int y) + { + /* Change l'image d'un batiment */ + /* Initialise le bloc en x,y, comme batiment accidente */ + if (planInitial.GetBlock(planInitial.TileMap2, x, y) == indexAv) + planInitial.SetBlock(planInitial.TileMap2, x, y, indexAp); + } +} \ No newline at end of file diff --git a/Game/Incident/menu_incident.cs b/Game/Incident/menu_incident.cs index 9ac1a94..2eb1a6a 100644 --- a/Game/Incident/menu_incident.cs +++ b/Game/Incident/menu_incident.cs @@ -1,6 +1,4 @@ -using System.Threading.Tasks; using Godot; -using SshCity.Game.Buildings; using SshCity.Game.Plan; public class menu_incident : CanvasLayer @@ -20,6 +18,7 @@ public class menu_incident : CanvasLayer private static string CaserneNon = "Attention, vous avez un incendie en cours. \n " + "Pour l'éteindre, dirigez-vous vers la boutique afin d'acheter une caserne de pompiers. \n "; + private static string CaserneOui = "Attention, vous avez un incendie en cours. \n " + "Vous possédez le matériel adéquate pour mettre fin à cet incident \n" + @@ -27,20 +26,23 @@ public class menu_incident : CanvasLayer "Pour ce faire, cliquez sur la caserne puis cliquez sur camion \n" + "Cliquez ensuite sur ce camion et dirigez-le à l'aide des flèches du clavier \n" + "Une fois le camion arrivé, l'incendie s'éteindra"; - + private static string PoliceNonB = "Attention, vous avez un bracage en cours. \n " + "Pour le résoudre, dirigez-vous vers la boutique afin d'acheter un commissariat. \n "; + private static string PoliceOuiB = "Attention, vous avez un bracage en cours. \n " + "Vous possédez le matériel adéquate pour mettre fin à cet incident \n" + "Dirigez-vous vers le commissariat afin de sortir et d'ammener la voiture vers le lieu du bracage \n" + "Pour ce faire, cliquez sur le commissariat puis sur police \n" + "Cliquez ensuite sur cette voiture et dirigez-la à l'aide des flèches du clavier \n" + - "Une fois la voiture arrivée, vous arrêterez le voleur"; + "Une fois la voiture arrivée, vous arrêterez le voleur"; + private static string PoliceNonA = "Attention, vous avez un accident en cours. \n " + "Pour le résoudre, dirigez-vous vers la boutique afin d'acheter un commissariat. \n "; + private static string PoliceOuiA = "Attention, vous avez un accident en cours. \n " + "Vous possédez le matériel adéquate pour mettre fin à cet incident \n" + @@ -48,10 +50,11 @@ public class menu_incident : CanvasLayer "Pour ce faire, cliquez sur l'hôpital puis sur ambulance\n" + "Cliquez ensuite sur celle-ci et dirigez-la à l'aide des flèches du clavier \n" + "Une fois l'ambulance arrivée, vous prendrez en charge l'accident"; - + private static string HopitalNon = "Attention, une personne de votre ville se noie. \n " + "Pour la sauver, dirigez-vous vers la boutique afin d'acheter un hôpital. \n "; + private static string HopitalOui = "Attention, une personne de votre ville se noie. \n " + "Vous possédez le matériel adéquate pour sauver cette personne \n" + @@ -59,25 +62,26 @@ public class menu_incident : CanvasLayer "Pour ce faire, cliquez sur l'hôpital puis sur hélicoptère\n" + "Une fois l'hélicoptère arrivé, il prendra en charge la personne"; - /* VARIABLES : boutons menu incident */ - public Button BoutiqueCaserne; - public Button BoutiquePolice; - public Button BoutiqueHopital; - public Button Quitter; - public Sprite Croix; - /* Timer incidents */ public static Timer TimerIncendie; public static Timer TimerAccident; public static Timer TimerBracage; public static Timer TimerNoyade; - + public TextureRect Background; + + /* VARIABLES : boutons menu incident */ + public Button BoutiqueCaserne; + public Button BoutiqueHopital; + public Button BoutiquePolice; + public Sprite Croix; + public Button Quitter; public Label Texte; public override void _Ready() - { /* Definitions et connections des boutons */ + { + /* Definitions et connections des boutons */ BoutiqueCaserne = (Button) GetNode("BoutiqueCaserne"); BoutiqueHopital = (Button) GetNode("BoutiqueHopital"); BoutiquePolice = (Button) GetNode("BoutiquePolice"); @@ -109,10 +113,11 @@ public override void _Ready() Bracage.Connect("pressed", this, nameof(ResolutionBracage)); Noyade.Connect("pressed", this, nameof(ResolutionNoyade)); } - + private void HideAll() - { /* Cache le menu incident */ + { + /* Cache le menu incident */ BoutiqueCaserne.Hide(); BoutiquePolice.Hide(); BoutiqueHopital.Hide(); @@ -123,34 +128,38 @@ private void HideAll() } private void on_boutique_caserne_pressed() - { /* Appui sur le bouton boutique => ouverture boutique fond cligno caserne */ + { + /* Appui sur le bouton boutique => ouverture boutique fond cligno caserne */ HideAll(); CaserneopenShop = true; } - + private void on_boutique_police_pressed() - { /* Appui sur le bouton boutique => ouverture boutique fond cligno police */ + { + /* Appui sur le bouton boutique => ouverture boutique fond cligno police */ HideAll(); PoliceopenShop = true; } - + private void on_boutique_hopital_pressed() - { /* Appui sur le bouton boutique => ouverture boutique fond cligno hopital */ + { + /* Appui sur le bouton boutique => ouverture boutique fond cligno hopital */ HideAll(); HopitalopenShop = true; } - - + + private void ResolutionIncendie() { CloseAll(); // ferme tous les autres menu Background.Show(); Quitter.Show(); Croix.Show(); - + if (MainPlan.ExistBatiment(Ref_donnees.caserne)) // si la caserne est deja presente Texte.Text = CaserneOui; - else { + else + { Texte.Text = CaserneNon; BoutiqueCaserne.Show(); // bouton pour aller vers la boutique } @@ -164,53 +173,57 @@ private void ResolutionAccident() Background.Show(); Quitter.Show(); Croix.Show(); - + if (MainPlan.ExistBatiment(Ref_donnees.hopital)) // si l'hopital est deja present Texte.Text = PoliceOuiA; - else { + else + { Texte.Text = PoliceNonA; BoutiqueHopital.Show(); // bouton pour aller vers la boutique } - + Texte.Show(); } - + private void ResolutionBracage() - { + { CloseAll(); // ferme tous les autres menu Background.Show(); Quitter.Show(); Croix.Show(); - + if (MainPlan.ExistBatiment(Ref_donnees.police)) // si la police est deja presente Texte.Text = PoliceOuiB; - else { + else + { Texte.Text = PoliceNonB; BoutiquePolice.Show(); // bouton pour aller vers la boutique } - + Texte.Show(); } - + private void ResolutionNoyade() { CloseAll(); // ferme tous les autres menu Background.Show(); Quitter.Show(); Croix.Show(); - + if (MainPlan.ExistBatiment(Ref_donnees.hopital)) // si l'hopital est deja present Texte.Text = HopitalOui; - else { + else + { Texte.Text = HopitalNon; BoutiqueHopital.Show(); // bouton pour aller vers la boutique } - + Texte.Show(); } - private void CloseAll() - { /* ferme tous les autres menu */ + private void CloseAll() + { + /* ferme tous les autres menu */ OpenIncident = true; Infos.Close = true; PlanInitial.AchatRoute(false); diff --git a/Game/Interface/Activation.cs b/Game/Interface/Activation.cs index 54c8633..3473274 100644 --- a/Game/Interface/Activation.cs +++ b/Game/Interface/Activation.cs @@ -8,12 +8,12 @@ public static bool isNextToRoad(PlanInitial planInitial, Vector2 tile, int bloc) { Func NextToRoad = delegate(Vector2 vector2) { - return Routes.IsRoute(planInitial.GetBlock(planInitial.TileMap2, (int)vector2.x-1, (int)vector2.y)) || - Routes.IsRoute(planInitial.GetBlock(planInitial.TileMap2, (int)vector2.x+1, (int)vector2.y)) || - Routes.IsRoute(planInitial.GetBlock(planInitial.TileMap2, (int)vector2.x, (int)vector2.y-1)) || - Routes.IsRoute(planInitial.GetBlock(planInitial.TileMap2, (int)vector2.x, (int)vector2.y+1)); + return Routes.IsRoute(planInitial.GetBlock(planInitial.TileMap2, (int) vector2.x - 1, (int) vector2.y)) || + Routes.IsRoute(planInitial.GetBlock(planInitial.TileMap2, (int) vector2.x + 1, (int) vector2.y)) || + Routes.IsRoute(planInitial.GetBlock(planInitial.TileMap2, (int) vector2.x, (int) vector2.y - 1)) || + Routes.IsRoute(planInitial.GetBlock(planInitial.TileMap2, (int) vector2.x, (int) vector2.y + 1)); }; - + bool res = false; (int largeur, int longueur) dimensions = (1, 1); try @@ -37,20 +37,20 @@ public static bool isNextToRoad(PlanInitial planInitial, Vector2 tile, int bloc) public static bool isRaccordeEnEau(PlanInitial planInitial, Vector2 tile, int bloc, int consomationEau) { - if (bloc != Ref_donnees.stationEpuration) { if (consomationEau == 0) { return true; } - return (planInitial.GetBlock(planInitial.TileMap0, (int) tile.x+1, (int) tile.y+1) == + + return (planInitial.GetBlock(planInitial.TileMap0, (int) tile.x + 1, (int) tile.y + 1) == Ref_donnees.sol_maisonEau); } else { - return (planInitial.GetBlock(planInitial.TileMap0, (int) tile.x+1, (int) tile.y+1) == + return (planInitial.GetBlock(planInitial.TileMap0, (int) tile.x + 1, (int) tile.y + 1) == Ref_donnees.sol_stationEpuration); } } -} +} \ No newline at end of file diff --git a/Game/Interface/Boutique.cs b/Game/Interface/Boutique.cs index 524169a..0d64db3 100644 --- a/Game/Interface/Boutique.cs +++ b/Game/Interface/Boutique.cs @@ -14,19 +14,19 @@ public class Boutique : CanvasLayer private const string _str_menuBienEtre = _str_background + "/MenuBienEtre"; private const string _str_menuEconomie = _str_background + "/MenuEconomie"; private const string _str_Quitter = _str_background + "/Quitter"; + public static bool BoutiqueOpen = false; private Panel _background; private Button _button_bien_etre; private Button _button_economie; private Button _button_habitation; private Button _button_sante; private Button _button_speciaux; - private Button _quitter; private MenuBienEtre _menuBienEtre; private MenuEconomie _menuEconomie; private MenuHabitation _menuHabitation; private MenuSante _menuSante; private MenuSpeciaux _menuSpeciaux; - public static bool BoutiqueOpen = false; + private Button _quitter; public override void _Ready() { @@ -92,7 +92,7 @@ public void ButtonSpeciauxPressed() public void ButtonBienEtrePressed() { - _menuBienEtre.Reset(); + _menuBienEtre.Reset(); _button_economie.Pressed = false; _button_habitation.Pressed = false; _button_sante.Pressed = false; @@ -170,7 +170,7 @@ public override void _Process(float delta) ViewShop(true); } else - + { MenuSante._clignoCaserne.Hide(); MenuSante._clignoHopital.Hide(); diff --git a/Game/Interface/Carte_achat/Carte.cs b/Game/Interface/Carte_achat/Carte.cs index f2d5841..5009879 100644 --- a/Game/Interface/Carte_achat/Carte.cs +++ b/Game/Interface/Carte_achat/Carte.cs @@ -13,12 +13,12 @@ public class Carte : Panel private int _bloc = 1; private Button _buttonAchat; private int _cost; + private Label _eau; + private Label _energie; private Label _gain; private Label _prix; private Sprite _sprite; private Label _titre; - private Label _energie; - private Label _eau; public int Cost { diff --git a/Game/Interface/DeleteVerif.cs b/Game/Interface/DeleteVerif.cs index e178a07..1ebeab9 100644 --- a/Game/Interface/DeleteVerif.cs +++ b/Game/Interface/DeleteVerif.cs @@ -32,7 +32,7 @@ public void ButtonOuiPressed() _verif = false; Interface.Delete = false; this.Hide(); - if(Parametres.effets) + if (Parametres.effets) _supression.Play(); } diff --git a/Game/Interface/Infos.cs b/Game/Interface/Infos.cs index e3d78e3..9f1fb41 100644 --- a/Game/Interface/Infos.cs +++ b/Game/Interface/Infos.cs @@ -32,37 +32,37 @@ public class Infos : Panel private static bool _close = false; private static bool _isOpen = false; - - private Label _amelioGainValue; + private AudioStreamPlayer _ambulance; private Label _amelioGainBatiment; + + private Label _amelioGainValue; private Panel _amelioPanel; private Button _ameliorer; private Label _argentActuel; - private Label _gainBatiment; - private Label _gainValue; private Label _argentAmelio; + private Button _buttonHelicopter; private Panel _cadre; private BuildingType _class; private Label _eauActuel; private Label _eauAmelio; private Label _energieActuel; private Label _energieAmelio; + private Label _gainBatiment; + private Label _gainValue; + private AudioStreamPlayer _helico; private Sprite _image; private Label _lvlActuel; private Panel _nivMax; + private AudioStreamPlayer _police; + private AudioStreamPlayer _pompier; private Button _quitter; private Label _titre; private Vehicules.Type _type; private Button _vehicule; private bool buttonWork = false; - private Vector2 position; - private Button _buttonHelicopter; - private AudioStreamPlayer _ambulance; - private AudioStreamPlayer _police; - private AudioStreamPlayer _helico; - private AudioStreamPlayer _pompier; public Vector2 CamionPos; + private Vector2 position; public static bool IsOpen { @@ -77,8 +77,8 @@ public static bool Close } public override void _Ready() - { - _ambulance = (AudioStreamPlayer) GetNode(_str_ambulance); + { + _ambulance = (AudioStreamPlayer) GetNode(_str_ambulance); _police = (AudioStreamPlayer) GetNode(_str_police); _helico = (AudioStreamPlayer) GetNode(_str_helico); _pompier = (AudioStreamPlayer) GetNode(_str_pompier); @@ -127,14 +127,15 @@ public void EnvoieVehicule() { _police.Play(); } - else if (_type == Vehicules.Type.AMBULANCE && Parametres.effets) + else if (_type == Vehicules.Type.AMBULANCE && Parametres.effets) { _ambulance.Play(); } - else if (_type == Vehicules.Type.CAMION && Parametres.effets) + else if (_type == Vehicules.Type.CAMION && Parametres.effets) { _pompier.Play(); } + PlanInitial.AddVehicule(_type, position); } @@ -144,7 +145,7 @@ public void EnvoieHelicopter() { CloseInfos(); Vector2 where = incidents.ListNoyade[0]; - if(Parametres.effets) + if (Parametres.effets) _helico.Play(); incidents.ListNoyade.Remove(where); PlanInitial.AddHouloucoupter(Houloucoupter.Type.HOPITAL, position, where); @@ -157,13 +158,14 @@ public bool config(Vector2 tile) if (batiment != null) { _titre.Text = batiment.Characteristics.Titre[batiment.Characteristics.Lvl]; - Texture texture = ResourceLoader.Load(batiment.Characteristics.Image[batiment.Characteristics.Lvl]) as Texture; + Texture texture = + ResourceLoader.Load(batiment.Characteristics.Image[batiment.Characteristics.Lvl]) as Texture; _image.Texture = texture; position = tile; _lvlActuel.Text = "Lvl " + Convert.ToString(batiment.Characteristics.Lvl + 1); _argentActuel.Text = Convert.ToString(batiment.Characteristics.Earn[batiment.Characteristics.Lvl]); _class = batiment.Type; - if (batiment.Characteristics.energy[batiment.Characteristics.Lvl] <0 ) + if (batiment.Characteristics.energy[batiment.Characteristics.Lvl] < 0) { _energieActuel.Text = "0"; } @@ -171,7 +173,8 @@ public bool config(Vector2 tile) { _energieActuel.Text = Convert.ToString(batiment.Characteristics.energy[batiment.Characteristics.Lvl]); } - if (batiment.Characteristics.water[batiment.Characteristics.Lvl] <0 ) + + if (batiment.Characteristics.water[batiment.Characteristics.Lvl] < 0) { _eauActuel.Text = "0"; } @@ -185,13 +188,13 @@ public bool config(Vector2 tile) _gainBatiment.Text = "Habitant :"; _gainValue.Text = "" + batiment.Characteristics.Population[batiment.Characteristics.Lvl]; } - else if(batiment.Characteristics.energy[batiment.Characteristics.Lvl] < 0) + else if (batiment.Characteristics.energy[batiment.Characteristics.Lvl] < 0) { _gainBatiment.Text = "Energie :"; _gainValue.Text = "" + -batiment.Characteristics.energy[batiment.Characteristics.Lvl]; } else if (batiment.Characteristics.water[batiment.Characteristics.Lvl] < 0) - { + { _gainBatiment.Text = "Eau :"; _gainValue.Text = "" + -batiment.Characteristics.water[batiment.Characteristics.Lvl]; } @@ -200,29 +203,31 @@ public bool config(Vector2 tile) _gainBatiment.Text = ""; _gainValue.Text = ""; } - + if (batiment.Characteristics.Lvl != batiment.Characteristics.NbrAmeliorations) { _amelioPanel.Show(); _nivMax.Hide(); _argentAmelio.Text = Convert.ToString(batiment.Characteristics.Earn[batiment.Characteristics.Lvl + 1]); - _energieAmelio.Text = Convert.ToString(batiment.Characteristics.energy[batiment.Characteristics.Lvl + 1]); + _energieAmelio.Text = + Convert.ToString(batiment.Characteristics.energy[batiment.Characteristics.Lvl + 1]); _eauAmelio.Text = Convert.ToString(batiment.Characteristics.water[batiment.Characteristics.Lvl + 1]); - _ameliorer.Text = "Ameliorer\n" + Convert.ToString(batiment.Characteristics.Cost[batiment.Characteristics.Lvl +1]); - if (batiment.Characteristics.Population[batiment.Characteristics.Lvl +1] != 0) + _ameliorer.Text = "Ameliorer\n" + + Convert.ToString(batiment.Characteristics.Cost[batiment.Characteristics.Lvl + 1]); + if (batiment.Characteristics.Population[batiment.Characteristics.Lvl + 1] != 0) { _amelioGainBatiment.Text = "Habitant :"; - _amelioGainValue.Text = "" + batiment.Characteristics.Population[batiment.Characteristics.Lvl +1]; + _amelioGainValue.Text = "" + batiment.Characteristics.Population[batiment.Characteristics.Lvl + 1]; } - else if(batiment.Characteristics.energy[batiment.Characteristics.Lvl +1] < 0) + else if (batiment.Characteristics.energy[batiment.Characteristics.Lvl + 1] < 0) { _amelioGainBatiment.Text = "Energie :"; - _amelioGainValue.Text = "" + -batiment.Characteristics.energy[batiment.Characteristics.Lvl +1]; + _amelioGainValue.Text = "" + -batiment.Characteristics.energy[batiment.Characteristics.Lvl + 1]; } - else if (batiment.Characteristics.water[batiment.Characteristics.Lvl +1] < 0) - { + else if (batiment.Characteristics.water[batiment.Characteristics.Lvl + 1] < 0) + { _amelioGainBatiment.Text = "Eau :"; - _amelioGainValue.Text = "" + -batiment.Characteristics.water[batiment.Characteristics.Lvl +1]; + _amelioGainValue.Text = "" + -batiment.Characteristics.water[batiment.Characteristics.Lvl + 1]; } else { @@ -266,7 +271,7 @@ public override void _Process(float delta) } if (_class == BuildingType.CASERNE) - { + { _vehicule.Text = "Camion"; _vehicule.Show(); _type = Vehicules.Type.CAMION; diff --git a/Game/Interface/Interface.cs b/Game/Interface/Interface.cs index 51f7b63..d0744dc 100644 --- a/Game/Interface/Interface.cs +++ b/Game/Interface/Interface.cs @@ -19,41 +19,27 @@ public class Interface : CanvasLayer private const string _str_croixJaune = "CroixJaune"; private const string _str_infos = "Infos"; private const string _str_timer = "Timer"; + private const string _strButtonTuyaux = "ButtonTuyaux"; + private const string _strButonExit = "ButtonExitEau"; private static bool _interdit = false; private static bool _interdiMoney = false; private static Infos _infos; - private const string _strButtonTuyaux = "ButtonTuyaux"; - private const string _strButonExit = "ButtonExitEau"; private static bool _infosBool = false; private static PlanInitial _planInitial; - - private Button _buttonExit; private static Button _buttonTuyaux; private static int _money = Ref_donnees.argent; private static int _energy = Ref_donnees.energy; private static int _water = Ref_donnees.water; private static bool _hide = true; - private bool _achatRoute = false; - private bool _achatTuyaux = false; - private Sprite _bulldozerMouse; private static Button _button_shop; private static Button _buttonDelete; private static Button _buttonRoute; private static Button _buttonEau; - public Sprite _croix; - private Sprite _croixJaune; - private Sprite _rouages; private static bool _delete = false; private static Panel _money_couleur; private static Label _money_text; - private Label _energy_text; - private Label _water_text; - private AudioStreamPlayer _ouvertureboutique; - private Boutique _shop; - private Timer _timer; - private bool _visible; - + /* ScoreBar */ private static TextureProgress ScoreBar; private static Label Score; @@ -61,13 +47,27 @@ public class Interface : CanvasLayer public static int _level = 1; // niveau private static int XpMax = 30; public static bool levelup = false; - + private static int moneyWin = 0; private static int energyused = 0; private static int waterused = 0; private static bool _moneyAutomatique = true; - + public static List ListTuyaux = new List(); + private bool _achatRoute = false; + private bool _achatTuyaux = false; + private Sprite _bulldozerMouse; + + private Button _buttonExit; + public Sprite _croix; + private Sprite _croixJaune; + private Label _energy_text; + private AudioStreamPlayer _ouvertureboutique; + private Sprite _rouages; + private Boutique _shop; + private Timer _timer; + private bool _visible; + private Label _water_text; public static bool MoneyAutomatique { @@ -157,7 +157,7 @@ public override void _Ready() _timer = (Timer) GetNode(_str_timer); ScoreBar = (TextureProgress) GetNode("ScoreBar"); Score = GetNode