Пример #1
0
		//----------------------------------------------------------------
		private void SearchTarget()
		{
			if (Context.CurrentTarget != null) return;

			Player target = null;

			//interval search
			if (Time.time >= m_nextSearch)
			{
				target = PlayerTracker.Instance.GetValidEnemies(Context.Owner)
									  .FindNearest(Context.Owner.transform.position, out _);
				m_nextSearch = Time.time + TargetSearchInterval;
			}

			if (target == null) return;

			var isValidTarget = FSMHelper.IsInsideConeLineHitTest(Context.Owner.transform,
					target.transform,
					TargetDetectionRange,
					FieldOfView,
					ObstacleMask);
			if (!isValidTarget) return;

			//if valid target is available
			//set target and move to next state

			Context.CurrentTarget = target;
			GoToNextState(nameof(AttackState));
		}
Пример #2
0
 //----------------------------------------------------------------
 public override void DrawGizmos()
 {
     FSMHelper.DrawCone(Context.Owner.transform, AttackDistance, FieldOfView);
     if (Context.CurrentTarget != null)
     {
         FSMHelper.DrawSphereCast(Context.Owner.transform, Context.CurrentTarget.transform, HitTestThickness);
     }
 }
Пример #3
0
        //----------------------------------------------------------------
        private void ShootTarget()
        {
            var isVisible = FSMHelper.IsInsideConeSphereHitTest(Context.Owner.transform,
                                                                Context.CurrentTarget.transform,
                                                                AttackDistance,
                                                                FieldOfView,
                                                                ObstacleMask,
                                                                HitTestThickness);

            if (isVisible)
            {
                Weapon.Fire();
            }
        }
Пример #4
0
		//----------------------------------------------------------------
		public override void DrawGizmos()
		{
			FSMHelper.DrawCone(Context.Owner.transform, TargetDetectionRange, FieldOfView);
		}