/// <summary> /// Sets the target position for the navigation agent. /// </summary> /// <param name="_args"></param> protected override void OnActorCommandReceive(OnActorCommandReceiveEventArgs _args) { if (GetOwner == _args.baseArgs.actor) { if (_args.command.Equals(ActorCommands.Move)) { targetPosition = (Vector3)_args.value; targetPosition.y = 0; } } }
private void ChaseTarget(AIView _controller) { if (_controller.GetAIData.GetNavigationComponent.isStopped) { _controller.GetAIData.GetNavigationComponent.isStopped = false; } ChaseData data = _controller.GetStateData <ChaseData>(); Vector3 targetPosition = data.GetCurrentTarget.transform.position; OnActorCommandReceiveEventArgs args = new OnActorCommandReceiveEventArgs() { baseArgs = new OnActorEventEventArgs() { actor = _controller.GetOwner }, command = ActorCommands.Move, value = targetPosition }; EventController.QueueEvent(ActorEvents.ACTOR_COMMAND_RECEIVE, args); }
/// <summary> /// Sends a shoot and aim command to the ai. /// </summary> /// <param name="_controller"></param> private void DoShoot(AIView _controller) { if (!_controller.GetAIData.GetNavigationComponent.isStopped) { _controller.GetAIData.GetNavigationComponent.isStopped = true; } ShootData data = _controller.GetStateData <ShootData>(); Vector3 startPosition = _controller.GetOwner.GetCenterOfBodyPosition; Vector3 targetPosition = data.GetCurrentTarget.GetCenterOfBodyPosition; Vector3 vectorToTarget = targetPosition - startPosition; OnActorCommandReceiveEventArgs aimArgs = new OnActorCommandReceiveEventArgs() { baseArgs = new OnActorEventEventArgs() { actor = _controller.GetOwner }, command = ActorCommands.Aim, // Means the shoot button is pressed. value = vectorToTarget.normalized }; EventController.QueueEvent(ActorEvents.ACTOR_COMMAND_RECEIVE, aimArgs); OnActorCommandReceiveEventArgs shootArgs = new OnActorCommandReceiveEventArgs() { baseArgs = new OnActorEventEventArgs() { actor = _controller.GetOwner }, command = ActorCommands.Shoot, // Means the shoot button is pressed. value = 1.0f }; EventController.QueueEvent(ActorEvents.ACTOR_COMMAND_RECEIVE, shootArgs); }
public override bool Decide(AIView _controller) { bool keepShooting = base.Decide(_controller); // If we can't keep shooting send a shoot command with a input value of 0.0f. if (!keepShooting) { OnActorCommandReceiveEventArgs args = new OnActorCommandReceiveEventArgs() { baseArgs = new OnActorEventEventArgs() { actor = _controller.GetOwner }, command = ActorCommands.Shoot, // Means the shoot button has been released. value = 0.0f }; EventController.QueueEvent(ActorEvents.ACTOR_COMMAND_RECEIVE, args); } return(keepShooting); }