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); }
public override RAIN.Action.Action.ActionResult Start(RAIN.Core.Agent agent, float deltaTime) { Debug.Log("I am wandering"); if (actionContext.ContextItemExists("playerLoc") && actionContext.ContextItemExists("canSee")) { _goHero = actionContext.GetContextItem <GameObject>("playerLoc"); actionContext.SetContextItem("canSee", 1); } return(RAIN.Action.Action.ActionResult.SUCCESS); }
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); }
public override RAIN.Action.Action.ActionResult Execute(RAIN.Core.Agent agent, float deltaTime) { if (_goHero != null) { agent.LookAt(_goHero.transform.position, deltaTime); agent.MoveTarget.VectorTarget = _goHero.transform.position; if (!agent.Move(deltaTime)) { RAIN.Sensors.RaycastSensor s = (RAIN.Sensors.RaycastSensor)agent.GetSensor("Sensor"); if (!s.CanSee(_goHero)) { if (actionContext.ContextItemExists("canSee")) { actionContext.SetContextItem("canSee", 0); agent.Mind.CancelInvoke("Move"); agent.Mind.Reset(); return(RAIN.Action.Action.ActionResult.SUCCESS); } } return(ActionResult.RUNNING); } } return(RAIN.Action.Action.ActionResult.SUCCESS); }
public override RAIN.Action.Action.ActionResult Stop(RAIN.Core.Agent agent, float deltaTime) { Debug.Log("Stop"); return(RAIN.Action.Action.ActionResult.SUCCESS); }
public override RAIN.Action.Action.ActionResult Execute(RAIN.Core.Agent agent, float deltaTime) { return(RAIN.Action.Action.ActionResult.SUCCESS); }
public override RAIN.Action.Action.ActionResult Start(RAIN.Core.Agent agent, float deltaTime) { _path = (RAIN.Path.RAINPathManager)agent.PathManager; return(RAIN.Action.Action.ActionResult.SUCCESS); }