/* Spawn Landed Arrow */ public virtual void SpawnLandedArrowOn( // IShootingTarget target, IArrowHitDetector detector, Vector3 position, Quaternion rotation ) { thisLandedArrowReserve.ActivateLandedArrowAt( detector, position, rotation ); }
public void ActivateAt( IArrowHitDetector detector, Vector3 position, Quaternion rotation ) { SetHitDetector( detector, position, rotation ); Activate(); }
public void ActivateLandedArrowAt( IArrowHitDetector detector, Vector3 position, Quaternion rotation ) { ILandedArrow nextLandedArrow = GetNext(); nextLandedArrow.Deactivate(); nextLandedArrow.ActivateAt( detector, position, rotation ); }
void SetHitDetector( IArrowHitDetector detector, Vector3 position, Quaternion rotation ) { RemoveSelfFromCurrentDetector(); thisDetector = detector; AddSelfToCurrentDetector(); SetParent(detector); // ResetLocalTransform(); SetPosition(position); SetRotation(rotation); }
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 void Land( // IShootingTarget target, IArrowHitDetector detector, Vector3 hitPosition ) { // if(detector.IsActivated()) if (detector.ShouldSpawnLandedArrow()) { thisShootingManager.SpawnLandedArrowOn( detector, hitPosition, thisAdaptor.GetRotation() ); thisArrowAdaptor.PlayArrowHitSound(); } Deactivate(); }
public override void SetUp() { thisDetector = CreateArrowHitDetector(); thisColliders = CollectColliders(); }