void Attack(int a) { var arbol = this.GetComponent <DecisionTreeCreator>(); if (arbol != null) { try { if (!triggered) { targetAttack = arbol.target; } } catch { Debug.LogError("Ha ocurrido error en " + this.name); } PersonalityBase targetPers = targetAttack.GetComponent <PersonalityBase>(); GroupScript targetGroup = targetPers.gameObject.GetComponent <GroupScript>(); if (targetGroup.groupLeader == this.gameObject.GetComponent <GroupScript>().groupLeader) { if (targetGroup.groupMembers.Count > 0) { if (targetGroup.IAmTheLeader) { var members = targetGroup.groupMembers; targetGroup.ExitGroup(); foreach (var m in members) { GroupScript memberGroup = m.GetComponent <GroupScript>(); memberGroup.groupLeader = members[0]; } } else { targetGroup.ExitGroup(); } } } updateTrust(false, targetPers, this.GetComponent <PersonalityBase>().GetMyOwnIndex()); targetPers.takeDamage(a, this.GetComponent <PersonalityBase>()); //HAY QUE RECORRER EL GRUPO DEL TARGET Y REDUCIR LA CONFIANZA DE TODOS } }
public void waitForAttack() { GameObject player = GameObject.FindGameObjectWithTag("Player"); GroupScript myGroup = player.GetComponent <GroupScript>(); int totalAttack = player.GetComponent <PlayerPersonality>().attack; foreach (var member in myGroup.groupMembers) { totalAttack += member.GetComponent <AIPersonality>().attack; //animacion numeritos } targetIA = menuController.GetTargetIA(); PersonalityBase targetPers = targetIA.GetComponent <AIPersonality>(); targetPers.interactionFromOtherCharacter = ActionsEnum.Actions.ATTACK; targetIA.GetComponent <GroupScript>().ExitGroup(); targetIA.GetComponent <VisibilityConeCycleIA>().enabled = true; targetPers.takeDamage(totalAttack, player.GetComponent <PersonalityBase> ()); updateTrust(false, targetPers, player.GetComponent <PersonalityBase>().GetMyOwnIndex()); reactionTree = targetIA.GetComponent <DecisionTreeReactionAfterInteraction>(); if (reactionTree != null) { DestroyImmediate(reactionTree); } targetIA.gameObject.GetComponent <AIPersonality>().oldNodes = targetIA.gameObject.GetComponents <DecisionTreeNode>(); foreach (DecisionTreeNode n in targetIA.gameObject.GetComponent <AIPersonality>().oldNodes) { DestroyImmediate(n); } reactionTree = targetIA.AddComponent <DecisionTreeReactionAfterInteraction>(); reactionTree.target = GameObject.FindGameObjectWithTag("Player"); GroupScript leaderGroup = player.GetComponent <GroupScript>().groupLeader.GetComponent <GroupScript>(); player.GetComponent <PersonalityBase>().formacionGrupo(leaderGroup.groupLeader, leaderGroup); }