Esempio n. 1
0
    void Update()
    {
        if (agentComponent.IsWounded() || oAgentComponent.IsWounded())
        {
            UpdateAppraisalStatus();
            endTime = Time.time;
            FinishFight();
        }
        else
        {
            if (oAgentComponent.role == (int)RoleName.Police)
            {
                agentComponent.AddDamage(0.1f);             //extra damage if opponent is a police
            }
            else
            {
                agentComponent.AddDamage(0.05f);
            }

            agentComponent.SteerTo(opponent.transform.position);
            transform.rotation = Quaternion.LookRotation(opponent.transform.position - transform.position, Vector3.up);

            //Send message to others to watch this fight
            foreach (GameObject c in agentComponent.collidingAgents)
            {
                if (c.GetComponent <AgentComponent>().role == (int)RoleName.Protester && c.GetComponent <AgentComponent>().IsVisible(this.gameObject, Mathf.PI / 2f) &&
                    c.GetComponent <AgentComponent>().IsFighting() == false && c.GetComponent <ProtesterBehavior>().isWatchingFight == false)
                {
                    if (c.GetComponent <AffectComponent>().personality[(int)OCEAN.E] > 0)   //intervene if assertive
                    {
                        c.GetComponent <AgentComponent>().SteerTo((transform.position + opponent.transform.position) / 2f);
                        watchers.Add(c);
                        c.GetComponent <ProtesterBehavior>().isWatchingFight = true;
                    }
                    else if (c.GetComponent <AffectComponent>().personality[(int)OCEAN.O] > 0) //watch if curious
                    {
                        c.GetComponent <SteeringController>().Stop(true);
                        c.GetComponent <AgentComponent>().Watch((transform.position + opponent.transform.position) / 2f);
                        watchers.Add(c);
                        c.GetComponent <ProtesterBehavior>().isWatchingFight = true;
                    }
                }
            }
        }
    }
Esempio n. 2
0
    void Update()
    {
        const float fearThreshold = 0.1f;

        if (agentComponent.IsDead())
        {
            Destroy(GetComponent <ExplosionBehavior>());
        }

        if (explosion)
        {
            dist = (transform.position - explosion.transform.position).magnitude;
            if (dist < 5f) //add even more damage
            {
                agentComponent.AddDamage(0.15f);
            }
            else if (dist < 10f) //add more damage
            {
                agentComponent.AddDamage(0.1f);
            }
            else if (dist < 15f)
            {
                agentComponent.AddDamage(0.05f);
            }

            //Wait until fear is above some threshold before reacting
            if (GetComponent <AffectComponent>().emotion[(int)EType.Fear] > fearThreshold)
            {
                agentComponent.DeactivateOtherBehaviors();
                agentComponent.CurrAction = "";
                if (GetComponent <AffectComponent>().IsMood((int)MoodType.Anxious) || GetComponent <AffectComponent>().personality[(int)OCEAN.N] > 0)
                {
                    agentComponent.IncreasePanic();
                }
                agentComponent.SteerFrom(explosion.transform.position);
                //  agentComponent.SteerTo(escapePos);
            }
        }
        //Explosion is over
        else
        {
            if (isOver == false)
            {
                isOver = true;
                if (agentComponent.IsWounded())
                {
                    //change fear to fearsconfirmed
                    appraisal.RemoveGoal("explosion", AppDef.Displeased, AppDef.ConsequenceForSelf, AppDef.ProspectRelevant);
                    appraisal.AddGoal("explosion", 1.0f, AppDef.Displeased, AppDef.ConsequenceForSelf, AppDef.ProspectRelevant, AppDef.Confirmed);
                }
                else
                {
                    //change fear to relief
                    appraisal.RemoveGoal("explosion", AppDef.Displeased, AppDef.ConsequenceForSelf, AppDef.ProspectRelevant);
                    appraisal.AddGoal("explosion", 0.7f, AppDef.Displeased, AppDef.ConsequenceForSelf, AppDef.ProspectRelevant, AppDef.Disconfirmed);
                }
            }
            agentComponent.DecreasePanic();

            //wait until fear is below some threshold
            if (GetComponent <AffectComponent>().emotion[(int)EType.Fear] < fearThreshold)
            {
                agentComponent.ReactivateOtherBehaviors();
                agentComponent.CalmDown();
                Destroy(this);
            }
        }
    }