Esempio n. 1
0
    void convertToMonster()
    {
        lastAttackValue = attack;
//		Debug.Log ("convirtiendome");
        attack = 20;
        GetComponent <AgentPositionController>().maxLinearVelocity = 150;
        GetComponent <SpriteRenderer>().sprite = playerMonsterStateImage;
        isMonster = true;

        GroupScript myGroup = this.GetComponent <GroupScript>();

        if (myGroup.groupMembers.Count > 1)
        {
            Debug.LogError("hay mas de uno");
        }
        else if (myGroup.groupMembers.Count > 0)
        {
            if (myGroup.IAmTheLeader)
            {
                myGroup.groupMembers [0].GetComponent <GroupScript> ().ExitGroup();
            }
            else
            {
                myGroup.ExitGroup();
            }
        }
    }
Esempio n. 2
0
    public override void DoAction()
    {
        base.visibiCone.IDecided = false;
        Reaction.spawnReaction(ResponseController.responseEnum.GROUP, ResponseController.responseEnum.OK, this.gameObject);
        // Debug.Log("me uno a tu grupo");

        //Debug.Log("mytarget es " + this.GetComponent<DecisionTreeCreator>().target);

        GameObject  t           = this.GetComponent <DecisionTreeCreator>().target;
        GroupScript myGroup     = this.GetComponent <GroupScript>();
        GroupScript leadergroup = t.GetComponent <GroupScript>();

        t = leadergroup.groupLeader;



        if (t.tag == "Player" && myGroup.IAmTheLeader == false && myGroup.groupLeader != this.gameObject)
        {
            myGroup.ExitGroup();
            myGroup.groupLeader  = t;
            myGroup.inGroup      = true;
            myGroup.IAmTheLeader = false;
            leadergroup.updateGroups(this.gameObject, myGroup.groupMembers);
            leadergroup.makeLeader();
            myGroup.groupMembers = new List <GameObject>();
            myGroup.groupMembers.AddRange(leadergroup.groupMembers);
            myGroup.groupMembers.Remove(this.gameObject);
            myGroup.addSingleMember(t);
            this.gameObject.GetComponent <SpriteRenderer>().color = leadergroup.getColor();
        }
        else
        {
            myGroup.groupLeader  = t;
            myGroup.inGroup      = true;
            myGroup.IAmTheLeader = false;
            leadergroup.updateGroups(this.gameObject, myGroup.groupMembers);
            leadergroup.makeLeader();
            myGroup.addSingleMember(t);

            leadergroup.resetMembersOfGroups(t.GetComponent <SpriteRenderer>());
        }

        if (this.gameObject.tag != "Player")
        {
            string[]     behaviours     = { "Pursue", "Leave", "AvoidWall", "Face" };
            float[]      weightedBehavs = { 0.8f, 0.1f, 1, 1 };
            GameObject   target         = this.GetComponent <DecisionTreeCreator>().target.GetComponent <GroupScript>().groupLeader;
            GameObject[] targets        = { target, target, target, target };
            GameObject.FindGameObjectWithTag("GameController").GetComponent <BehaviourAdder>().addBehavioursOver(this.gameObject, targets, behaviours, weightedBehavs);
            base.DestroyTrees();
        }
        t.GetComponent <PersonalityBase>().formacionGrupo(t, leadergroup);


        DecisionTreeNode[] oldNodes = this.gameObject.GetComponents <DecisionTreeNode>();
        foreach (DecisionTreeNode n in oldNodes)
        {
            DestroyImmediate(n);
        }
    }
Esempio n. 3
0
    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
        }
    }