Пример #1
0
 public override Status update(EntityKnowledgeFacade entity, UInt32 request, StopParticipateParam parameters, StaticObject paramsOut, float dt)
 {
     if (entity.getKnowledge().getInt("Events.inEvent") == 0)
     {
         entity.getKnowledge().setInt("Events.inEvent", 1);
     }
     if (entity.getKnowledge().getInt("IP.inIP") == 0)
     {
         entity.getKnowledge().setInt("IP.inIP", 1);
     }
     return(Status.succeeded);
 }
Пример #2
0
    public override Status update(EntityKnowledgeFacade entity, UInt32 request, GotoEntityParam parameters, StaticObject paramsOut, float dt)
    {
        if (parameters.target != "none")
        {
            for (uint i = 0; i < nbrEntity; i++)
            {
                if (i != entity.entity.entityID)
                {
                    Aname = entity.getEntityKnowledge(i).getString("name");
                    if (Aname == parameters.target)
                    {
                        entity.getEntityKnowledge(i).retrieve(entity.getEntityKnowledge(i).getProperty("position"), out position);
                        if (parameters.location == true)
                        {
                            entity.getKnowledge().setString("location", "none");
                            entity.getKnowledge().setString("interactName", "none");
                            entity.getKnowledge().setString("destination", Aname);
                        }
                    }
                }
            }
        }

        if (parameters.targetID != -1)
        {
            index = (uint)parameters.targetID;
            entity.getEntityKnowledge(index).retrieve(entity.getEntityKnowledge(index).getProperty("position"), out position);
            if (parameters.location == true)
            {
                entity.getKnowledge().setString("location", "none");
                entity.getKnowledge().setString("interactName", "none");
                //entity.getKnowledge().setString("destination", Aname);
            }
        }


        //index = (uint)parameters.target;
        //Debug.Log(index);
        //entity.getEntityKnowledge(index).retrieve(entity.getEntityKnowledge(index).getProperty("position"), out position);

        GameObject   self = entity.entity.gameObject;
        NavMeshAgent nav  = entity.entity.GetComponent <NavMeshAgent>();

        // Create a vector from the enemy to the last sighting of the player.
        Vector3 sightingDeltaPos = position - self.transform.position;

        // If the the last personal sighting of the player is not close...
        if (sightingDeltaPos.sqrMagnitude > 4f)
        {
            // ... set the destination for the NavMeshAgent to the last personal sighting of the player.
            nav.destination = position;
        }
        if (sightingDeltaPos.sqrMagnitude < parameters.threshold)
        {
            nav.Stop();
            if (parameters.location == true)
            {
                entity.getKnowledge().setString("location", Aname);
                entity.getKnowledge().setString("interactName", Aname);
                entity.getKnowledge().setString("destination", "none");
            }
            return(Status.succeeded);
        }

        /*for(uint i = 0; i < nbrEntity; i++){
         *      if(entity.getEntityKnowledge(i).getBool("interruption") ==  true)
         *      {
         *              nav.Stop();
         *              return Status.succeeded;
         *      }
         * }*/

        return(Status.running);
    }