Esempio n. 1
0
    public override RAIN.Action.Action.ActionResult Execute(RAIN.Core.Agent agent, float deltaTime)
    {
        if (_getNext)
        {
            if (_previousPoint > 4)
            {
                _previousPoint = 1;
            }

            if (_path != null)
            {
                agent.LookTarget.TransformTarget = _path.waypointCollection.transform.FindChild(_previousPoint.ToString()).transform;
            }

            _previousPoint = Random.Range(1, 5);
            _getNext       = false;
        }

        if (!agent.MoveTo(agent.LookTarget.TransformTarget.position, deltaTime))
        {
            return(ActionResult.RUNNING);
        }
        else
        {
            _getNext = true;
        }
        return(RAIN.Action.Action.ActionResult.SUCCESS);
    }
Esempio n. 2
0
  public override RAIN.Action.Action.ActionResult Execute(RAIN.Core.Agent agent, float deltaTime)
  {
      //get position of passenger, if he has not moved to a random position yet (boolean flag)
      //get the random destination from the action context, move him there
      Vector3 pos = agent.Avatar.transform.position;

      if (flag == false)
      {
          no   = agent.actionContext.GetContextItem <Vector3>("newpos");
          flag = true;
      }
      agent.MoveTo(no, deltaTime);

      //check if he has reached random destination; if so, move to closest door
      if (Mathf.Abs((int)no.x - (int)pos.x) <= 1 && Mathf.Abs((int)no.z - ((int)pos.z)) <= 1)
      {
          script = (closestDoor)agent.Avatar.gameObject.GetComponent("closestDoor");
          script.calculateDoor();
          no = agent.actionContext.GetContextItem <Vector3>("door");
          agent.MoveTo(no, deltaTime);
      }
      return(RAIN.Action.Action.ActionResult.FAILURE);
  }