コード例 #1
0
 /* Spawn Landed Arrow */
 public virtual void SpawnLandedArrowOn(
     // IShootingTarget target,
     IArrowHitDetector detector,
     Vector3 position,
     Quaternion rotation
     )
 {
     thisLandedArrowReserve.ActivateLandedArrowAt(
         detector,
         position,
         rotation
         );
 }
コード例 #2
0
 public void ActivateAt(
     IArrowHitDetector detector,
     Vector3 position,
     Quaternion rotation
     )
 {
     SetHitDetector(
         detector,
         position,
         rotation
         );
     Activate();
 }
コード例 #3
0
        public void ActivateLandedArrowAt(
            IArrowHitDetector detector,
            Vector3 position,
            Quaternion rotation
            )
        {
            ILandedArrow nextLandedArrow = GetNext();

            nextLandedArrow.Deactivate();
            nextLandedArrow.ActivateAt(
                detector,
                position,
                rotation
                );
        }
コード例 #4
0
        void SetHitDetector(
            IArrowHitDetector detector,
            Vector3 position,
            Quaternion rotation
            )
        {
            RemoveSelfFromCurrentDetector();
            thisDetector = detector;
            AddSelfToCurrentDetector();

            SetParent(detector);
            // ResetLocalTransform();
            SetPosition(position);
            SetRotation(rotation);
        }
コード例 #5
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;
                }
            }
        }
コード例 #6
0
        public void Land(
            // IShootingTarget target,
            IArrowHitDetector detector,
            Vector3 hitPosition
            )
        {
            // if(detector.IsActivated())
            if (detector.ShouldSpawnLandedArrow())
            {
                thisShootingManager.SpawnLandedArrowOn(
                    detector,
                    hitPosition,
                    thisAdaptor.GetRotation()
                    );
                thisArrowAdaptor.PlayArrowHitSound();
            }

            Deactivate();
        }
コード例 #7
0
 public override void SetUp()
 {
     thisDetector  = CreateArrowHitDetector();
     thisColliders = CollectColliders();
 }