Beispiel #1
0
        public void FixedUpdate()
        {
            if (thisChecksForCollision)
            {
                count++;
                if (count > checkPerEveryThisFrames)
                {
                    throw new System.InvalidOperationException(
                              "fixed update frame skipped?"
                              );
                }
                if (count == checkPerEveryThisFrames)
                {
                    count = 0;
                    Vector3    position = GetPosition();
                    RaycastHit critHit;
                    int        layerMask  = 1 << (targetLayerNumber);
                    bool       hasCritHit = Physics.Linecast(thisPrevPosition, position, out critHit, layerMask);

                    if (hasCritHit)
                    {
                        Transform hitTrans = critHit.transform;

                        IArrowHitDetectorAdaptor detectorAdaptor = hitTrans.GetComponentInParent(typeof(IArrowHitDetectorAdaptor)) as IArrowHitDetectorAdaptor;
                        if (detectorAdaptor == null)
                        {
                            throw new System.InvalidOperationException(
                                      "there's no IArrowHitDetectorAdaptor assigned to the hit transform"
                                      );
                        }
                        IArrowHitDetector detector = detectorAdaptor.GetArrowHitDetector();

                        detector.Hit(thisArrow);

                        thisArrow.Land(
                            detector,
                            critHit.point
                            );
                    }
                    thisPrevPosition = position;
                }
            }
        }
 public ConstArg(
     IArrowHitDetectorAdaptor adaptor
     ) : base(adaptor)
 {
 }