public virtual void PerformActionOnTarget(ActionType action, GroupFighter groupHuman) { performingAction = true; performingAction = true; justdidAction = true; lastAction = action; Debug.Log("Fighter :" + this.sName + " Perform action :" + action.sName + "on all enemy Group "); // ActionTalk(); }
public override void PerformActionOnTarget(ActionType action, GroupFighter groupHuman) { base.PerformActionOnTarget(action, groupHuman); if (action == ActionType.TALK) { lastActionResult = RollResultEnum.Normal; //((GroupHumanFighter)groupHuman).GetConvinced(this); CombatManager combatManager = GameObject.FindGameObjectWithTag("CombatManager").GetComponent <CombatManager>(); float rand = 0.5f; if (rand > 0.95) { } else if (rand > 0.3) { } else { Debug.Log("Fail Convice:" + rand.ToString()); } GameObject g = GameObject.FindGameObjectWithTag("CombatManager"); CombatManager cm = g.GetComponent <CombatManager>(); ((GroupHumanFighter)cm.GetGroupFighterOfFighter(this)).bInConversation = true;; if (combatManager.humanGroupFighter.bIsSpecial && combatManager.specialType == SpecialType.Bard) { ((IABard)combatManager.humanGroupFighter.groupLogic).Talk(); } else if (combatManager.humanGroupFighter.bIsSpecial && combatManager.specialType == SpecialType.Ed) { ((IAEd)combatManager.humanGroupFighter.groupLogic).Talk(); } else { ActionTalk(action, rand); } } }
public override void PerformActionOnSelf(ActionType action, GroupFighter monsterFighter) { if (action == ActionType.ESCAPE) { float rand = Random.Range(0f, 1f); CombatManager combatManager = GameObject.FindGameObjectWithTag("CombatManager").GetComponent <CombatManager>(); if (combatManager.protoScript != null && combatManager.protoScript.combat != null && combatManager.protoScript.combat.currentTurn != null) { rand = combatManager.protoScript.combat.currentTurn.fRoll; } if (rand > combatManager.rollProbaManager.Escape.fail) { bTryToescape = true; AkSoundEngine.PostEvent("Play_flee", GameObject.FindGameObjectWithTag("MainCamera")); ((GroupMonsterFighter)monsterFighter).MonsterEscaping(); } else { } } }
public virtual void PerformActionOnSelf(ActionType action, GroupFighter groupFighter) { }
void InstantiateHuman() { GameObject prefab = prefabHuman; Fighter fighter; CreatureType creatureType = CreatureType.Human; GameObject humansPositionParent = GameObject.FindGameObjectWithTag("HumansPosition"); List <Transform> humansPosition = new List <Transform>(); foreach (Transform child in humansPositionParent.transform) { humansPosition.Add(child); } if (!bSpecialFight) { humanGroupFighter = new GroupHumanFighter(); if (protoScript == null && !isBossCombat) { currentNbHuman = Random.Range(2, nbCreaturePerGroup + 1); //currentNbHuman = 2; } for (int i = 0; i < currentNbHuman; i++) { int idModel = creaturePrefabManager.GetRandomHumanID(); GameObject model = creaturePrefabManager.GetHuman(idModel); Human humain = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent <CreaturesData>().GetFighterOfID <Human>(creatureType, idModel); humain.sexe = enumSex.None; enumSex sexCurrent = creaturePrefabManager.GetSexPrefabId(model, idModel); humain.sexe = sexCurrent; ModelHumainUI modelUI = model.GetComponent <ModelHumainUI>(); if (modelUI != null) { modelUI.RandomCheveux(); } if (humain == null) { humain = new Human(); humain.CopyHuman(defaultHuman); humain.nID = idModel; //humain.sName = model.name; } GameObject g = Instantiate(prefab, humansPosition[i].position, Quaternion.Euler(0, 90, 0)) as GameObject; GameObject mo = Instantiate(model, humansPosition[i].position, Quaternion.Euler(0, 90, 0)) as GameObject; mo.transform.parent = g.transform; mo.transform.localPosition = Vector3.zero; mo.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>(); MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>(); mouseOver.fighterUI = g.GetComponent <FighterUI>(); g.GetComponent <FighterUI>().fighter = humain; humanGroupFighter.lFighters.Add(humain); g.transform.parent = GameObject.FindGameObjectWithTag("Humans").transform; g.name = humain.sName; g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>(); } } else { if (specialType == SpecialType.Ed) { humanGroupFighter = new GroupEd(); int idModel = 30; GameObject model = creaturePrefabManager.GetSpecial(idModel); //Human humain = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent<CreaturesData>().GetFighterOfID<Human>(creatureType, idModel); Human humain = new Human(); humain.CopyHuman(defaultHuman); humain.nID = idModel; humain.sName = "Ed"; humain.nPower = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent <CreaturesData>().defaultHuman.nPower; GameObject g = Instantiate(prefab, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject; GameObject mo = Instantiate(model, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject; mo.transform.parent = g.transform; mo.transform.localPosition = Vector3.zero; mo.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>(); MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>(); mouseOver.fighterUI = g.GetComponent <FighterUI>(); g.GetComponent <FighterUI>().fighter = humain; humanGroupFighter.lFighters.Add(humain); g.transform.parent = GameObject.FindGameObjectWithTag("Humans").transform; g.name = humain.sName; g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>(); } if (specialType == SpecialType.Bard) { humanGroupFighter = new GroupBard(); int idModel = 31; GameObject model = creaturePrefabManager.GetSpecial(idModel); //Human humain = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent<CreaturesData>().GetFighterOfID<Human>(creatureType, idModel); Human humain = new Human(); humain.CopyHuman(defaultHuman); humain.nID = idModel; humain.sName = "Bard"; GameObject g = Instantiate(prefab, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject; GameObject mo = Instantiate(model, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject; mo.transform.parent = g.transform; mo.transform.localPosition = Vector3.zero; mo.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>(); MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>(); mouseOver.fighterUI = g.GetComponent <FighterUI>(); g.GetComponent <FighterUI>().fighter = humain; humanGroupFighter.lFighters.Add(humain); g.transform.parent = GameObject.FindGameObjectWithTag("Humans").transform; g.name = humain.sName; g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>(); } if (specialType == SpecialType.Slip) { humanGroupFighter = new GroupSlip(); int idModel = 32; GameObject model = creaturePrefabManager.GetSpecial(idModel); //Human humain = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent<CreaturesData>().GetFighterOfID<Human>(creatureType, idModel); Human humain = new Human(); humain.CopyHuman(defaultHuman); humain.nPower = 0; humain.nID = idModel; humain.sName = "MecEnSlip"; GameObject g = Instantiate(prefab, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject; GameObject mo = Instantiate(model, humansPosition[0].position, Quaternion.Euler(0, 90, 0)) as GameObject; mo.transform.parent = g.transform; mo.transform.localPosition = Vector3.zero; mo.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>(); MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>(); mouseOver.fighterUI = g.GetComponent <FighterUI>(); g.GetComponent <FighterUI>().fighter = humain; humanGroupFighter.lFighters.Add(humain); g.transform.parent = GameObject.FindGameObjectWithTag("Humans").transform; g.name = humain.sName; g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>(); } } }
void InstantiateMonster() { monsterGroupFighter = new GroupMonsterFighter(); GameObject prefab = prefabMonster; Fighter fighter; CreatureType creatureType = CreatureType.Monster; GameObject monstersPositionParent = GameObject.FindGameObjectWithTag("MonstersPosition"); List <Transform> monstersPosition = new List <Transform>(); foreach (Transform child in monstersPositionParent.transform) { monstersPosition.Add(child); } for (int i = 0; i < nbCreaturePerGroup && i < caravane.lFighters.Count; i++) { fighter = caravane.lFighters[i]; fighter.bTryToescape = false; GameObject g = Instantiate(prefab, monstersPosition[i].position, Quaternion.Euler(0, 90, 0)) as GameObject; GameObject mo; GameObject model = creaturePrefabManager.GetMonster(fighter.nID); mo = Instantiate(model, monstersPosition[i].position, Quaternion.Euler(0, 270, 0)) as GameObject; mo.transform.parent = g.transform; mo.transform.localPosition = Vector3.zero; mo.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>(); g.GetComponent <FighterUI>().fighter = fighter; monsterGroupFighter.lFighters.Add(fighter); g.transform.parent = GameObject.FindGameObjectWithTag("Monsters").transform; g.name = fighter.sName; MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>(); mouseOver.fighterUI = g.GetComponent <FighterUI>(); g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>(); } if (isBossCombat) { monstersPosition = new List <Transform>(); foreach (Transform child in monstersPositionParent.transform) { monstersPosition.Add(child); } humanGroupFighter = new GroupEd(); int idModel = 40; GameObject model = creaturePrefabManager.GetSpecial(idModel); //Human humain = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent<CreaturesData>().GetFighterOfID<Human>(creatureType, idModel); Monster monster = new Monster(); monster.nID = idModel; monster.sName = "PiratePlant"; monster.isBoss = true; monster.nPower = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent <CreaturesData>().defaultMonster.nPower; monster.nHealthMax = GameObject.FindGameObjectWithTag("CreaturesData").GetComponent <CreaturesData>().defaultMonster.nHealthMax; monster.nCurrentHealth = monster.nHealthMax; GameObject g = Instantiate(prefab, monstersPosition[4].position, Quaternion.Euler(0, 90, 0)) as GameObject; GameObject mo = Instantiate(model, monstersPosition[4].position, Quaternion.Euler(0, 90, 0)) as GameObject; mo.transform.parent = g.transform; mo.transform.localPosition = Vector3.zero; mo.transform.localScale = new Vector3(-0.3f, 0.3f, 0.3f); mo.transform.GetChild(0).gameObject.AddComponent <BoxCollider>(); MouseOverCreature mouseOver = mo.transform.GetChild(0).gameObject.AddComponent <MouseOverCreature>(); mouseOver.fighterUI = g.GetComponent <FighterUI>(); g.GetComponent <FighterUI>().fighter = monster; monsterGroupFighter.lFighters.Add(monster); g.transform.parent = GameObject.FindGameObjectWithTag("Monsters").transform; g.name = monster.sName; g.GetComponent <FighterUI>().fighterRenderer = mouseOver.gameObject.GetComponent <Renderer>(); } }
public override void PerformActionOnTarget(ActionType action, GroupFighter groupHuman) { base.PerformActionOnTarget(action, groupHuman); if (action == ActionType.FEAR) { // ((GroupHumanFighter)groupHuman).GetFeared(this); CombatManager combatManager = GameObject.FindGameObjectWithTag("CombatManager").GetComponent <CombatManager>(); //float rand = 0.1f; float rand = Random.Range(0f, 1f); if (!groupHuman.bIsSpecial && !isBoss) { float bonus = GameObject.FindGameObjectWithTag("TipManager").GetComponent <TipsManager>().GetBonus(action, this, (GroupHumanFighter)groupHuman); rand += bonus; } float terrain = GameObject.FindGameObjectWithTag("CombatTerrain").GetComponent <CombatTerrainInfo>().modRoll.GetValueOfAction(action, CreatureType.Monster); rand += terrain; if (combatManager.protoScript != null && combatManager.protoScript.combat != null && combatManager.protoScript.combat.currentTurn != null) { rand = combatManager.protoScript.combat.currentTurn.fRoll; } if (!((GroupHumanFighter)groupHuman).bCanBeFeared) { rand = 0; } if (rand > combatManager.rollProbaManager.Fear.normal) { lastActionResult = RollResultEnum.Crit; ((GroupHumanFighter)groupHuman).GetFeared(RollResultEnum.Crit, this); } else if (rand > combatManager.rollProbaManager.Fear.fail) { lastActionResult = RollResultEnum.Normal; ((GroupHumanFighter)groupHuman).GetFeared(RollResultEnum.Normal, this); } else { lastActionResult = RollResultEnum.Fail; ((GroupHumanFighter)groupHuman).GetFeared(RollResultEnum.Fail, this); // ((GroupHumanFighter)groupHuman).bCanBeFeared = false; Debug.Log("Fail Fear:" + rand.ToString()); AkSoundEngine.PostEvent("Play_miss", GameObject.FindGameObjectWithTag("MainCamera")); if (combatManager.protoScript != null && combatManager.protoScript.combat != null && combatManager.protoScript.combat.currentTurn != null) { combatManager.protoScript.combat.MonsterFailFear(); } } ActionTalk(action, rand); } if (action == ActionType.TALK) { //((GroupHumanFighter)groupHuman).GetConvinced(this); CombatManager combatManager = GameObject.FindGameObjectWithTag("CombatManager").GetComponent <CombatManager>(); // float rand = 0.1f; float rand = Random.Range(0f, 1f); // CEST PAS OPTI DE LE CALCULER A CHAQUE FOIS if (!groupHuman.bIsSpecial && !isBoss) { float bonus = GameObject.FindGameObjectWithTag("TipManager").GetComponent <TipsManager>().GetBonus(action, this, (GroupHumanFighter)groupHuman); rand += bonus; } float terrain = GameObject.FindGameObjectWithTag("CombatTerrain").GetComponent <CombatTerrainInfo>().modRoll.GetValueOfAction(action, CreatureType.Monster); rand += terrain; if (combatManager.protoScript != null && combatManager.protoScript.combat != null && combatManager.protoScript.combat.currentTurn != null) { rand = combatManager.protoScript.combat.currentTurn.fRoll; } if (!((GroupHumanFighter)groupHuman).bCanListen) { rand = 0; } if (rand > combatManager.rollProbaManager.Discussion.normal) { lastActionResult = RollResultEnum.Crit; ((GroupHumanFighter)groupHuman).GetConvinced(RollResultEnum.Crit, this); } else if (rand > combatManager.rollProbaManager.Discussion.fail) { lastActionResult = RollResultEnum.Normal; ((GroupHumanFighter)groupHuman).GetConvinced(RollResultEnum.Normal, this); } else { lastActionResult = RollResultEnum.Fail; ((GroupHumanFighter)groupHuman).GetConvinced(RollResultEnum.Fail, this); Debug.Log("Fail Convice:" + rand.ToString()); AkSoundEngine.PostEvent("Play_miss", GameObject.FindGameObjectWithTag("MainCamera")); //((GroupHumanFighter)groupHuman).bCanListen = false; } ActionTalk(action, rand); } }