예제 #1
0
    void Update()
    {
        if (agentComponent.IsDead())
        {
            if (bannerCarrier)
            {
                banner.SetActiveRecursively(false);
            }
            return;
        }

        UpdateAction();

        if (agentComponent.IsFighting() == false)
        {
            frameCnt++;
            UpdateAttractor();

            // if (affectComponent.emotion[(int)EType.Anger] > 0.6f)
            //   Instantiate(UnityEngine.Resources.Load("Explosion"), transform.position, new Quaternion());

            foreach (GameObject c in agentComponent.collidingAgents)
            {
                if (agentComponent.IsGoodToFight(c))
                {
                    agentComponent.StartFight(c);
                    c.GetComponent <AgentComponent>().StartFight(this.gameObject);
                    frameCnt = 0;
                    break;
                }
            }
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (agentComponent.IsDead())
        {
            shield.SetActiveRecursively(false);
            return;
        }


        UpdateAction();

        if (agentComponent.IsFighting() == false)
        {
            // if (intruder == null && (post - transform.position).magnitude > 1f) //if no one to watch && stop jittering
            if ((post - transform.position).magnitude > 2f) //if no one to watch && stop jittering
            {
                agentComponent.SteerTo(post);
            }
            // else
            //   agentComponent.GetComponent<NavMeshAgent>().Stop();
            Vigil();
        }
    }
예제 #3
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);
            }
        }
    }