//Liaison avec le script Action public void DrawSpyResult(int info, ResultType resultType, Espion spy, Villes town) { if (resultType == ResultType.GARNISON) { Notifications.SetActive(true); GarnisonText.transform.parent.gameObject.SetActive(true); ReturnFromNotificationButton.SetActive(true); CityInfoPanel.SetActive(false); GarnisonText.text = "Votre espion " + spy.namePerso + " revient victorieux de sa mission d'espionnage dans la ville " + town.nameVilles + ". Il y a découvert l'étendue des forces présentes : " + info + " hommes."; } else if (resultType == ResultType.GOLD) { Notifications.SetActive(true); GoldText.transform.parent.gameObject.SetActive(true); ReturnFromNotificationButton.SetActive(true); CityInfoPanel.SetActive(false); GoldText.text = "Votre espion " + spy.namePerso + " revient victorieux de sa mission d'espionnage dans la ville " + town.nameVilles + ". Il y a découvert l'étendue des richesses présentes : " + info + " Or."; } else if (resultType == ResultType.DEADSPY) { Notifications.SetActive(true); DeadSpyText.transform.parent.gameObject.SetActive(true); ReturnFromNotificationButton.SetActive(true); CityInfoPanel.SetActive(false); DeadSpyText.text = "Votre espion " + spy.namePerso + " n'est jamais revenu de sa mission d'espionnage dans la ville " + town.nameVilles + "."; } addEspionnageToHistoriqueList(info, resultType, spy, town); }
public Espion(Espion spion) : base(spion.namePerso) { owned = false; fuite = spion.fuite; perception = spion.perception; discretion = spion.discretion; description = spion.description; }
// supprime l'élément de la liste en cas d'égalité sur le nom public void delEspion(Espion espion) { for (int i = 0; i < espion_list.Capacity; i++) { if (espion_list[i].namePerso == espion.namePerso) { espion_list.RemoveAt(i); break; // on break car on est sûr de supprimer au maximum un seul espion, et la longueur de la liste a diminué de 1 après la suppression, donc erreur de pointeur si on continue } } }
void addEspionnageToHistoriqueList(int info, ResultType resultType, Espion spy, Villes town) { if (resultType == ResultType.GOLD) { historiqueList.Add(town.nameVilles + " possède " + town.gold_known.value_known + " Or. Merci " + spy.namePerso + "."); } else if (resultType == ResultType.GARNISON) { historiqueList.Add(town.nameVilles + " possède " + town.garni_known.value_known + " hommes. Merci " + spy.namePerso + "."); } else if (resultType == ResultType.DEADSPY) { historiqueList.Add(spy.namePerso + ", " + town.nameVilles + ", RIP."); } }
public void DrawSpySpecial(string info, ResultType resultType, Espion spy, Villes town) { Notifications.SetActive(true); if (resultType == ResultType.KNIGHTS) { IsKnightNotificationPanel.SetActive(true); IsKnightNotificationPanel.GetComponentInChildren <Text>().text = info; } else if (resultType == ResultType.TREBUCHET) { IsTrebuchetNotificationPanel.SetActive(true); IsTrebuchetNotificationPanel.GetComponentInChildren <Text>().text = info; } else if (resultType == ResultType.EVENT) { IsEventNotificationPanel.SetActive(true); IsEventNotificationPanel.GetComponentInChildren <Text>().text = info; } }
public void Espionnage(Drakkar joueur, Espion spy, Villes town, Time time) { if (town.perception > spy.discretion) { time.max_turn -= 1; if (town.capture > spy.fuite) { //Urgal : delete espion joueur.delEspion(spy); UIManager.DrawSpyResult(0, ResultType.DEADSPY, spy, town); } else { getinfo(town, spy, time); //todo faire la distinction de cas } } else { getinfo(town, spy, time); } timeScript.updateTurn(gameManager); }
public void getinfo(Villes town, Espion spy, Time time) { int quality = 20 - spy.perception; int info = UnityEngine.Random.Range(1, 3); if (info == 1) { town.garni_known.is_known = true; town.garni_known.turn_known = time.currentTurn; float percent = (float)town.garnison.number / 100f; int success = UnityEngine.Random.Range(100 - quality, 100 + quality); town.garni_known.value_known = (int)Math.Floor((float)success * percent); //Urgal : espionnage de la garnison UIManager.DrawSpyResult(town.garni_known.value_known, ResultType.GARNISON, spy, town); } else { town.gold_known.is_known = true; town.gold_known.turn_known = time.currentTurn; float percent = town.gold / 100; int success = UnityEngine.Random.Range(100 - quality, 100 + quality); town.gold_known.value_known = (int)Math.Floor(success * percent); //Urgal : espionnage de l'or UIManager.DrawSpyResult(town.gold_known.value_known, ResultType.GOLD, spy, town); } if (town.is_knights) { //todo urgal, add message knights string descr = ""; //"Blabla Knights"; UIManager.DrawSpySpecial(descr, ResultType.KNIGHTS, spy, town); } if (town.is_trebuchet) { //todo urgal, add message trebuchet string descr = ""; //"Blabla Trebuchet"; UIManager.DrawSpySpecial(descr, ResultType.TREBUCHET, spy, town); } if (town.is_event) { //todo urgal string descr = time.getdescrpevent(town.current_event); UIManager.DrawSpySpecial(descr, ResultType.EVENT, spy, town); switch (town.current_event) { case 1: SoundManager.PlayBruitage("mariage"); break; case 2: SoundManager.PlayBruitage("event"); break; case 3: SoundManager.PlayBruitage("priest"); break; case 4: SoundManager.PlayBruitage("event"); break; case 5: SoundManager.PlayBruitage("hollandais"); break; default: SoundManager.PlayBruitage("event"); break; } } else { SoundManager.PlayBruitage("espionnage"); } }
// Use this for initialization void Start() { Villages = GameObject.Find("Villages"); //init du roi king = false; SoundManager.PlayMusique("main"); // init des espions Espion Blake = new Espion(2, 15, 3, "Blake", "Un espion assez compétent et discret, mais au charisme d’un hanneton malade. A tendance à attirer les problèmes mais compense par sa vitesse de course."); Espion Sammy = new Espion(4, 18, 0, "Sammy", "Vient au calme, voit bien et pars vite, sans se soucier d’avoir été vu par 99% de la ville. Forcément, l'intérêt des infos ramenées est proportionnel à la méfiance générée chez les gueux."); Espion Willy = new Espion(1, 10, 2, "Willy", "Homme à l’origine douteuse se prétendant espion. Il est plutôt médiocre, mais à le mérite d’être volontaire. Willy a des spasmes étranges et parle parfois à Willy."); Espion Flantier = new Espion(0, 13, 3, "Flantier", "Travaillant toujours avec classe et élégance, cet espion qui a bien roulé sa bosse connaît les ficelles du métier. Cependant, ses capacités de fuite et d’intimidation sont grandement compromises à cause de son âge avancé."); List <Espion> ShopList = new List <Espion>(3); int randEspion = UnityEngine.Random.Range(0, 4); switch (randEspion) { case 0: drakkar.espion_list.Add(Blake); ShopList.Add(Sammy); ShopList.Add(Willy); ShopList.Add(Flantier); UImanager.EspionOwnedDisplayStart(); break; case 1: drakkar.espion_list.Add(Sammy); ShopList.Add(Blake); ShopList.Add(Willy); ShopList.Add(Flantier); UImanager.EspionOwnedDisplayStart(); break; case 2: drakkar.espion_list.Add(Willy); ShopList.Add(Sammy); ShopList.Add(Blake); ShopList.Add(Flantier); UImanager.EspionOwnedDisplayStart(); break; case 3: drakkar.espion_list.Add(Flantier); ShopList.Add(Sammy); ShopList.Add(Willy); ShopList.Add(Blake); UImanager.EspionOwnedDisplayStart(); break; } // init des villes Soldat knights = new Soldat(3, 3, 4, 2, 20, "Chevaliers Errants"); Soldat trebuchet = new Soldat(20, 1, 20, 15, 1, "Trébuchet"); Soldat no_one = new Soldat(0, 0, 0, 0, 0, "personne"); TownList = new List <Villes>(); // listes des noms List <string> nameList = new List <string> { "city 1", "city 2", "city 3", "city 4", "city 5", "city 6", "city 7", "city 8", "city 9", "city 10", "city 11", "city 12" }; // liste des nombres de garnisons à répartir List <int> nbrList = new List <int> { 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 150 }; List <int> posList = new List <int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; List <int> spotList = new List <int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; for (int i = 0; i < nameList.Count; i++) { // rand garnisons int randGarn = UnityEngine.Random.Range(0, nbrList.Count); int garnNum = nbrList[randGarn]; nbrList.RemoveAt(randGarn); Soldat garnison = new Soldat(1, 1, 2, 1, garnNum, "Garnisons"); // rand fortification int Fortif = 0; int randFortif = UnityEngine.Random.Range(0, 3); switch (randFortif) { case 0: Fortif = 0; break; case 1: Fortif = 1; break; case 2: Fortif = 2; break; } // rand productivity int randProd = UnityEngine.Random.Range(0, 3); float Prod = 0.0f; switch (randProd) { case 0: Prod = 0.98f; break; case 1: Prod = 1.00f; break; case 2: Prod = 1.02f; break; } // rand capture int randCapt = UnityEngine.Random.Range(0, 4); int Capt = randCapt + 1; // rand perception int randPerc = UnityEngine.Random.Range(0, 4); int Perc = randPerc; // rand gold int randGold = UnityEngine.Random.Range(40, 76); int Gold = randGold * 1000; // rand pos int randPos = UnityEngine.Random.Range(0, posList.Count); int Pos = posList[randPos]; posList.RemoveAt(randPos); int rand = UnityEngine.Random.Range(0, spotList.Count); int childNum = spotList[rand]; spotList.RemoveAt(rand); Villes city = Villages.transform.GetChild(childNum).gameObject.AddComponent <Villes>() as Villes; city.set(nameList[i], Fortif, Gold, garnison, Capt, Perc, Prod, no_one, no_one, Pos); // ajout de la ville créée à la liste TownList.Add(city); UImanager.InstantiateCity(city); } int trebuchet_city = UnityEngine.Random.Range(0, 11); TownList[trebuchet_city].trebuchet = trebuchet; TownList[trebuchet_city].is_trebuchet = true; int knight_start_city = UnityEngine.Random.Range(0, 11); TownList[knight_start_city].knights = knights; TownList[knight_start_city].is_knights = true; // METTRE UN TIME ICI // Generateur de logs pour test /* * string lines = ""; * * for (int k = 0; k < TownList.Count; k++) * { * Villes city = TownList[k]; * lines = lines + city.nameVilles + ": fortif = " + city.fortification.ToString() + ", gold = " + city.gold.ToString() + ", garnisons = " + city.garnison.number.ToString() + ", capture = " + city.capture.ToString() + ", perception = " + city.perception.ToString() + ", productivity = " + city.productivity.ToString() + ", pos = " + city.pos.ToString() + ", knights" + city.is_knights.ToString() + ", trebuchet" + city.is_trebuchet.ToString() +"\r\n"; + } + + + + // Write the string to a file. + /*System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\Users\\jean claude\\Desktop\\JIN\\test.txt"); + file.WriteLine(lines); + + file.Close();*/ }
public void recrutEspion(Drakkar drakkar, Espion espion, int costEspion) { drakkar.gold -= costEspion; drakkar.espion_list.Add(espion); }