// The decide function, called on Update() (State controller - current state - transition - decision). public override bool Decide(StateController controller) { // If target is not near: felt a shot and sight to target is clear, can focus. // If target is near, always check sense for target. return((sense != Sense.NEAR && controller.variables.feelAlert && !controller.BlockedSight()) || Decision.CheckTargetsInRadius(controller, radius, MyHandleTargets)); }
public override bool Decide(StateController controller) { return((sense != Sense.NEAR && controller.variables.feelAlert && !controller.BlockedSight()) || CheckTargetInRadius(controller, radius, MyHandleTargets)); // NEAR가 아닌데, 경고를 느꼈고, 시야가 막혀있지 않거나 (||) // 타겟(플레이어)이 인지 범위안에서 감지 되었다면 true }
private bool MyHanleTargets(StateController controller, bool hasTarget, Collider[] targetsInHearRadius) { if (hasTarget && !controller.BlockedSight()) { if (invalidateCoverSpot) { controller.CoverSpot = Vector3.positiveInfinity; } controller.targetInSight = true; controller.personalTarget = controller.aimTarget.position; return(true); } return(false); }
private bool MyHandleTargets(StateController controller, bool hasTarget, Collider[] targetsInRadius) { if (hasTarget) { Vector3 target = targetsInRadius[0].transform.position; Vector3 dirToTarget = target - controller.transform.position; bool inFOVCondition = (Vector3.Angle(controller.transform.forward, dirToTarget) < controller.viewAngle / 2); if (inFOVCondition && !controller.BlockedSight()) { controller.targetInSight = true; controller.personalTarget = controller.aimTarget.position; return(true); } } return(false); }
// The delegate for results of overlapping targets in focus decision. private bool MyHandleTargets(StateController controller, bool hasTargets, Collider[] targetsInHearRadius) { // Is there any target, with a clear sight to it? if (hasTargets && !controller.BlockedSight()) { // Invalidade current cover spot (ex.: used to move from position when spotted). if (invalidateCoverSpot) { controller.CoverSpot = Vector3.positiveInfinity; } // Set current target parameters. controller.targetInSight = true; controller.personalTarget = controller.aimTarget.position; return(true); } // No target on sight. return(false); }
/// <summary> /// controller가 플레이어를 발견했는가?(hasTarget) /// 발견했다면 targetsInHearRadius 충돌체 반환 /// </summary> private bool MyHandleTargets(StateController controller, bool hasTarget, Collider[] targetsInHearRadius) { //타겟이 존재하고 시야가 막히지 않았다면 if (hasTarget && !controller.BlockedSight()) { if (invalidateCoverSpot) // 현재 엄폐물 해제 { //더미값 세팅 controller.CoverSpot = Vector3.positiveInfinity; } controller.targetInSight = true; controller.personalTarget = controller.aimTarget.position; return(true); // true Desicion -> 해당 Transition을 통해 해당 State로 변화 } return(false); // false Desicion }
// The delegate for results of overlapping targets in look decision. private bool MyHandleTargets(StateController controller, bool hasTargets, Collider[] targetsInViewRadius) { // Is there any sight on view radius? if (hasTargets) { Vector3 target = targetsInViewRadius[0].transform.position; // Check if target is in field of view. Vector3 dirToTarget = target - controller.transform.position; bool inFOVCondition = (Vector3.Angle(controller.transform.forward, dirToTarget) < controller.viewAngle / 2); // Is target in FOV and NPC have a clear sight? if (inFOVCondition && !controller.BlockedSight()) { // Set current target parameters. controller.targetInSight = true; controller.personalTarget = controller.aimTarget.position; return(true); } } // No target on sight. return(false); }
public override bool Decide(StateController controller) { return((sence != Sence.NEAR && controller.variables.feelAlert && !controller.BlockedSight()) || Decision.CheckTargetsInRadius(controller, radius, MyHanleTargets)); }