public List <MutationData> GetRandomMutation(int nbMutationRequested) { List <MutationData> list = new List <MutationData>(0); if (nbMutationRequested > 3) { nbMutationRequested = 3; } for (int i = 0; i < nbMutationRequested; i++) { int randIndex = Random.Range(0, allMutations.Count); CaractMonster caract = CaractMonster.GetRandomCaracExept(allMutations[randIndex].impossibleMutation, allMutations[randIndex].mutation); MutationData data = new MutationData(allMutations[randIndex].nIdMonster, caract, allMutations[randIndex].impossibleMutation); while (list.Contains(data)) { caract = CaractMonster.GetRandomCaracExept(allMutations[randIndex].impossibleMutation, allMutations[randIndex].mutation); data = new MutationData(allMutations[randIndex].nIdMonster, caract, allMutations[randIndex].impossibleMutation); } list.Add(data); } return(list); }
private void Start() { MutationManager mutationManager = GameObject.FindGameObjectWithTag("MutationManager").GetComponent <MutationManager>(); CreaturesData creatureData = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent <CreaturesData>(); if (mutationManager.allMutations.Count > 0) { MutationManager.MutationData data = mutationManager.GetRandomMutation(1)[0]; idMonster = data.nIdMonster; mutation = CaractMonster.GetCaractMonsterOfEnum(data.mutation); monsterIcon.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/MonsterIcons/" + creatureData.GetFighterOfID <Monster>(CreatureType.Monster, idMonster).sName); mutationIcon.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/HumandexIcons/" + mutation.sName); char[] correctCapitalisation = mutation.sName.ToLowerInvariant().ToCharArray(); correctCapitalisation[0] = correctCapitalisation[0].ToString().ToUpperInvariant()[0]; mutationName.text = ""; for (int i = 0; i < correctCapitalisation.Length; ++i) { mutationName.text += correctCapitalisation[i]; } } else { Destroy(gameObject); } }
public CaractMonster GetMutationWithId(int id) { foreach (MutationData mutationData in allMutations) { if (mutationData.nIdMonster == id) { return(CaractMonster.GetCaractMonsterOfEnum(mutationData.mutation)); } } return(CaractMonster.NONE); }
public List <Tip> GetTipsAboutMonsterCarac(CaractMonster caracMonster, List <Tip> aList) { List <Tip> finalList = new List <Tip>(); foreach (Tip tip in aList) { if (tip.caracMonster == caracMonster) { finalList.Add(tip); } } return(finalList); }
public void Start() { if (permanentMutation != CaractMonster._enumCaractMonster.NONE) { permanentCarMutation = CaractMonster.GetCaractMonsterOfEnum(permanentMutation); } int id = gameObject.transform.parent.GetComponent <FighterUI>().fighter.nID; MutationManager mmm = GameObject.FindGameObjectWithTag("MutationManager").GetComponent <MutationManager>(); SetCaract(mmm.GetMutationWithId(id)); }
public List <CaractMonster> GetMutationsWithId(int id) { List <CaractMonster> mutations = new List <CaractMonster>(); foreach (MutationData mutationData in allMutations) { if (mutationData.nIdMonster == id) { mutations.Add(CaractMonster.GetCaractMonsterOfEnum(mutationData.mutation)); } } return(mutations); }
public void AddMutationID(int id, CaractMonster mutation) { foreach (MutationData mutationData in allMutations) { if (mutationData.nIdMonster == id) { if (mutationData.mutation == CaractMonster._enumCaractMonster.NONE) { mutationData.mutation = mutation.enumCaract; } else { allMutations.Add(new MutationData(id, mutation, CaractMonster._enumCaractMonster.NONE)); return; } } } }
public static CaractMonster GetRandomCaracExept(_enumCaractMonster enumMut, _enumCaractMonster enumMut2) { CaractMonster car = GetRandomCarac(); while (car.enumCaract == enumMut || car.enumCaract == enumMut2) { car = GetRandomCarac(); } /* * int randIndex = Random.Range(1, allCaractMonster.Count ); * * while(allCaractMonster[randIndex].enumCaract == enumMut || allCaractMonster[randIndex].enumCaract == enumMut2) * { * randIndex = Random.Range(1, allCaractMonster.Count ); * }*/ // return allCaractMonster[randIndex]; return(car); }
public void Awake() { if (instance == null) { instance = this; } if (!created) { DontDestroyOnLoad(transform.gameObject); created = true; } else { Destroy(transform.gameObject); } CaractMonster init = CaractMonster.AILES; Initialise(); }
public void SetCaract(CaractMonster caract) { caractMonster = caract; foreach (Transform child in Mutations.transform) { MonsterMutationUI mutationUI = child.gameObject.GetComponent <MonsterMutationUI>(); if (mutationUI != null) { if (mutationUI._enumMutations == caract.enumCaract) { child.gameObject.SetActive(true); } else { child.gameObject.SetActive(false); } } } }
void Initialise() { CaractHumainStuff test = CaractHumainStuff.ARC; CaractHumainCheveux test2 = CaractHumainCheveux.BLANC; List <CaractMonster> allCaracMonster = new List <CaractMonster>(); List <CaractHumain> allCaracHumain = new List <CaractHumain>(); CaractMonster[] allCaracMonsterA = new CaractMonster[CaractMonster.GetAllCarac().Count]; CaractHumain[] allCaracHumainA = new CaractHumain[CaractHumain.GetAllCarac().Count]; CaractMonster.GetAllCarac().CopyTo(allCaracMonsterA); CaractHumain.GetAllCarac().CopyTo(allCaracHumainA); allCaracMonster = allCaracMonsterA.ToList(); allCaracHumain = allCaracHumainA.ToList(); //System.Array.Copy( , allCaracMonster, CaractMonster.GetAllCarac().Count); Tip tip; for (int i = 0; i < allCaracMonster.Count && allCaracHumain.Count > 0;) { tip = new Tip(); int randIndexMonster = Random.Range(0, allCaracMonster.Count); int randIndexHumain = Random.Range(0, allCaracHumain.Count); tip.caracMonster = allCaracMonster[randIndexMonster]; tip.caracHumain = allCaracHumain[randIndexHumain]; allCaracMonster.RemoveAt(randIndexMonster); allCaracHumain.RemoveAt(randIndexHumain); listTips.Add(tip); ModRoll roll = ModRoll.GetRandomMod(); tip.modroll = roll; } CaractMonster.GetAllCarac().CopyTo(allCaracMonsterA); allCaracMonster = allCaracMonsterA.ToList(); for (int i = 0; i < allCaracMonster.Count && allCaracHumain.Count > 0;) { tip = new Tip(); int randIndexMonster = Random.Range(0, allCaracMonster.Count); int randIndexHumain = Random.Range(0, allCaracHumain.Count); tip.caracMonster = allCaracMonster[randIndexMonster]; tip.caracHumain = allCaracHumain[randIndexHumain]; allCaracMonster.RemoveAt(randIndexMonster); allCaracHumain.RemoveAt(randIndexHumain); ModRoll roll = ModRoll.GetRandomMod(); tip.modroll = roll; listTips.Add(tip); } foreach (Tip t in listTips) { Tip newTip = new Tip(); newTip.CopyTips(t); tipsNotKnownByPlayer.Add(newTip); } }
public List <Tip> GetAllTipConcerningGroups(GroupMonsterFighter groupMonster, GroupHumanFighter groupHuman, bool inInitialGroup) { List <Tip> finalList = new List <Tip>(); List <Fighter> allHuman = groupHuman.lFighters; List <Fighter> allMonster = groupMonster.lFighters; if (inInitialGroup) { allHuman = groupHuman.lInitialFighters; allMonster = groupMonster.lInitialFighters; } foreach (Tip tip in tipsNotKnownByPlayer) { bool bConcernM = false; bool bConcernH = false; foreach (Fighter fighter in allHuman) { ModelHumainUI modelH = ((Human)fighter).currentUI.gameObject.GetComponentInChildren <ModelHumainUI>(); CaractHumainCheveux cheveux = modelH.caractCheveux; CaractHumainStuff stuff = modelH.caractStuff; if (tip.caracHumain == cheveux) { bConcernH = true; } else if (tip.caracHumain == stuff) { bConcernH = true; } } foreach (Fighter fighter in allMonster) { ModelMonsterUI modelM = ((Monster)fighter).currentUI.gameObject.GetComponentInChildren <ModelMonsterUI>(); if (modelM != null) { CaractMonster firstMutation = modelM.caractMonster; CaractMonster permaMutation = modelM.permanentCarMutation; if (tip.caracMonster == firstMutation) { bConcernM = true; } else if (tip.caracMonster == permaMutation) { bConcernM = true; } } } if (bConcernH && bConcernM) { finalList.Add(tip); } } return(finalList); }
public float GetBonus(ActionType actionType, Human human, GroupMonsterFighter groupMonster) { float bonus = 0; List <Tip> myTips = GetTipsOfAction(actionType, human.eCreatureType); CaractHumainCheveux chm = human.currentUI.gameObject.GetComponentInChildren <ModelHumainUI>().caractCheveux; myTips = GetTipsAboutHumainCarac(chm, myTips); foreach (Fighter fighter in groupMonster.lFighters) { if (fighter.CanAttack()) { ModelMonsterUI modelM = ((Monster)fighter).currentUI.gameObject.GetComponentInChildren <ModelMonsterUI>(); if (modelM != null) { CaractMonster tempCarac = modelM.caractMonster; CaractMonster permaCarac = modelM.permanentCarMutation; foreach (Tip tip in myTips) { if (tip.caracMonster == tempCarac) { bonus += tip.modroll.GetValueOfAction(actionType, human.eCreatureType); } else if (tip.caracMonster == permaCarac) { bonus += tip.modroll.GetValueOfAction(actionType, human.eCreatureType); } if (bonus != 0) { break; } } } } if (bonus != 0) { break; } } myTips = GetTipsOfAction(actionType, human.eCreatureType); CaractHumainStuff chs = human.currentUI.gameObject.GetComponentInChildren <ModelHumainUI>().caractStuff; myTips = GetTipsAboutHumainCarac(chs, myTips); foreach (Fighter fighter in groupMonster.lFighters) { if (fighter.CanAttack()) { ModelMonsterUI modelM = ((Monster)fighter).currentUI.gameObject.GetComponentInChildren <ModelMonsterUI>(); if (modelM != null) { CaractMonster tempCarac = modelM.caractMonster; CaractMonster permaCarac = modelM.permanentCarMutation; foreach (Tip tip in myTips) { if (tip.caracMonster == tempCarac) { bonus += tip.modroll.GetValueOfAction(actionType, human.eCreatureType); } else if (tip.caracMonster == permaCarac) { bonus += tip.modroll.GetValueOfAction(actionType, human.eCreatureType); } if (bonus != 0) { break; } } } } if (bonus != 0) { break; } } // CaractMonster mutation; return(bonus); }
public float GetBonus(ActionType actionType, Monster monster, GroupHumanFighter groupHuman) { float bonus = 0; List <Tip> myTips = GetTipsOfAction(actionType, monster.eCreatureType); CaractMonster cm = monster.currentUI.gameObject.GetComponentInChildren <ModelMonsterUI>().caractMonster; myTips = GetTipsAboutMonsterCarac(cm, myTips); foreach (Fighter fighter in groupHuman.lFighters) { if (fighter.CanAttack()) { ModelHumainUI modelH = ((Human)fighter).currentUI.gameObject.GetComponentInChildren <ModelHumainUI>(); CaractHumainCheveux cheveux = modelH.caractCheveux; CaractHumainStuff stuff = modelH.caractStuff; foreach (Tip tip in myTips) { if (tip.caracHumain == cheveux) { bonus += tip.modroll.GetValueOfAction(actionType, monster.eCreatureType); } else if (tip.caracHumain == stuff) { bonus += tip.modroll.GetValueOfAction(actionType, monster.eCreatureType); } if (bonus != 0) { break; } } } if (bonus != 0) { break; } } myTips = GetTipsOfAction(actionType, monster.eCreatureType); cm = monster.currentUI.gameObject.GetComponentInChildren <ModelMonsterUI>().permanentCarMutation; myTips = GetTipsAboutMonsterCarac(cm, myTips); foreach (Fighter fighter in groupHuman.lFighters) { if (fighter.CanAttack()) { ModelHumainUI modelH = ((Human)fighter).currentUI.gameObject.GetComponentInChildren <ModelHumainUI>(); CaractHumainCheveux cheveux = modelH.caractCheveux; CaractHumainStuff stuff = modelH.caractStuff; foreach (Tip tip in myTips) { if (tip.caracHumain == cheveux) { bonus += tip.modroll.GetValueOfAction(actionType, monster.eCreatureType); } else if (tip.caracHumain == stuff) { bonus += tip.modroll.GetValueOfAction(actionType, monster.eCreatureType); } if (bonus != 0) { break; } } } if (bonus != 0) { break; } } // CaractMonster mutation; return(bonus); }
public MutationData(int id, CaractMonster mutationC, CaractMonster._enumCaractMonster impossibleMutationC) { nIdMonster = id; mutation = mutationC.enumCaract; impossibleMutation = impossibleMutationC; }
public void CopyTips(Tip tipToCopy) { caracHumain = tipToCopy.caracHumain; caracMonster = tipToCopy.caracMonster; modroll = tipToCopy.modroll; }