public virtual bool CastDetection() { PlayerGhost _ghost = null; for (int i = 0; i < fieldOfView.Length; i++) { int _amount = Physics2D.RaycastNonAlloc(transform.position, transform.rotation * fieldOfView[i], detectionCast, range, detectionMask.value); for (int _j = 0; _j < _amount; _j++) { if (detectionCast[_j].collider.TryGetComponent(out PlayerController _player)) { if (target == null) { PlayDetectionSound(); } target = _player; TargetTransform = detectionCast[_j].collider.transform; return(true); } else if (detectionCast[_j].collider.TryGetComponent(out PlayerGhost _testGhost)) { // IS OK _ghost = _testGhost; } else { break; } } } if (_ghost && target == null) { target = _ghost; TargetTransform = _ghost.transform; PlayDetectionSound(); return(true); } return(false); }
public void UpdateState(PlayerGhost _ghost) => _ghost.Move(movement * GameManager.DeltaTime);
public void UpdateState(PlayerGhost _ghost) => _ghost.Stop(position);
public void UpdateState(PlayerGhost _ghost) => _ghost.Interact();